Martin, Thanks for the suggestion, though I think there may have been some misunderstanding. I'm attempting to access a simple java.lang.String, not a DataSource. <Environment/> elements are used to place String resources in an application's environment, not <Resource/> elements, AFAIK.
Paul. 2008/9/3 Martin Gainty <[EMAIL PROTECTED]>: > > http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html<BR> > /WEB-INF/web.xml contents which contain a jndi reference <BR><web-app > xmlns="http://java.sun.com/xml/ns/j2ee"<BR> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<BR> > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee<BR> > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"<BR> > version="2.4"><BR> > <description>MySQL Test App</description><BR> > <resource-ref><BR> > <description>DB Connection</description><BR> > <res-ref-name>teststring</res-ref-name><BR> > <res-type>javax.sql.DataSource</res-type><BR> > <res-auth>Container</res-auth><BR> > </resource-ref><BR> > </web-app><BR> > > the lookup to teststring will get you a connection to the DB<BR> > > HTH<BR> > Martin<BR> > ______________________________________________ > Disclaimer and confidentiality note > Everything in this e-mail and any attachments relates to the official > business of Sender. This transmission is of a confidential nature and Sender > does not endorse distribution to any party other than intended recipient. > Sender does not necessarily endorse content contained within this > transmission. > > >> Date: Wed, 3 Sep 2008 01:01:40 +0100 >> From: [EMAIL PROTECTED] >> To: users@tomcat.apache.org >> Subject: Problem with JNDI environment entry resources >> >> Tomcat 6.0.18 >> java version "1.6.0_06" (sun-java6-jdk on Ubuntu 8.04 i386) >> >> I'm attempting to create environment entry resources, of type >> java.lang.String, within conf/server.xml and access them from web >> applications using JNDI. I've created a bare-bones test web app, >> jndistring, with the following conf/server.xml configuration: >> >> server.xml (snipped): >> ----------------------------- >> <Host name="localhost" >> appBase="webapps" >> unpackWARs="true" >> autoDeploy="false" >> deployOnStarup="true" >> xmlValidation="false" >> xmlNamespaceAware="false"> >> >> <Context docBase="jndistring.war" >> path="jndistring" >> useNaming="true"> >> >> <Environment name="teststring" >> value="a test value" >> type="java.lang.String" >> override="false" >> /> >> </Context> >> >> </Host> >> >> For the purpose of this test I've used jsp to access the value of teststring. >> >> jndistring.jsp (snipped): >> -------------------------------- >> <% >> Context initCtx = new InitialContext(); >> Context envCtx = (Context) initCtx.lookup("java:comp/env"); >> >> String teststring = (String) envCtx.lookup("teststring"); >> out.println("teststring: " + teststring); >> %> >> >> Accessing this page throws an exception: >> org.apache.jasper.JasperException: An exception occurred processing >> JSP page /test.jsp at line 18 >> 15: Context initCtx = new InitialContext(); >> 16: Context envCtx = (Context) initCtx.lookup("java:comp/env"); >> 17: >> 18: String teststring = (String) envCtx.lookup("teststring"); >> 19: out.println("teststring: " + teststring); >> 20: %> >> >> The top frame of the root cause is shown as: >> javax.servlet.ServletException: javax.naming.NameNotFoundException: >> Name teststring is not bound in this Context >> >> If I attempt to create an environment entry resource using >> <env-entry/> (and sub-elements) within web.xml, then the resource is >> created and I can access it!!! >> >> I've read the "JNDI resources howto", docs regarding the <Host/>, >> <Context/> and <Environment/> elements (and others), but don't see >> that I have missed anything. >> >> Can anyone suggest what I might have missed? Has anyone else had >> similar problems? >> >> Thanks, >> >> Paul. >> >> --------------------------------------------------------------------- >> To start a new topic, e-mail: users@tomcat.apache.org >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> > > _________________________________________________________________ > Get thousands of games on your PC, your mobile phone, and the web with > Windows(R). > http://clk.atdmt.com/MRT/go/108588800/direct/01/ --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]