Search code examples
javaweb-applicationsjbossjndidirectory

Storing properties in JNDI? Environment specific locations


I want access to a storage folder but its actual location can vary with environments. Could I store properties into JNDI or do something similar to a datasource in JBOSS? How would I go about it?

Thanks.


Solution

  • The regular way to pass parameter in Java EE application is through the property in the deployment descriptor using env-entry. They will be bound in the JNDI so that you can inject them.

    <env-entry>
    <env-entry-name>docroot_path</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/usr/local/foo</env-entry-value>
    </env-entry>