Hi, I am no expert, but your lookup looks strange. (Empty string in lookup). Furthermore these two contextes seem "strange" to me.
This works great for me: @Override public void init() throws ServletException { LOGGER.info("INIT has been called"); try { final InitialContext initialContext = new InitialContext(); if ( initialContext == null ) { final String error = "Could not create initialContext. Errors WILL happen"; LOGGER.severe(error); throw new ServletException(error); } // actual jndi name is "jdbc/postgres" CustomerloungeServlet.datasource = (DataSource) initialContext.lookup( "java:/comp/env/jdbc/postgres" ); if ( CustomerloungeServlet.datasource == null ) { final String error = "Could not lookup, Errors WILL happen"; LOGGER.severe(error); throw new ServletException(error); } } catch (NamingException e) { LOGGER.log(Level.SEVERE,"Namingexception in init",e); throw new ServletException(e.getMessage()); } } And I did not put org.apache.commons.dbcp.BasicDataSource as type of the ressource. I guess it must be org.apache.commons.dbcp.dbcp..... (I guess) but in the tomcat source is string compared to: "javax.sql.DataSource" You can try that. Regards, Carsten Pohl ----- Original Message ----- From: "Mike Baranski" <list-subscripti...@secmgmt.com> To: "Tomcat Users List" <users@tomcat.apache.org> Sent: Tuesday, 3 November, 2009 14:49:04 GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna Subject: Trouble with context and JNDI resource I'm using this page, trying to get a resource in a java class: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html I have this in context.xml: <Context> <!-- Default set of monitored resources --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <Resource name="proteus" auth="Container" type="org.apache.commons.dbcp.BasicDataSource" maxActive="100" maxIdle="30" maxWait="10000" username="install" password="install" driverClassName="com.informix.jdbc.IfxDriver" url="jdbc:informix-sqli://sigma:1960/proteus:INFORMIXSERVER=sigma;IFX_LOCK_M ODE_WAIT=-1;IFX_ISOLATION_LEVEL=1"> </Resource> </Context> I have this in web.xml: <resource-env-ref> <description> Connection pool for xmlrpc. </description> <resource-env-ref-name> proteus </resource-env-ref-name> <resource-env-ref-type> org.apache.commons.dbcp.BasicDataSource </resource-env-ref-type> </resource-env-ref> I have this code: l.debug("Created the status xmlrpc class"); Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(""); this.setDataSource((BasicDataSource) envCtx.lookup("proteus")); I get this error: Name proteus is not bound in this Context --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org