Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 425FA7430 for ; Thu, 22 Sep 2011 15:42:40 +0000 (UTC) Received: (qmail 7951 invoked by uid 500); 22 Sep 2011 15:42:36 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 7818 invoked by uid 500); 22 Sep 2011 15:42:36 -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 7808 invoked by uid 99); 22 Sep 2011 15:42:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Sep 2011 15:42:36 +0000 X-ASF-Spam-Status: No, hits=2.9 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.86.89.64] (HELO elasmtp-curtail.atl.sa.earthlink.net) (209.86.89.64) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Sep 2011 15:42:27 +0000 Received: from [66.32.160.21] (helo=[192.168.2.50]) by elasmtp-curtail.atl.sa.earthlink.net with esmtpa (Exim 4.67) (envelope-from ) id 1R6lPZ-00064r-GN for users@tomcat.apache.org; Thu, 22 Sep 2011 11:42:05 -0400 Subject: [tomcat-6.0.33] META-INF/context.xml Environment not working From: Tim Watts To: users@tomcat.apache.org Content-Type: multipart/alternative; boundary="=-ecD7METbO7R9RoTpQiC6" Organization: Clifton Farm Date: Thu, 22 Sep 2011 11:42:37 -0400 Message-ID: <1316706157.23172.108.camel@dellberry> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 X-ELNK-Trace: 3a5701426d89357f74bf435c0eb9d478af833228fb35755ac398ca6ecc6b4968f4256edce5e38f1c350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 66.32.160.21 X-Virus-Checked: Checked by ClamAV on apache.org --=-ecD7METbO7R9RoTpQiC6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Hello, My very basic servlet fails to initialize when trying to read its JNDI environment entry. The app context name is xbasic. The context.xml is in xbasic.war's META-INF directory and TomCat (6.0.33) correctly copies it to ${tomcat.home}/conf/Catalina/localhost/xbasic.xml on first deploy. Below are the relevant snippets. Can anyone see what I'm doing wrong or is this a bug? BTW, I'm running this under openjdk 6. === EXCEPTION ================================================ javax.servlet.ServletException: Error instantiating servlet class org.cliftonfarm.xbasic.Controller org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) java.lang.Thread.run(Thread.java:636) root cause javax.naming.NameNotFoundException: Name configName is not bound in this Context org.apache.naming.NamingContext.lookup(NamingContext.java:770) org.apache.naming.NamingContext.lookup(NamingContext.java:140) org.apache.naming.NamingContext.lookup(NamingContext.java:781) org.apache.naming.NamingContext.lookup(NamingContext.java:140) org.apache.naming.NamingContext.lookup(NamingContext.java:781) org.apache.naming.NamingContext.lookup(NamingContext.java:153) org.apache.naming.SelectorContext.lookup(SelectorContext.java:152) javax.naming.InitialContext.lookup(InitialContext.java:409) javax.naming.InitialContext.doLookup(InitialContext.java:282) org.cliftonfarm.xbasic.Controller.(Controller.java:28) sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ... === context.xml ================================================ === web.xml ================================================ Archetype Created Web Application Controller org.cliftonfarm.xbasic.Controller Controller /* configName java.lang.String === Servlet constructor ======================================== public class Controller extends HttpServlet { private static final long serialVersionUID = 1L; private String configName; /** * @throws NamingException * @see HttpServlet#HttpServlet() */ public Controller() throws NamingException { super(); // get & store JNDI info configName = InitialContext.doLookup("java:comp/env/configName"); // line 28 log(getClass().getName() +": Successfully initialized. configName=[" +configName +"]"); } ... --=-ecD7METbO7R9RoTpQiC6--