1 message in com.mysql.lists.javaJNDI naming exceptions with Tomcat 4....
FromSent OnAttachments
Michael Amster08 Jun 2002 16:39 
Subject:JNDI naming exceptions with Tomcat 4.0.3 on RH 7.x
From:Michael Amster (mams@webeasy.com)
Date:06/08/2002 04:39:36 PM
List:com.mysql.lists.java

Hey:

I am getting a JNDI NamingException (Cannot create resource) when trying to lookup a DataSource in Tomcat 4.0.3 and use MySQL with the mm.mysql-2.0.14-bin.jar driver. I have checked to see that the servlet can load the driver using a Class.forName("org.gjt.mm.mysql.Driver") line and it does load the class. There must be something in the way I setup the resources, but I have doublechecked everything and I cannot find the problem.

Here are my relevant configs:

server.xml: <Context path="/dsi" docBase="dsi" debug="0" reloadable="true" crossContext="true"> <!-- JNDI Named JDBC DataSource --> <Resource name="jdbc/abestjob4u" auth="CONTAINER" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/abestjob4u">

<parameter><name>user</name><value>abestjob4u</value></parameter>

<parameter><name>password</name><value>foobar</value></parameter> <parameter><name>driverClassName</name> <value>org.gjt.mm.mysql.Driver</value></parameter> <parameter><name>driverName</name> <value>jdbc:mysql://localhost:3306/abestjob4u</value> </parameter> </ResourceParams> </Context>

web.xml:

<resource-ref> <description> This reference is used for JDBCRealm maintenance </description> <res-ref-name> jdbc/abestjob4u </res-ref-name> <res-type> javax.sql.DataSource </res-type> <res-auth> Container </res-auth> </resource-ref>

code: try { Context initCtx = (Context)(new InitialContext().lookup("java:comp/env")); String dbName = (String)ibillProperties.get(DB_NAME); dbURL = "jdbc/" + dbName; DataSource dbRes = (DataSource)initCtx.lookup(dbURL); con= dbRes.getConnection(); } catch (NamingException ne) { ne.printStackTrace(System.out); res.sendError(500, "Could not find database (" + dbURL + ") " + ne.getMessage()); return; } catch (SQLException se) { res.sendError(500, "Could not open database"); return; }

Any help is appreciated...