NamingException
Hello. I am getting a NamingException while Tomcat processes Global JNDI Resources. Any idea why this is happening? I am using Mac OS X Tiger, Eclipse 3.1, and the Tomcat Eclipse Plugin 3.1.0 from Sysdeo. This error occurs when I try to start Tomcat from within Eclipse using the plugin. It occurs with both Tomcat 4.x and Tomcat 5.x. I have provided the stack trace below. Any help would be greatly appreciated. Thanks. - Asad Aug 8, 2005 2:51:42 AM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 GlobalResourcesLifecycleListener: Exception processing Global JNDI Resources javax.naming.NamingException: /Library/jakarta-apache-4.1.31/conf/tomcat-users.xml.new (No such file or directory) at org.apache.naming.NamingContext.lookup(NamingContext.java:797) at org.apache.naming.NamingContext.lookup(NamingContext.java:147) at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:167) at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:134) at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:102) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2136) at org.apache.catalina.startup.Catalina.start(Catalina.java:463) at org.apache.catalina.startup.Catalina.execute(Catalina.java:350) at org.apache.catalina.startup.Catalina.process(Catalina.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156) Starting service Tomcat-Standalone Apache Tomcat/4.1.31 javax.naming.NamingException: /Library/jakarta-apache-4.1.31/conf/tomcat-users.xml.new (No such file or directory) at org.apache.naming.NamingContext.lookup(NamingContext.java:797) at org.apache.naming.NamingContext.lookup(NamingContext.java:147) at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:250) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:316) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2143) at org.apache.catalina.startup.Catalina.start(Catalina.java:463) at org.apache.catalina.startup.Catalina.execute(Catalina.java:350) at org.apache.catalina.startup.Catalina.process(Catalina.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156) Catalina.start: LifecycleException: No UserDatabase component found under key UserDatabase LifecycleException: No UserDatabase component found under key UserDatabase at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:257) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:316) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2143) at org.apache.catalina.startup.Catalina.start(Catalina.java:463) at org.apache.catalina.startup.Catalina.execute(Catalina.java:350) at org.apache.catalina.startup.Catalina.process(Catalina.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156) Stopping service Tomcat-Standalone Catalina.stop: LifecycleException: Coyote connector has not been started LifecycleException: Coyote connector has not been started at org.apache.coyote.tomcat4.CoyoteConnector.stop(CoyoteConnector.java:1296) at org.apache.catalina.core.StandardService.stop(StandardService.java:499
Re: NamingException
read the error message. It is complaining GlobalResourcesLifecycleListener: Exception processing Global JNDI Resources javax.naming.NamingException: /Library/jakarta-apache-4.1.31/conf/tomcat-users.xml.new check whether the file /Library/jakarta-apache-4.1.31/conf/tomcat-users.xml exist. On 8/8/05, Asad Habib [EMAIL PROTECTED] wrote: Hello. I am getting a NamingException while Tomcat processes Global JNDI Resources. Any idea why this is happening? I am using Mac OS X Tiger, Eclipse 3.1, and the Tomcat Eclipse Plugin 3.1.0 from Sysdeo. This error occurs when I try to start Tomcat from within Eclipse using the plugin. It occurs with both Tomcat 4.x and Tomcat 5.x. I have provided the stack trace below. Any help would be greatly appreciated. Thanks. - Asad Aug 8, 2005 2:51:42 AM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 GlobalResourcesLifecycleListener: Exception processing Global JNDI Resources javax.naming.NamingException: /Library/jakarta-apache-4.1.31/conf/tomcat-users.xml.new (No such file or directory) at org.apache.naming.NamingContext.lookup(NamingContext.java:797) at org.apache.naming.NamingContext.lookup(NamingContext.java:147) at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:167) at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:134) at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:102) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2136) at org.apache.catalina.startup.Catalina.start(Catalina.java:463) at org.apache.catalina.startup.Catalina.execute(Catalina.java:350) at org.apache.catalina.startup.Catalina.process(Catalina.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156) Starting service Tomcat-Standalone Apache Tomcat/4.1.31 javax.naming.NamingException: /Library/jakarta-apache-4.1.31/conf/tomcat-users.xml.new (No such file or directory) at org.apache.naming.NamingContext.lookup(NamingContext.java:797) at org.apache.naming.NamingContext.lookup(NamingContext.java:147) at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:250) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:316) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2143) at org.apache.catalina.startup.Catalina.start(Catalina.java:463) at org.apache.catalina.startup.Catalina.execute(Catalina.java:350) at org.apache.catalina.startup.Catalina.process(Catalina.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156) Catalina.start: LifecycleException: No UserDatabase component found under key UserDatabase LifecycleException: No UserDatabase component found under key UserDatabase at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:257) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:316) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2143) at org.apache.catalina.startup.Catalina.start(Catalina.java:463) at org.apache.catalina.startup.Catalina.execute(Catalina.java:350) at org.apache.catalina.startup.Catalina.process(Catalina.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324
Re: Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL
Have a look at the tomcat documentation: DBCP uses the Jakarta-Commons Database Connection Pool. It relies on number of Jakarta-Commons components: * Jakarta-Commons DBCP * Jakarta-Commons Collections * Jakarta-Commons Pool These libraries are located in a single JAR at $CATALINA_HOME/common/lib/naming-factory-dbcp.jar. However, only the classes needed for connection pooling have been included, and the packages have been renamed to avoid interfering with applications. --- Ursprüngliche Nachricht --- Von: Greg Brownell [EMAIL PROTECTED] An: Tomcat Users List tomcat-user@jakarta.apache.org Betreff: Re: Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL Datum: Wed, 08 Jun 2005 17:44:55 -0400 Great! Thanks Torsten. Added javax.naming Now new problem: NamingException: javax.naming.NamingException: Could not create resource factory, ClassNotFoundException:org.apache.commons.dbcp.BasicDataSourceFactory This exposed several other pitfalls. Tomcat distribution did not come with the apache commons jars: collections, dbcp, pool. Installed them in common/lib and all is well. Thanks tons. Greg. regards, Dirk -- Geschenkt: 3 Monate GMX ProMail gratis + 3 Ausgaben stern gratis ++ Jetzt anmelden testen ++ http://www.gmx.net/de/go/promail ++ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL
I get the error below when trying to compile/execute a jsp that wants to connect to a MySQL db named testdb. Here's the code snippet from testdb.jsp: InitialContext initCtx = null; DataSource ds = null; Connection conn = null; Statement stmt = null; ResultSet rset = null; try { initCtx = new InitialContext(); ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/testdb); conn = ds.getConnection(); stmt = conn.createStatement(); rset = stmt.executeQuery(select * from subscriber); It fails on the lookup with: org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 52 in the jsp file: /testdb.jsp Generated servlet error: NamingException cannot be resolved or is not a type org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397) org.apache.jasper.compiler.Compiler.compile(Compiler.java:288) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) I am using MySQL 4.1.12a (Windows nt), Connector/J v 3.1.8 Connector/j stuff moved to common/lib Tomcat: under webapps, app name testdb. testdb/WEB-INF/web.xml: ?xml version=1.0 encoding=ISO-8859-1? web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 display-nametestdb/display-name description db test site /description resource-ref descriptionTomcat DBCP/description res-ref-namejdbc/testdb/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app conf/Catalina/localhost/testdb.xml: ?xml version=1.0 encoding=UTF-8? Context path=/Search docBase=Search debug=1crossContext=true reloadable=true ResourceLink name=jdbc/testdb type=javax.sql.DataSource global=jdbc/testdb/ /Context conf/server.xml: GlobalNamingResources Environment name=simpleValue type=java.lang.Integer value=30/ Resource auth=Container description=User database that can be updated and saved name=UserDatabase type=org.apache.catalina.UserDatabase pathname=conf/tomcat-users.xml factory=org.apache.catalina.users.MemoryUserDatabaseFactory/ Resource name=jdbc/testdb auth=Container type=javax.sql.DataSource factory=org.apache.commons.dbcp.BasicDataSourceFactory username= password= removeAbandonedTimeout=60 maxActive=4 maxIdle=2 removeAbandoned=true driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/testdb?autoReconnect=true/ /GlobalNamingResources Any ideas why this doesn't work? By the way, I've tried moving the Resource lines in server.xml to testdb.xml (the context file) and replaced the resource-link. Same error. Thanks in advance. Greg. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL
You must import the classes you use in your JSP : %@ page import={package.class | package.*}, ... ... Arnaud -Message d'origine- De : Greg Brownell [mailto:[EMAIL PROTECTED] Envoyé : mercredi 8 juin 2005 21:34 À : tomcat-user@jakarta.apache.org Objet : Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL I get the error below when trying to compile/execute a jsp that wants to connect to a MySQL db named testdb. Here's the code snippet from testdb.jsp: InitialContext initCtx = null; DataSource ds = null; Connection conn = null; Statement stmt = null; ResultSet rset = null; try { initCtx = new InitialContext(); ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/testdb); conn = ds.getConnection(); stmt = conn.createStatement(); rset = stmt.executeQuery(select * from subscriber); It fails on the lookup with: org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 52 in the jsp file: /testdb.jsp Generated servlet error: NamingException cannot be resolved or is not a type org.apache.jasper.compiler.DefaultErrorHandler.javacError(Defa ultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDis patcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompil er.java:397) org.apache.jasper.compiler.Compiler.compile(Compiler.java:288) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilation Context.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServlet Wrapper.java:293) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet .java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) I am using MySQL 4.1.12a (Windows nt), Connector/J v 3.1.8 Connector/j stuff moved to common/lib Tomcat: under webapps, app name testdb. testdb/WEB-INF/web.xml: ?xml version=1.0 encoding=ISO-8859-1? web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 display-nametestdb/display-name description db test site /description resource-ref descriptionTomcat DBCP/description res-ref-namejdbc/testdb/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app conf/Catalina/localhost/testdb.xml: ?xml version=1.0 encoding=UTF-8? Context path=/Search docBase=Search debug=1crossContext=true reloadable=true ResourceLink name=jdbc/testdb type=javax.sql.DataSource global=jdbc/testdb/ /Context conf/server.xml: GlobalNamingResources Environment name=simpleValue type=java.lang.Integer value=30/ Resource auth=Container description=User database that can be updated and saved name=UserDatabase type=org.apache.catalina.UserDatabase pathname=conf/tomcat-users.xml factory=org.apache.catalina.users.MemoryUserDatabaseFactory/ Resource name=jdbc/testdb auth=Container type=javax.sql.DataSource factory=org.apache.commons.dbcp.BasicDataSourceFactory username= password= removeAbandonedTimeout=60 maxActive=4 maxIdle=2 removeAbandoned=true driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/testdb?autoReconnect=true/ /GlobalNamingResources Any ideas why this doesn't work? By the way, I've tried moving the Resource lines in server.xml to testdb.xml (the context file) and replaced the resource-link. Same error. Thanks in advance. Greg. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL
I have. Here is what I have at top of jsp: %@ page import=java.sql.* % %@ page import=javax.sql.DataSource % %@ page import=javax.naming.InitialContext % %@ page import=javax.naming.Context % %@ page import=java.io.File % Greg. Arnaud HERITIER wrote: You must import the classes you use in your JSP : %@ page import={package.class | package.*}, ... ... Arnaud -Message d'origine- De : Greg Brownell [mailto:[EMAIL PROTECTED] Envoyé : mercredi 8 juin 2005 21:34 À : tomcat-user@jakarta.apache.org Objet : Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL I get the error below when trying to compile/execute a jsp that wants to connect to a MySQL db named testdb. Here's the code snippet from testdb.jsp: InitialContext initCtx = null; DataSource ds = null; Connection conn = null; Statement stmt = null; ResultSet rset = null; try { initCtx = new InitialContext(); ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/testdb); conn = ds.getConnection(); stmt = conn.createStatement(); rset = stmt.executeQuery(select * from subscriber); It fails on the lookup with: org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 52 in the jsp file: /testdb.jsp Generated servlet error: NamingException cannot be resolved or is not a type org.apache.jasper.compiler.DefaultErrorHandler.javacError(Defa ultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDis patcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompil er.java:397) org.apache.jasper.compiler.Compiler.compile(Compiler.java:288) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilation Context.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServlet Wrapper.java:293) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet .java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) I am using MySQL 4.1.12a (Windows nt), Connector/J v 3.1.8 Connector/j stuff moved to common/lib Tomcat: under webapps, app name testdb. testdb/WEB-INF/web.xml: ?xml version=1.0 encoding=ISO-8859-1? web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 display-nametestdb/display-name description db test site /description resource-ref descriptionTomcat DBCP/description res-ref-namejdbc/testdb/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app conf/Catalina/localhost/testdb.xml: ?xml version=1.0 encoding=UTF-8? Context path=/Search docBase=Search debug=1crossContext=true reloadable=true ResourceLink name=jdbc/testdb type=javax.sql.DataSource global=jdbc/testdb/ /Context conf/server.xml: GlobalNamingResources Environment name=simpleValue type=java.lang.Integer value=30/ Resource auth=Container description=User database that can be updated and saved name=UserDatabase type=org.apache.catalina.UserDatabase pathname=conf/tomcat-users.xml factory=org.apache.catalina.users.MemoryUserDatabaseFactory/ Resource name=jdbc/testdb auth=Container type=javax.sql.DataSource factory=org.apache.commons.dbcp.BasicDataSourceFactory username= password= removeAbandonedTimeout=60 maxActive=4 maxIdle=2 removeAbandoned=true driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/testdb?autoReconnect=true/ /GlobalNamingResources Any ideas why this doesn't work? By the way, I've tried moving the Resource lines in server.xml to testdb.xml (the context file) and replaced the resource-link. Same error. Thanks in advance. Greg. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL
Greg Brownell schrieb: I have. Here is what I have at top of jsp: %@ page import=java.sql.* % %@ page import=javax.sql.DataSource % %@ page import=javax.naming.InitialContext % %@ page import=javax.naming.Context % %@ page import=java.io.File % You are missing javax.naming.NamingException (or do javax.naming.*) Torsten Greg. Arnaud HERITIER wrote: You must import the classes you use in your JSP : %@ page import={package.class | package.*}, ... ... Arnaud -Message d'origine- De : Greg Brownell [mailto:[EMAIL PROTECTED] Envoyé : mercredi 8 juin 2005 21:34 À : tomcat-user@jakarta.apache.org Objet : Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL I get the error below when trying to compile/execute a jsp that wants to connect to a MySQL db named testdb. Here's the code snippet from testdb.jsp: InitialContext initCtx = null; DataSource ds = null; Connection conn = null; Statement stmt = null; ResultSet rset = null; try { initCtx = new InitialContext(); ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/testdb); conn = ds.getConnection(); stmt = conn.createStatement(); rset = stmt.executeQuery(select * from subscriber); It fails on the lookup with: org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 52 in the jsp file: /testdb.jsp Generated servlet error: NamingException cannot be resolved or is not a type org.apache.jasper.compiler.DefaultErrorHandler.javacError(Defa ultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDis patcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompil er.java:397) org.apache.jasper.compiler.Compiler.compile(Compiler.java:288) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilation Context.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServlet Wrapper.java:293) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet .java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) I am using MySQL 4.1.12a (Windows nt), Connector/J v 3.1.8 Connector/j stuff moved to common/lib Tomcat: under webapps, app name testdb. testdb/WEB-INF/web.xml: ?xml version=1.0 encoding=ISO-8859-1? web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 display-nametestdb/display-name description db test site /description resource-ref descriptionTomcat DBCP/description res-ref-namejdbc/testdb/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app conf/Catalina/localhost/testdb.xml: ?xml version=1.0 encoding=UTF-8? Context path=/Search docBase=Search debug=1crossContext=true reloadable=true ResourceLink name=jdbc/testdb type=javax.sql.DataSource global=jdbc/testdb/ /Context conf/server.xml: GlobalNamingResources Environment name=simpleValue type=java.lang.Integer value=30/ Resource auth=Container description=User database that can be updated and saved name=UserDatabase type=org.apache.catalina.UserDatabase pathname=conf/tomcat-users.xml factory=org.apache.catalina.users.MemoryUserDatabaseFactory/ Resource name=jdbc/testdb auth=Container type=javax.sql.DataSource factory=org.apache.commons.dbcp.BasicDataSourceFactory username= password= removeAbandonedTimeout=60 maxActive=4 maxIdle=2 removeAbandoned=true driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/testdb?autoReconnect=true/ /GlobalNamingResources Any ideas why this doesn't work? By the way, I've tried moving the Resource lines in server.xml to testdb.xml (the context file) and replaced the resource-link. Same error. Thanks in advance. Greg. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL
Great! Thanks Torsten. Added javax.naming Now new problem: NamingException: javax.naming.NamingException: Could not create resource factory, ClassNotFoundException:org.apache.commons.dbcp.BasicDataSourceFactory This exposed several other pitfalls. Tomcat distribution did not come with the apache commons jars: collections, dbcp, pool. Installed them in common/lib and all is well. Thanks tons. Greg. Torsten Römer wrote: Greg Brownell schrieb: I have. Here is what I have at top of jsp: %@ page import=java.sql.* % %@ page import=javax.sql.DataSource % %@ page import=javax.naming.InitialContext % %@ page import=javax.naming.Context % %@ page import=java.io.File % You are missing javax.naming.NamingException (or do javax.naming.*) Torsten Greg. Arnaud HERITIER wrote: You must import the classes you use in your JSP : %@ page import={package.class | package.*}, ... ... Arnaud -Message d'origine- De : Greg Brownell [mailto:[EMAIL PROTECTED] Envoyé : mercredi 8 juin 2005 21:34 À : tomcat-user@jakarta.apache.org Objet : Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL I get the error below when trying to compile/execute a jsp that wants to connect to a MySQL db named testdb. Here's the code snippet from testdb.jsp: InitialContext initCtx = null; DataSource ds = null; Connection conn = null; Statement stmt = null; ResultSet rset = null; try { initCtx = new InitialContext(); ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/testdb); conn = ds.getConnection(); stmt = conn.createStatement(); rset = stmt.executeQuery(select * from subscriber); It fails on the lookup with: org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 52 in the jsp file: /testdb.jsp Generated servlet error: NamingException cannot be resolved or is not a type org.apache.jasper.compiler.DefaultErrorHandler.javacError(Defa ultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDis patcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompil er.java:397) org.apache.jasper.compiler.Compiler.compile(Compiler.java:288) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilation Context.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServlet Wrapper.java:293) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet .java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) I am using MySQL 4.1.12a (Windows nt), Connector/J v 3.1.8 Connector/j stuff moved to common/lib Tomcat: under webapps, app name testdb. testdb/WEB-INF/web.xml: ?xml version=1.0 encoding=ISO-8859-1? web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 display-nametestdb/display-name description db test site /description resource-ref descriptionTomcat DBCP/description res-ref-namejdbc/testdb/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app conf/Catalina/localhost/testdb.xml: ?xml version=1.0 encoding=UTF-8? Context path=/Search docBase=Search debug=1crossContext=true reloadable=true ResourceLink name=jdbc/testdb type=javax.sql.DataSource global=jdbc/testdb/ /Context conf/server.xml: GlobalNamingResources Environment name=simpleValue type=java.lang.Integer value=30/ Resource auth=Container description=User database that can be updated and saved name=UserDatabase type=org.apache.catalina.UserDatabase pathname=conf/tomcat-users.xml factory=org.apache.catalina.users.MemoryUserDatabaseFactory/ Resource name=jdbc/testdb auth=Container type=javax.sql.DataSource factory=org.apache.commons.dbcp.BasicDataSourceFactory username= password= removeAbandonedTimeout=60 maxActive=4 maxIdle=2 removeAbandoned=true driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/testdb?autoReconnect=true/ /GlobalNamingResources Any ideas why this doesn't work? By the way, I've tried moving the Resource lines in server.xml to testdb.xml (the context file) and replaced the resource-link. Same error. Thanks in advance. Greg. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
Re: JNDI lookup returns NamingException
Many thanks to Doug and Seven. The core problem on our Windows machines was that we neglected to put a Resource-Link entry in the ROOT.xml in the Documents and Settings\. directory. On the Linux servers (running 5.5), we needed to put a Resource-Link entry in the Context.xml under META-INF. And, to think we worked for several hours on such a simple problem. Thanks again, Carl - Original Message - From: Parsons Technical Services [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, February 15, 2005 11:16 PM Subject: Re: JNDI lookup returns NamingException Did you put ResourceLinks in your Default context or the Apps context? If not, you will not be able to see the resource. http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/globalresources.html And the link that is in your server.xml shouldn't be there or anywhere. See above link. Doug - Original Message - From: Carl [EMAIL PROTECTED] To: Tomcat User Group tomcat-user@jakarta.apache.org Sent: Tuesday, February 15, 2005 4:41 PM Subject: JNDI lookup returns NamingException For various reasons, I need to put a Hashtable as a resource in the Tomcat Context. I have modified the server.xml as follows (note the resource entry of DBHashtable): Server port=8005 shutdown=SHUTDOWN debug=0 Listener className=org.apache.catalina.mbeans.ServerLifecycleListener debug=0/ Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener debug=0/ !-- Global JNDI resources -- GlobalNamingResources !-- Test entry for demonstration purposes -- Environment name=simpleValue type=java.lang.Integer value=30/ !-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -- Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved /Resource Resource name=DBHashtable auth=Container type=java.util.Hashtable/ ResourceParams name=UserDatabase parameter namefactory/name valueorg.apache.catalina.users.MemoryUserDatabaseFactory/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter /ResourceParams ResourceParams name=DBHashtable parameter namefactory/name valuecom.tsr.factory.HashtableFactory/value /parameter /ResourceParams /GlobalNamingResources ResourceLink name=linkToGlobal global=simpleValue type=java.lang.Integer/ !-- Define the Tomcat Stand-Alone Service -- Service name=Catalina !-- Define a non-SSL Coyote HTTP/1.1 Connector on the port specified during installation -- Connector port=8080 maxThreads=150 minSpareThreads=25 maxSpareThreads=75 enableLookups=false redirectPort=8443 acceptCount=100 debug=0 connectionTimeout=2 disableUploadTimeout=true / Connector port=8009 enableLookups=false redirectPort=8443 debug=0 protocol=AJP/1.3 / !-- Define the top level container in our container hierarchy -- Engine name=Catalina defaultHost=localhost debug=0 !-- Global logger unless overridden at lower levels -- Logger className=org.apache.catalina.logger.FileLogger prefix=catalina_log. suffix=.txt timestamp=true/ Realm className=org.apache.catalina.realm.UserDatabaseRealm debug=0 resourceName=UserDatabase/ Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Logger className=org.apache.catalina.logger.FileLogger directory=logs prefix=localhost_log. suffix=.txt timestamp=true/ /Host /Engine /Service /Server My application accesses this resource (well, tries to) using the following code: try { Context ctx = new InitialContext(); if(ctx == null ){ System.out.println(Boom - No Context); throw new NamingException(No Context - No DataBase Exists); } Context envCtx = (Context)ctx.lookup(java:comp/env); Object ud = (Object)envCtx.lookup(DBHashtable); }catch (NamingException ne){ ne.printStackTrace(); // throw new SQLException(Datasource Not Found); } It fails of the line Object ud = (Object)envCtx.lookup(DBHashtable); with the following error: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFa ctory.java:99) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) at org.apache.naming.NamingContext.lookup(NamingContext.java:791) at org.apache.naming.NamingContext.lookup(NamingContext.java:151) at LoginServlet.doPost(LoginServlet.java:37) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
JNDI lookup returns NamingException
For various reasons, I need to put a Hashtable as a resource in the Tomcat Context. I have modified the server.xml as follows (note the resource entry of DBHashtable): Server port=8005 shutdown=SHUTDOWN debug=0 Listener className=org.apache.catalina.mbeans.ServerLifecycleListener debug=0/ Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener debug=0/ !-- Global JNDI resources -- GlobalNamingResources !-- Test entry for demonstration purposes -- Environment name=simpleValue type=java.lang.Integer value=30/ !-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -- Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved /Resource Resource name=DBHashtable auth=Container type=java.util.Hashtable/ ResourceParams name=UserDatabase parameter namefactory/name valueorg.apache.catalina.users.MemoryUserDatabaseFactory/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter /ResourceParams ResourceParams name=DBHashtable parameter namefactory/name valuecom.tsr.factory.HashtableFactory/value /parameter /ResourceParams /GlobalNamingResources ResourceLink name=linkToGlobal global=simpleValue type=java.lang.Integer/ !-- Define the Tomcat Stand-Alone Service -- Service name=Catalina !-- Define a non-SSL Coyote HTTP/1.1 Connector on the port specified during installation -- Connector port=8080 maxThreads=150 minSpareThreads=25 maxSpareThreads=75 enableLookups=false redirectPort=8443 acceptCount=100 debug=0 connectionTimeout=2 disableUploadTimeout=true / Connector port=8009 enableLookups=false redirectPort=8443 debug=0 protocol=AJP/1.3 / !-- Define the top level container in our container hierarchy -- Engine name=Catalina defaultHost=localhost debug=0 !-- Global logger unless overridden at lower levels -- Logger className=org.apache.catalina.logger.FileLogger prefix=catalina_log. suffix=.txt timestamp=true/ Realm className=org.apache.catalina.realm.UserDatabaseRealm debug=0 resourceName=UserDatabase/ Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Logger className=org.apache.catalina.logger.FileLogger directory=logs prefix=localhost_log. suffix=.txt timestamp=true/ /Host /Engine /Service /Server My application accesses this resource (well, tries to) using the following code: try { Context ctx = new InitialContext(); if(ctx == null ){ System.out.println(Boom - No Context); throw new NamingException(No Context - No DataBase Exists); } Context envCtx = (Context)ctx.lookup(java:comp/env); Object ud = (Object)envCtx.lookup(DBHashtable); }catch (NamingException ne){ ne.printStackTrace(); // throw new SQLException(Datasource Not Found); } It fails of the line Object ud = (Object)envCtx.lookup(DBHashtable); with the following error: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFa ctory.java:99) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) at org.apache.naming.NamingContext.lookup(NamingContext.java:791) at org.apache.naming.NamingContext.lookup(NamingContext.java:151) at LoginServlet.doPost(LoginServlet.java:37) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:157) at com.tsr.filters.RequestFilter.doFilter(RequestFilter.java:78) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext Valve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137 ) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117 ) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520
Re: JNDI lookup returns NamingException
Hi, See if having a pair of the sequence of Resource ResourceParams instead of having Resource, Resource ResourceParams, ResourceParams. Also the ResourceLink seems to be misplaced, not that it will much difference for your set-up. aka_sergio --- Carl [EMAIL PROTECTED] wrote: For various reasons, I need to put a Hashtable as a resource in the Tomcat Context. I have modified the server.xml as follows (note the resource entry of DBHashtable): Server port=8005 shutdown=SHUTDOWN debug=0 Listener className=org.apache.catalina.mbeans.ServerLifecycleListener debug=0/ Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener debug=0/ !-- Global JNDI resources -- GlobalNamingResources !-- Test entry for demonstration purposes -- Environment name=simpleValue type=java.lang.Integer value=30/ !-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -- Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved /Resource Resource name=DBHashtable auth=Container type=java.util.Hashtable/ ResourceParams name=UserDatabase parameter namefactory/name valueorg.apache.catalina.users.MemoryUserDatabaseFactory/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter /ResourceParams ResourceParams name=DBHashtable parameter namefactory/name valuecom.tsr.factory.HashtableFactory/value /parameter /ResourceParams /GlobalNamingResources ResourceLink name=linkToGlobal global=simpleValue type=java.lang.Integer/ !-- Define the Tomcat Stand-Alone Service -- Service name=Catalina !-- Define a non-SSL Coyote HTTP/1.1 Connector on the port specified during installation -- Connector port=8080 maxThreads=150 minSpareThreads=25 maxSpareThreads=75 enableLookups=false redirectPort=8443 acceptCount=100 debug=0 connectionTimeout=2 disableUploadTimeout=true / Connector port=8009 enableLookups=false redirectPort=8443 debug=0 protocol=AJP/1.3 / !-- Define the top level container in our container hierarchy -- Engine name=Catalina defaultHost=localhost debug=0 !-- Global logger unless overridden at lower levels -- Logger className=org.apache.catalina.logger.FileLogger prefix=catalina_log. suffix=.txt timestamp=true/ Realm className=org.apache.catalina.realm.UserDatabaseRealm debug=0 resourceName=UserDatabase/ Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Logger className=org.apache.catalina.logger.FileLogger directory=logs prefix=localhost_log. suffix=.txt timestamp=true/ /Host /Engine /Service /Server My application accesses this resource (well, tries to) using the following code: try { Context ctx = new InitialContext(); if(ctx == null ){ System.out.println(Boom - No Context); throw new NamingException(No Context - No DataBase Exists); } Context envCtx = (Context)ctx.lookup(java:comp/env); Object ud = (Object)envCtx.lookup(DBHashtable); }catch (NamingException ne){ ne.printStackTrace(); // throw new SQLException(Datasource Not Found); } It fails of the line Object ud = (Object)envCtx.lookup(DBHashtable); with the following error: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFa ctory.java:99) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) at org.apache.naming.NamingContext.lookup(NamingContext.java:791) at org.apache.naming.NamingContext.lookup(NamingContext.java:151) at LoginServlet.doPost(LoginServlet.java:37) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:157) at com.tsr.filters.RequestFilter.doFilter(RequestFilter.java:78) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext Valve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520
Re: JNDI lookup returns NamingException
Did you put ResourceLinks in your Default context or the Apps context? If not, you will not be able to see the resource. http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/globalresources.html And the link that is in your server.xml shouldn't be there or anywhere. See above link. Doug - Original Message - From: Carl [EMAIL PROTECTED] To: Tomcat User Group tomcat-user@jakarta.apache.org Sent: Tuesday, February 15, 2005 4:41 PM Subject: JNDI lookup returns NamingException For various reasons, I need to put a Hashtable as a resource in the Tomcat Context. I have modified the server.xml as follows (note the resource entry of DBHashtable): Server port=8005 shutdown=SHUTDOWN debug=0 Listener className=org.apache.catalina.mbeans.ServerLifecycleListener debug=0/ Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener debug=0/ !-- Global JNDI resources -- GlobalNamingResources !-- Test entry for demonstration purposes -- Environment name=simpleValue type=java.lang.Integer value=30/ !-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -- Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved /Resource Resource name=DBHashtable auth=Container type=java.util.Hashtable/ ResourceParams name=UserDatabase parameter namefactory/name valueorg.apache.catalina.users.MemoryUserDatabaseFactory/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter /ResourceParams ResourceParams name=DBHashtable parameter namefactory/name valuecom.tsr.factory.HashtableFactory/value /parameter /ResourceParams /GlobalNamingResources ResourceLink name=linkToGlobal global=simpleValue type=java.lang.Integer/ !-- Define the Tomcat Stand-Alone Service -- Service name=Catalina !-- Define a non-SSL Coyote HTTP/1.1 Connector on the port specified during installation -- Connector port=8080 maxThreads=150 minSpareThreads=25 maxSpareThreads=75 enableLookups=false redirectPort=8443 acceptCount=100 debug=0 connectionTimeout=2 disableUploadTimeout=true / Connector port=8009 enableLookups=false redirectPort=8443 debug=0 protocol=AJP/1.3 / !-- Define the top level container in our container hierarchy -- Engine name=Catalina defaultHost=localhost debug=0 !-- Global logger unless overridden at lower levels -- Logger className=org.apache.catalina.logger.FileLogger prefix=catalina_log. suffix=.txt timestamp=true/ Realm className=org.apache.catalina.realm.UserDatabaseRealm debug=0 resourceName=UserDatabase/ Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Logger className=org.apache.catalina.logger.FileLogger directory=logs prefix=localhost_log. suffix=.txt timestamp=true/ /Host /Engine /Service /Server My application accesses this resource (well, tries to) using the following code: try { Context ctx = new InitialContext(); if(ctx == null ){ System.out.println(Boom - No Context); throw new NamingException(No Context - No DataBase Exists); } Context envCtx = (Context)ctx.lookup(java:comp/env); Object ud = (Object)envCtx.lookup(DBHashtable); }catch (NamingException ne){ ne.printStackTrace(); // throw new SQLException(Datasource Not Found); } It fails of the line Object ud = (Object)envCtx.lookup(DBHashtable); with the following error: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFa ctory.java:99) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) at org.apache.naming.NamingContext.lookup(NamingContext.java:791) at org.apache.naming.NamingContext.lookup(NamingContext.java:151) at LoginServlet.doPost(LoginServlet.java:37) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:157) at com.tsr.filters.RequestFilter.doFilter(RequestFilter.java:78) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext Valve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:104) at org.apache.catalina.core.StandardPipeline.invoke
jspInit() throwing NamingException when extracting a factory object from JNDI context
BUG ID: http://issues.apache.org/bugzilla/show_bug.cgi?id=33307 Problem: jspInit() throwing NamingException when extracting a factory object from JNDI context. Description: When the container has been configured to load the JSP page during startup by including the Load-On-Startup tag in web.xml, the NamingException has been reported( can be viewed in the attachment). The Tomcat Version which we are using is Tomcat 4.1.3. How to Reproduce the problem: - Step 1) create a directory under webapps (say test) and unzip the attached jsppax.zip into the test dir under webapps. Step 2) add the following lines to server.xml Context path=/test docBase=d:\jakarta-tomcat-4.1.30\webapps\test debug=0/ !-- DefaultContext -- DefaultContext reloadable=true crossContext=true useNaming=true !-- bean/MyBeanFactory -- Resource name=bean/MyBeanFactory auth=Container type=com.mycompany.MyBean/ ResourceParams name=bean/MyBeanFactory parameter namefactory/name valueorg.apache.naming.factory.BeanFactory/value /parameter parameter namebar/name value23/value /parameter /ResourceParams /DefaultContext !-- /DefaultContext -- Step 3) start the server During startup, the NamingException has been reported. We tried with couple of other Tomcat versions aswell it is poping that NamingException with them also. Please letus know if you had any issues while reproducing the above exception. You can refer to the bugid :33307 if you need more information. Please let us Know if it is a configuration issue or a bug in JSP-TomCat. Awaiting yor response.. Thanks in Advance Yogi Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: jspInit() throwing NamingException when extracting a factory object from JNDI context
Appreciate if any one has some inputsWe couldn't decide whether it is a bug or usage issue,... Details @ http://issues.apache.org/bugzilla/show_bug.cgi?id=33307 Problem: jspInit() throwing NamingException when extracting a factory object from JNDI context. Description: When the container has been configured to load the JSP page during startup by including the Load-On-Startup tag in web.xml, the NamingException has been reported( can be viewed in the attachment). The Tomcat Version which we are using is Tomcat 4.1.3. How to Reproduce the problem: - Step 1) create a directory under webapps (say test) and unzip the attached jsppax.zip into the test dir under webapps. Step 2) add the following lines to server.xml Context path=/test docBase=d:\jakarta-tomcat-4.1.30\webapps\test debug=0/ !-- DefaultContext -- DefaultContext reloadable=true crossContext=true useNaming=true !-- bean/MyBeanFactory -- Resource name=bean/MyBeanFactory auth=Container type=com.mycompany.MyBean/ ResourceParams name=bean/MyBeanFactory parameter namefactory/name valueorg.apache.naming.factory.BeanFactory/value /parameter parameter namebar/name value23/value /parameter /ResourceParams /DefaultContext !-- /DefaultContext -- Step 3) start the server During startup, the NamingException has been reported. We tried with couple of other Tomcat versions aswell it is poping that NamingException with them also. Please letus know if you had any issues while reproducing the above exception. You can refer to the bugid :33307 if you need more information. Please let us Know if it is a configuration issue or a bug in JSP-TomCat. Awaiting yor response.. Thanks in Advance Yogi Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
jspInit() throwing NamingException when extracting a factory object from JNDI context
I feel, we tried many combinations to see if it is a configurations issue, but of now use. It seems to be a bug in Tomcat it is present in all the versions we tried out. We are declaring it as a bug, let us know if any one has any other suggestions/soln to try out. Thanks in advance, Yogi -Original Message- From: Yogi [mailto:[EMAIL PROTECTED] Sent: Thursday, February 03, 2005 7:47 PM To: 'Tomcat Users List' Subject: RE: jspInit() throwing NamingException when extracting a factory object from JNDI context Appreciate if any one has some inputsWe couldn't decide whether it is a bug or usage issue,... Details @ http://issues.apache.org/bugzilla/show_bug.cgi?id=33307 Problem: jspInit() throwing NamingException when extracting a factory object from JNDI context. Description: When the container has been configured to load the JSP page during startup by including the Load-On-Startup tag in web.xml, the NamingException has been reported( can be viewed in the attachment). The Tomcat Version which we are using is Tomcat 4.1.3. How to Reproduce the problem: - Step 1) create a directory under webapps (say test) and unzip the attached jsppax.zip into the test dir under webapps. Step 2) add the following lines to server.xml Context path=/test docBase=d:\jakarta-tomcat-4.1.30\webapps\test debug=0/ !-- DefaultContext -- DefaultContext reloadable=true crossContext=true useNaming=true !-- bean/MyBeanFactory -- Resource name=bean/MyBeanFactory auth=Container type=com.mycompany.MyBean/ ResourceParams name=bean/MyBeanFactory parameter namefactory/name valueorg.apache.naming.factory.BeanFactory/value /parameter parameter namebar/name value23/value /parameter /ResourceParams /DefaultContext !-- /DefaultContext -- Step 3) start the server During startup, the NamingException has been reported. We tried with couple of other Tomcat versions aswell it is poping that NamingException with them also. Please letus know if you had any issues while reproducing the above exception. You can refer to the bugid :33307 if you need more information. Please let us Know if it is a configuration issue or a bug in JSP-TomCat. Awaiting yor response.. Thanks in Advance Yogi Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
NamingException in tomcat 4.1.18 LE
hi, I just joined this list but have used tomcat a while now. I used jakarta-tomcat-4.1.10 until now and changed my server to jakarta-tomcat-4.1.18-LE-jdk14 and got it running almost OK. in server.xml I have a Context element like this: Context path= docBase=/var/www/htdocs debug=1 reloadable=true Resource name=jdbc/KalleDB auth=Container type=javax.sql.DataSource description=Kalle database/ ResourceParams name=jdbc/KalleDB parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost/test?user=test/value /parameter /ResourceParams /Context With tomcat-1.1.10 it works OK and in Java code I can use Context initCtx = new InitialContext(); DataSource ds = (DataSource)initCtx.lookup(java:comp/env/jdbc/KalleDB); Connection conn = ds.getConnection(); to get the connection. I can use the code also if I get connection from DriverManager Connection conn = DriverManager.getConnection(jdbc:mysql://localhost/test?user=test); With 4.1.18-LE I get the exception below if I use the initCts.lookup What is missing in my 4.1.18 or has something changed here? regards Kaarle -- javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:189) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) at org.apache.naming.NamingContext.lookup(NamingContext.java:834) at org.apache.naming.NamingContext.lookup(NamingContext.java:181) at org.apache.naming.NamingContext.lookup(NamingContext.java:822) at org.apache.naming.NamingContext.lookup(NamingContext.java:181) at org.apache.naming.NamingContext.lookup(NamingContext.java:822) at org.apache.naming.NamingContext.lookup(NamingContext.java:181) at org.apache.naming.NamingContext.lookup(NamingContext.java:822) at org.apache.naming.NamingContext.lookup(NamingContext.java:194) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183) at javax.naming.InitialContext.lookup(InitialContext.java:347) at fi.iki.kaila.util.SoccerUtil.makeConnection(Unknown Source) - Kaarle Kaila http://www.iki.fi/kaila mailto:[EMAIL PROTECTED] tel: +358 50 3725844 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
NamingException using DataSource from JNDI
Hi, I created a DataSource resource in server.xml file and a reference in the web.xml. But i receive a null reference and a Exception javax.naming.NamingException when i want to get the DataSource instance from the context. Someone know what is happening? in server.xml file: Context path=/appSample docBase=C:\Desenv\AppSample reloadable=true checkInterval=2 Resource name=jdbc/DBSample type=javax.sql.DataSource/ ResourceParams name=jdbc/DBSample parameternamemaxWait/namevalue5000/value/parameter parameternamemaxActive/namevalue4/value/parameter parameternamepassword/namevaluepass/value/parameter parameternameurl/namevaluejdbc:jdbcprogress:T:localhost:35001:testdb /value/parameter parameternamedriverClassName/namevaluecom.progress.sql.jdbc.JdbcProg ressDriver/value/parameter parameternamemaxIdle/namevalue2/value/parameter parameternameusername/namevaluesuper/value/parameter /ResourceParams /Context in web.xml file: web-app ( ... ) resource-ref descriptionSQLExplorer DataSource/description res-ref-namejdbc/DBSample/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app My code: try { Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); DataSource ds = (DataSource) envCtx.lookup(jdbc/DBSample); Returns a NamingException } catch( Here is some piece of Stack javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory. java:189) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) at org.apache.naming.NamingContext.lookup(NamingContext.java:834) at org.apache.naming.NamingContext.lookup(NamingContext.java:181) at org.apache.naming.NamingContext.lookup(NamingContext.java:822) at org.apache.naming.NamingContext.lookup(NamingContext.java:194) (...) I´m using Tomcat 4.1.18 and J2sdk 1.4.1 Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat SendMail Example : NamingException: Cannot create resource
Phil: Thanks for responding. I got it working. In short, the simplest advice I can give anyone struggling with this is to simply use tomcat_4.0.4 instead of 4.0.3 Found that out after a process of painful elimination; by changing IBM to Sun and so on.. Everything worked magically after that.. I guess JNDI support must be better.. :) Thanks.. --- Phil Steitz [EMAIL PROTECTED] wrote: Glow Nair wrote: -- NamingException : Cannot create resource instance -- While trying to run the SendMail example that came bundled with Tomcat4, I get the error NamingException : Cannot create resource instance I've read and re-read the Tomcat How-To's. And went through the JNDI tutorials as well.. (at leat tried to.. till the installation of the LDAP server :) ) Am I missing something in CLASSPATH? or is my Tomcat installation corrupted in some way ? Can someone help me with this or give me a hint or URL? Thanks.. I've attached details below. ANY HELP WOULD BE GREATLY APPRECIATED. Glow [EMAIL PROTECTED] - 1. I use IBM's JDK IBMJava2-SDK-1.3-13.0.i386.rpm 2. I downloaded mail.jar and copied it to /var/tomcat4/common/lib. Did you also copy activation.jar to common/lib? 3. I could successfully compile SendMailServelet using /opt/IBMJava2-13/bin/javac -verbose -classpath .:/var/tomcat4/common/lib/mail.jar: /var/tomcat4/common/lib/servlet.jar SendMailServlet.java 4. I fixed the typo in sendmail.jsp ie changed form ... action=../../SendMailServlet TO form ... action=../../servlet/SendMailServlet 5. I have qmail running on localhost. I verified that to be working by sending mail using a standalone example that does NOT use Tomcat's JNDI implementation.. it worked fine by using simple classses. 6. I installed tomcat using the following RPMs rpm -ivh regexp-1.2-1.noarch.rpm rpm -ivh servletapi4-4.0.3-1.noarch.rpm rpm -ivh xerces-j-1.4.4-2.noarch.rpm rpm -ivh tomcat4-4.0.3-1.noarch.rpm rpm -ivh tomcat4-webapps-4.0.3-1.noarch.rpm 7. I connected tomcat to Apache using rpm -ivh mod_webapp-1.0-1.i386.rpm __ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]