[GLASSFISH-7229] java.lang.String entry for JNDI Created: 25/Feb/09  Updated: 06/Mar/12

Status: Open
Project: glassfish
Component/s: admin_gui
Affects Version/s: v2.1
Fix Version/s: not determined

Type: Improvement Priority: Blocker
Reporter: lsacco Assignee: Anissa Lam
Resolution: Unresolved Votes: 6
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: All
Platform: All

Issuezilla Id: 7,229


Under JNDI custom resources you should have the ability to add a JNDI value for
java.lang.String similar to Tomcat or other JEE containers. This is essential
for us because we use commons-configuration in our application to look for that
value to be DEV, TEST, or PROD and then pick runtime attributes from our
internal config.

Comment by Amy Roh [ 26/Feb/09 ]


Comment by Amy Roh [ 26/Feb/09 ]

Can you elaborate? GlassFish already supports java.lang.String entry for JNDI
via Environment entry like tomcat.

<Environment name="..." type="java.lang.String" value="..."/>

Comment by lsacco [ 26/Feb/09 ]

This is what I do in Tomcat:

<Environment name="config/com/xxx/pds/env" override="false"
type="java.lang.String" value="DEV" />

Where in the Admin UI for Glassfish can I set this or do I have to update an XML
file somewhere on the server?


Comment by Amy Roh [ 26/Feb/09 ]

If you want to define environment entry that will be shared across the server,
you can create global context.xml in
glassfish/domains/domain1/config/context.xml and this will be loaded by all

In your global context.xml, you can have the same Tomcat entry

<Environment name="config/com/xxx/pds/env" override="false"
type="java.lang.String" value="DEV" />

Different levels of context.xml support is described in my blog -

This should suit your need, correct?

Comment by lsacco [ 02/Mar/09 ]

So I decided to do the first one similar to what we do in Tomcat and add this
appropriate entry in the context.xml file as follows:

<Environment name="config/com/xxx/pds/env" override="false"
type="java.lang.String" value="DEV" />

I restart the server, but fail with exception:
9471-4218-a69b-0bfb1400f1b8;|WebModule[/PCNRequestApprovalWeb]PWC1275: Exception
sending context initialized event to listener instance of class

This is the offending code (I assume I just need to remove java:comp/env for the
context look-up):

try {
InitialContext ctx = new InitialContext();
String env = (String)ctx.lookup("config/com/qualcomm/pds/env");
String config = "sm-security-config.xml";
if ("local".equalsIgnoreCase(env))

{ config = "local-security-config.xml"; }

configs.add(PREFIX + config);

} catch (NamingException ne)

{ throw new ApplicationContextException(ne.getMessage()); }

Also, when I browse the JNDI tree from the admin console I do not see this entry
in the tree. Any suggestions?

Comment by lsacco [ 03/Mar/09 ]

FYI...there's workarounds for this (the blog post didn't work) but I feel that
you should be able to set a String property from the admin console as a String
and have it bound to the JNDI tree. This is a request for enhancement to that end.

Comment by Amy Roh [ 03/Mar/09 ]

Yes, I agree that you should be able to edit environment entry using the admin
console. I believe admin gui folks are working on this already. Assigning the
enhancement request to admin gui team.

Comment by Amy Roh [ 03/Mar/09 ]

Assign the enhancement request to admin gui team.

Comment by athrawn17 [ 09/Mar/09 ]

Just wanted to link back to the forum discussion.


Comment by freddio [ 06/Apr/09 ]
      • Issue 7229 has been confirmed by votes. ***
Comment by kumara [ 01/Sep/09 ]

Changing version from 9.1.1 to v2.1 to reflect new name/version.

Comment by teenow [ 10/May/11 ]

Close this issue when done.

Comment by Tom Mueller [ 06/Mar/12 ]

Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

Generated at Tue Jun 02 19:59:42 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.