Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 2326 invoked from network); 23 Feb 2004 10:13:26 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 23 Feb 2004 10:13:26 -0000 Received: (qmail 63636 invoked by uid 500); 23 Feb 2004 10:12:40 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 63624 invoked by uid 500); 23 Feb 2004 10:12:40 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 63611 invoked from network); 23 Feb 2004 10:12:39 -0000 Received: from unknown (HELO twin.jikos.cz) (213.151.79.26) by daedalus.apache.org with SMTP; 23 Feb 2004 10:12:39 -0000 Received: from localhost (ondra@localhost) by twin.jikos.cz (8.11.6/8.11.6) with ESMTP id i1NACqX08677 for ; Mon, 23 Feb 2004 11:12:52 +0100 Date: Mon, 23 Feb 2004 11:12:51 +0100 (CET) From: Ondra Nekola To: Tomcat Users List Subject: Tomcat JNDI - mapping a String In-Reply-To: <4039CA00.2000902@apache.org> Message-ID: References: <3F2A0190.2060208@apache.org> <3F4B2B1D.6090102@apache.org> <3F6EF3ED.5010305@apache.org> <3FA27DD2.5060805@apache.org> <3FCE6283.4010801@apache.org> <400FE777.8080708@apache.org> <4039CA00.2000902@apache.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I have developed a small web-based aplication. I use an ant build script to compile it and to generate a war. The application is used in several servers with different settings (it uses different databases, connects to different xml-rpc resources...) so it has to somehow read the configuration from the server environment. I have used the tomcat Web server administration tool to set Resources - a data source and several Environment Entries. The tool regenerates server.xml file in such a manner: ... ... ... Then I change my deployment descriptor get access to this environment: ... BLAh_USER java.lang.String ... The code, that tryes to read this environmnt looks like this: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); String res_user = (String) envCtx.lookup("BLAH_USER"); The problem is, that I get this exception: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:146) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) at org.apache.naming.NamingContext.lookup(NamingContext.java:837) at org.apache.naming.NamingContext.lookup(NamingContext.java:197) at myapp.servlets.MyAppListener.contextInitialized(MyAppListener.java:123) When I try to access a mapped JDBC resource everything seems to be OK. When I list (NamingEnumeration enum = initCtx.list("java:comp/env");) the keys for mapped resources BLAH_USER appears. I have tried look this situation in the Tomcat documentation and to google it, but I haven't get any reasonable idea to solve it. -- S pozdravem Ondrej Nekola ondra@matfyz.cz http://www.matfyz.cz/ondra ICQ# 160692888 --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org