You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Seth Ladd <se...@ehawaii.gov> on 2005/07/28 04:00:21 UTC

accessing global Environment values?

Hello,

I have a stock Tomcat 5.5.9 with JDK 1.5.  This is a fresh install, 
nothing has changed.

I am not able to lookup the default simpleValue environment variable 
form JNDI with a simple JSP file.  Is there anything else I have to do 
to move an Environment variable, from GlobalNamingResources, into the 
scope of a webapp?

I placed a JSP file into the webapps/ROOT directory, just for testing 
(contents below).  The last line throws the NamingException because it's 
not found.  When I remove the last line, I'm able to browse the JNDI 
tree, and I get the following output:

 From java: : comp: org.apache.naming.NamingContext
 From java:comp/ : UserTransaction: org.apache.naming.TransactionRef
 From java:comp/ : env: org.apache.naming.NamingContext
 From java:comp/ : Resources: org.apache.naming.resources.ProxyDirContext

Any advice on how to expose GlobalNamingResources's Environment 
variables into webapps?

Thanks very much,
Seth

Test JSP File, in webapps/ROOT :

<%

javax.naming.Context ctx = new javax.naming.InitialContext();
javax.naming.NamingEnumeration e = ctx.list("java:");
while (e.hasMoreElements()) {
out.println("From java: : " + e.nextElement() + "<br>");
}
e = ctx.list("java:comp/");
while (e.hasMoreElements()) {
out.println("From java:comp/ : " + e.nextElement() + "<br>");
}
e = ctx.list("java:comp/env/");
while (e.hasMoreElements()) {
out.println("From java:comp/env/ : " + e.nextElement() + "<br>");
}

System.out.println(new 
javax.naming.InitialContext().lookup("java:comp/env/simpleValue"));

%>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: accessing global Environment values?

Posted by Seth Ladd <se...@ehawaii.gov>.
Mark Thomas wrote:
> Seth Ladd wrote:
> 
>> I am not able to lookup the default simpleValue environment variable 
>> form JNDI with a simple JSP file.  Is there anything else I have to do 
>> to move an Environment variable, from GlobalNamingResources, into the 
>> scope of a webapp?
>>
>> Any advice on how to expose GlobalNamingResources's Environment 
>> variables into webapps?
> 
> 
> You could start by reading the documentation for JNDI resources.
> 
> http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-resources-howto.html

Yes, I read that over and over and I was missing my <ResourceLink> tag 
in the context.xml.  For some reason, I kept missing it in the 
documentation.

Seth

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: accessing global Environment values?

Posted by Mark Thomas <ma...@apache.org>.
Seth Ladd wrote:
> I am not able to lookup the default simpleValue environment variable 
> form JNDI with a simple JSP file.  Is there anything else I have to do 
> to move an Environment variable, from GlobalNamingResources, into the 
> scope of a webapp?
> 
> Any advice on how to expose GlobalNamingResources's Environment 
> variables into webapps?

You could start by reading the documentation for JNDI resources.

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-resources-howto.html

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org