Results 1 to 2 of 2

Thread: jndi property as environment variable

  1. #1
    Join Date
    Jul 2010
    Posts
    16

    Default jndi property as environment variable

    I have an environment variable setup in my tomcat context file as

    Code:
    <Environment name="envName" value="local" type="java.lang.String" override="true"/>
    I am able to read this in my spring-context.xml file by

    Code:
    <context:property-placeholder location="classpath:app-${envName}.properties"/>
    This works fine but when I deploy the application in websphere I have the same variable defined as a jndi entry. So obviously it doesnt works anymore and spring is not able to find the property value. How can i retrieve a jndi based string value and use that in spring expressions to load the correct properties file.

    Thanks

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    I both tomcat and websphere it is a jndi variable/entry. However in Tomcat it is automatically available in java:comp/env in websphere it depends on where you defined it. In general you need to add a resource-ref in your web.xml to make it local for your app.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •