<< Back to previous view

[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
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: All
Platform: All

Issuezilla Id: 7,229
Participants: Amy Roh, Anissa Lam, athrawn17, freddio, kumara, lsacco, teenow and Tom Mueller


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 10:33 AM ]


Comment by Amy Roh [ 26/Feb/09 11:16 AM ]

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 11:42 AM ]

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 11:56 AM ]

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 05:45 PM ]

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 10:56 AM ]

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 11:17 AM ]

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 11:20 AM ]

Assign the enhancement request to admin gui team.

Comment by athrawn17 [ 09/Mar/09 10:06 AM ]

Just wanted to link back to the forum discussion.


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

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

Comment by teenow [ 10/May/11 12:17 AM ]

Close this issue when done.

Comment by Tom Mueller [ 06/Mar/12 09:56 PM ]

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 Sat Apr 19 04:52:41 UTC 2014 using JIRA 4.0.2#472.