Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 72759 invoked from network); 3 Nov 2009 14:03:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Nov 2009 14:03:24 -0000 Received: (qmail 73873 invoked by uid 500); 3 Nov 2009 14:03:20 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 73811 invoked by uid 500); 3 Nov 2009 14:03:19 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 73800 invoked by uid 99); 3 Nov 2009 14:03:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2009 14:03:19 +0000 X-ASF-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of pohl@tyntec.com designates 78.110.225.202 as permitted sender) Received: from [78.110.225.202] (HELO zimbra.tyntec.com) (78.110.225.202) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2009 14:03:15 +0000 Received: from zimbra.tyntec.com (zimbra.tyntec.com [78.110.225.202]) by zimbra.tyntec.com (Postfix) with ESMTP id AE758300007AC for ; Tue, 3 Nov 2009 15:02:49 +0100 (CET) Date: Tue, 3 Nov 2009 15:02:49 +0100 (CET) From: Carsten Pohl Reply-To: pohl@tyntec.com To: Tomcat Users List Message-ID: <15249397.1202831257256969622.JavaMail.root@zimbra.tyntec.com> In-Reply-To: <24998256.1202651257256797246.JavaMail.root@zimbra.tyntec.com> Subject: Re: Trouble with context and JNDI resource MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.3.4.23] X-Mailer: Zimbra 5.0.13_GA_2791.UBUNTU6 (ZimbraWebClient - SAF3 (Linux)/5.0.13_GA_2791.UBUNTU6) 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" To: "Tomcat Users List" 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: WEB-INF/web.xml I have this in web.xml: Connection pool for xmlrpc. proteus org.apache.commons.dbcp.BasicDataSource 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-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org