java - 如何使用 Spring JndiObjectFactoryBean 为 tomcat7 设置 jndiname 属性值?我这里的属性值是一个文件
问题描述
我正在尝试将在 jboss5 中运行的 web 应用程序转换为 tomcat7。我需要更改元数据属性的 JNDI 配置才能在 tomcat 中工作。元数据属性在外部属性文件中配置,并且必须在应用程序启动期间加载属性文件。
<bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<bean class="org.springframework.core.io.FileSystemResource">
<constructor-arg>
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${CATALINA_HOME}/conf/metadata.properties" />
</bean>
</constructor-arg>
</bean>
</list>
</property>
</bean>
应用程序应该加载 jndiName 属性值,但它不工作。它抛出以下错误,
Caused by: javax.naming.NameNotFoundException: Name [${CATALINA_HOME}/conf/metadata.properties] is not bound in this Context. Unable to find [${CATALINA_HOME}].
而为 jboss 提供了相同的配置。取而代之的${CATALINA_HOME}
是"external/config/"
。
你们能帮我看看我是否错过了tomcat的任何其他配置。
(我还在文件中定义${CATALINA_HOME}
了环境变量,catalina.sh
并且其他属性文件已正确加载。即使我给出绝对路径,它也会显示相同的错误。)
Caused by: javax.naming.NameNotFoundException: Name [root/user1/apache-tomcat-7.0.92/conf/metadata.properties] is not bound in this Context. Unable to find [root].
解决方案
推荐阅读
- oracle-adf - 如何通过托管 bean 以编程方式提交?
- cassandra - Cassandra 不可预测的失败取决于 WHERE 子句
- python - 如果连续的数据框值相等,则编辑第二列的值
- jetty - 通过发送到环回服务请求
- delphi - 如何初始化自定义控件?
- python - 保存响应中的 unicode 文本而不编码到文件中
- sql - 使用大查询 safe_divide 逻辑操作数据时如何停止数据重复?
- mongodb - Mongodb + PHP 无法使用数据库“Czechia”发送“find”命令:无法读取 4 个字节:套接字错误或超时
- angular - Angular 可以在集成测试中测试什么以及在单元测试中测试什么
- r - 如何创建代码来计算 R 中的“空白”行