Hi Doug,

it works on my Linux (Kernel 2.4.19), JVM 1.3.1 and Tomcat 5.0.19 (with 
context.xml in META-INF/) and Tomcat 4.1.29 with the ResourceLink in the 
Context in the server.xml.

But it doesn'nt work, when I start the Tomcat with this CATALINA_OPTS:
-Djava.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory 
-Djava.naming.provider.url=file:/jdbcpool/ifxpool

We need this file-based DataSource for DB-Connections to an Informix Dynamic 
Server 9.30.

from the StackTrace:
-----------------------------
javax.naming.NamingException: Cannot create resource instance
        at 
org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:146)
...
---------------------------

What are the necessary JNDI-Properties getting a DataSource from Tomcat?

Holger



> Several questions:
>
> What version of Tomcat is this?
> What platform/OS are you on?
> Which JDK version?
>
> Typically this error is from a mis-configuration for the jndi.
>
> Here are my configuration files or parts of for my development box.
>
> First in the server.xml set up a GlobalResource such as this:
>
>   <GlobalNamingResources>
>     <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
>     <Resource name="jdbc/GolfDB" type="javax.sql.DataSource"/>
>     <ResourceParams name="jdbc/GolfDB">
>       <parameter>
>         <name>validationQuery</name>
>         <value>select 1</value>
>       </parameter>
>       <parameter>
>         <name>url</name>
>         <value>jdbc:mysql://localhost:3306/golf?autoReconnect=true</value>
>       </parameter>
>       <parameter>
>         <name>username</name>
>         <value>******</value>
>       </parameter>
>       <parameter>
>         <name>password</name>
>         <value>******</value>
>       </parameter>
>       <parameter>
>         <name>maxActive</name>
>         <value>30</value>
>       </parameter>
>       <parameter>
>         <name>maxWait</name>
>         <value>5000</value>
>       </parameter>
>       <parameter>
>         <name>driverClassName</name>
>         <value>com.mysql.jdbc.Driver</value>
>       </parameter>
>       <parameter>
>         <name>maxIdle</name>
>         <value>2</value>
>       </parameter>
>     </ResourceParams>
>   </GlobalNamingResources>
>
> Of course replace the necesary data with your specifics.
>
> Next place this, at the bottom, in your web.xml for the app:
>
>   <resource-ref>
>       <description>GolfDB Connection</description>
>       <res-ref-name>jdbc/GolfDB</res-ref-name>
>       <res-type>javax.sql.DataSource</res-type>
>       <res-auth>Container</res-auth>
>   </resource-ref>
>
> For TC5: Now create a file in the META-INF directory. Name the file
> context.xml.
> In this file you will need to define the context and the link to the jdbc.
> For TC4: Add this to the server.xml
>
> <Context className="org.apache.catalina.core.StandardContext"
> cachingAllowed="true"
> charsetMapperClass="org.apache.catalina.util.CharsetMapper" cookies="true"
> crossContext="true" debug="0" displayName="golf" docBase="golf"
> mapperClass="org.apache.catalina.core.StandardContextMapper" path="/golf"
> privileged="false" reloadable="false" swallowOutput="false"
> useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper">
> <ResourceLink name="jdbc/GolfDB" global="jdbc/GolfDB"
> type="javax.sql.DataSource"/>
> </Context>
>
> My application is deployed with the manager from a war file named golf.war
> The resource name is jdbc/GolfDB and I am running against a MySQL database.
> Make sure all the names match exactly as this will cause many bumps from
> banging you head. Adjust other setting to match your needs.
>
> I am on TAO linux, Tomcat 5.0.19 /4.1.29 And JVM 1.4.2_04-b05.
>
> Doug
> www.parsonstechnical.com
>
>
> ----- Original Message -----
> From: "Paul Richards" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, April 13, 2004 3:03 PM
> Subject: Tomcat and DataSource JNDI
>
> > Hi,
> > I am running Tomcat from the Java Webservices Developer Pack 1.3 and I
> > cannot get JNDI working for mysql DataSource objects.  I have googled
> > around for my error which is:
> >
> > java.sql.SQLException: Cannot load JDBC driver class 'null'
> > at
>
> org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.ja
>v a:529)
>
> > at
>
> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:
>3 29)
>
> > What I found on google was that this error is not just a problem with
>
> Mysql and that people have experienced it with Oracle and Postgresql also:
>
> http://archives.real-time.com/pipermail/tomcat-users/2002-October/081368.ht
>ml
>
> > I tried the suggestion in this last URL of using the exact orderings of
> > parameters in the server.xml file as shown in the Tomcat JNDI DataSource
> > HowTo.  Unfortunately this has not helped my case.
> >
> >
> > I appreciate that a very similar thread to this is currently running but
> > that problem looks different to mine.
> >
> >
> > I have failover code which created a Mysql datasource manually if the
> > JNDI fails and the failover code works perfectly.  This makes me sure
> > that my CLASSPATHs are correct.
> >
> >
> >


-- 
Holger de Wall
LKV-SH, Steenbeker Weg 151, Kiel 24106
Tel.   : +049 431-33987-38
Fax   : +049 431-33987-20


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to