0

When I have used jndi-place-holder name as ${myappdb.jndi} having following error. When I used the direct JNDI name instead of using placeholder name it worked properly. Why Spring jndi does not read JNDI name from placeholder? I am sure "myappdb.jndi" is defined in "myapp.cfg" file.

Using:

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>

Error:

    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)
Ahmet Karakaya
  • 9,899
  • 23
  • 86
  • 141
  • See http://stackoverflow.com/questions/12391474/read-an-environment-variable-from-applicationcontext-xml and http://forum.spring.io/forum/spring-projects/container/91457-how-to-read-system-property-in-applicationcontext-xml for similar questions – Display Name is missing Oct 20 '14 at 19:46
  • I do not wanna se SYSTEM variable, all solutions focus that one – Ahmet Karakaya Oct 21 '14 at 08:00
  • Is the relative path to your config file really `/conf/myapp.cfg`? Have you seen property loading examples like http://www.baeldung.com/2012/02/06/properties-with-spring/ that use something like `classpath:/conf/myapp.cfg` instead? – Display Name is missing Oct 21 '14 at 15:58

0 Answers0