当我使用jndi-place-holder名称为$ {myappdb.jndi}时出现以下错误。 当我使用直接JNDI名称而不是使用占位符名称时,它正常工作。 为什么Spring jndi不从占位符读取JNDI名称?我肯定" myappdb.jndi"在" myapp.cfg"中定义文件。
使用:
Weblogic 12c
Spring 3.x
的applicationContext.xml
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="ignoreResourceNotFound" value="false"/>
<property name="order" value="1" />
<property name="locations">
<list>
<value>file:/conf/myapp.cfg</value>
</list>
</property>
</bean>
<jee:jndi-lookup id="myapp.db" jndi-name="${myappdb.jndi}"/>
<bean name="myappDbDaoImpl" class="com.myapp.db.myappDbDaoImpl">
<property name="dataSource" ref="myapp.db" />
</bean>
错误:
weblogic.application.ModuleException: javax.naming.NameNotFoundException: While trying to lookup '${myappdb.jndi}' didn't find subcontext '${myappdb'. Resolved ''; remaining name '${
myappdb/jndi}'
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)