Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 82290 invoked from network); 8 Jun 2005 20:58:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Jun 2005 20:58:22 -0000 Received: (qmail 6465 invoked by uid 500); 8 Jun 2005 20:57:59 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 6443 invoked by uid 500); 8 Jun 2005 20:57:59 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: 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 6405 invoked by uid 99); 8 Jun 2005 20:57:58 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from pne-smtpout2-sn1.fre.skanova.net (HELO pne-smtpout2-sn1.fre.skanova.net) (81.228.11.159) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 08 Jun 2005 13:57:57 -0700 Received: from homer.luniks.net (217.208.82.159) by pne-smtpout2-sn1.fre.skanova.net (7.2.059.6) id 42930AA900386C17 for tomcat-user@jakarta.apache.org; Wed, 8 Jun 2005 22:57:40 +0200 Received: from [192.168.0.1] (homer.luniks.net [192.168.0.1]) by homer.luniks.net (Postfix) with ESMTP id 5E02740CB2 for ; Wed, 8 Jun 2005 22:57:40 +0200 (CEST) Message-ID: <42A75BC3.1090506@luniks.net> Date: Wed, 08 Jun 2005 22:57:39 +0200 From: =?ISO-8859-1?Q?Torsten_R=F6mer?= User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Tomcat 5.5.9: NamingException cannot be resolved or is not a type - JNDI, MySQL References: <20050608194720.CC4E070000C3@mwinf1412.wanadoo.fr> <42A74C24.8080401@technologist.com> In-Reply-To: <42A74C24.8080401@technologist.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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:gwb@technologist.com] 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: >>> >> 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"> >>> >>> testdb >>> >>> db test site >>> >>> >>> >>> Tomcat DBCP >>> jdbc/testdb >>> javax.sql.DataSource >>> Container >>> >>> >>> >>> conf/Catalina/localhost/testdb.xml: >>> >>> >> path="/Search" docBase="Search" >>> debug="1" crossContext="true" >>> reloadable="true"> >>> >> global="jdbc/testdb"/> >>> >>> conf/server.xml: >>> >>> >> name="simpleValue" >>> type="java.lang.Integer" >>> value="30"/> >>> >> 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"/> >>> >> name="jdbc/testdb" >>> auth="Container" >>> type="javax.sql.DataSource" >>> factory="org.apache.commons.dbcp.BasicDataSourceFactory" >>> username="xxxx" >>> password="yyyy" >>> removeAbandonedTimeout="60" >>> maxActive="4" >>> maxIdle="2" >>> removeAbandoned="true" >>> driverClassName="com.mysql.jdbc.Driver" >>> url="jdbc:mysql://localhost:3306/testdb?autoReconnect=true"/> >>> >>> >>> 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: tomcat-user-unsubscribe@jakarta.apache.org >>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org >>> >>> >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org >> >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org