Announcement Announcement Module
Collapse
No announcement yet.
How to make j2ee:environment optional for a jndi-lookup ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to make j2ee:environment optional for a jndi-lookup ?

    Hello,

    I'm using <j2ee:jndi-lookup> to get my DataSource. I'd like the JNDI environment to be configurable, so I'm using a PlaceHolder and a properties file to set java.naming.factory.initial.

    So I've set :
    Code:
      <j2ee:jndi-lookup id="dataSource" jndi-name="jdbc/BGCAF">
         <j2ee:environment>
            java.naming.factory.initial=${datasource.JndiFactory.className}
         </j2ee:environment>
      </j2ee:jndi-lookup>
    But I also want this property to be optional, so that I can get the default JNDI context.
    If I don't set the property, the placeholder fails (Could not resolve placeholder...).
    If I set the property to "" (empty), I get a NoInitialContextException as InitialContext tries to instantiate "" class.

    Is there any way to make some part of the Spring context optional ?
Working...
X