I've set this up I don't know how many times and only ever had problems when I've mispelled the JNDI name I gave it somewhere in the 4 places it was specified. Others have had issue with the order of parameters in the ResourceParams block. To be on the safe side, follow the order of parameters given in the jndi-datasource-howto.html page you were following. That's the same page I followed when I did this for the first time.

I take it you've:

1) defined a <Resource/> and <ResouceParams/> block in your {context}.xml file that's stored in the {TOMCAT_HOME}/conf/Catalina/localhost folder. Both <Resource/> and <ResourceParams>...</ResourceParams> sections have the same JNDI name in their name attributes. I'd recommend all lower case since case is important in java.

2) Placed a <resource-ref>...</resource-ref> in your WEB-INF/web.xml file with the <res-ref-name>...</res-ref-name> tag specifying the same JNDI name specified in the {context}.xml file above. I keep harping on the same JNDI name because this is where I've been messed up before.

3) Did a lookup for java:comp/env/{your JNDI name here} in your java code.

4) Restarted the tomcat service after putting the mysql jar file in common/lib so the tomcat classloaders can see it.

Can you post what you do have in {context}.xml and web.xml and just omit the username and password for the database or put in bogus ones for the purposes of posting to the list? An excerpt of your java code where you attempt to access the db would be good as well.

--David

Briggs, Patrick wrote:

Ok, I have it in the common/lib directory, but that didn't make a
difference.  You'd think there would be a lot easier way to setup stuff like
this.  Editing XML files is pretty tricky business.

-----Original Message-----
From: David Smith [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 30, 2004 12:19 PM
To: Tomcat Users List
Subject: Re: Tomcat -> MySQL = No suitable driver ERROR


Wrong place for mysql jar file. It should be in {TOMCAT_HOME}/common/lib right along side the DBCP jar file.


--David

Briggs, Patrick wrote:



If the webapps.xml file is supposed to be located in Catalina\localhost,


the


apache's own website documentation JDBC-HOWTO needs to be updated to


reflect


that new situation.  I'm surprised they haven't updated it because I'm sure
a lot of other people are going to be having the same problems I am.

I have made all of the changes you have suggest.  the mysql.jar file has
been deleted everywhere except for {CATALINA_HOME}/shared/lib where I have
now placed it.

I have created a file called DBTest.xml over in
/conf/Catalina/localhost/DBTest.xml

I used your template for the XML find changing it where it needs changes


for


URL and username/password.

Still getting the same error message :(
So now what could it be?

-----Original Message-----
From: Jan Behrens [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 30, 2004 1:58 AM
To: 'Tomcat Users List'
Subject: RE: Tomcat -> MySQL = No suitable driver ERROR


Hi Patrick,

the problem might be that in Tomcat 5.x the storage of the context related
configuration changed from server.xml to a sepparate file for each webapp.
This file should be stored under
{Catalina_Home}\conf\Catalina\{domain-name}\myWebAppName.xml where
Catalina_Home points to your Tomcat installation dir and domain_name


usually


would be localhost in a dev-environment.

If you have a webapp called myWebApp and want to setup a datastore via jndi
for same to use in Tomcat 5 you could use the following as a basis for a
myWebApp.xml file stored under
{Catalina_Home}\conf\Catalina\{domain-name}\myWebAppName.xml:


<?xml version='1.0' encoding='utf-8'?> <Context debug="5" displayName="myWebApp" docBase="myWebApp " path="/myWebApp" reloadable="true" workDir="work\Catalina\localhost\myWebApp">

<Resource auth="Container" name="jdbc/myWebApp"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/myWebApp">
  <parameter>
    <name>url</name>

<value>jdbc:mysql://NAME_OR_IP_OF_MYSQL_SERVER:3306/NAME_OF_DATABASE?autoRe


c


onnect=true</value>
  </parameter>
  <parameter>
    <name>maxIdle</name>
    <value>15</value>
  </parameter>
  <parameter>
    <name>maxActive</name>
    <value>50</value>
  </parameter>
  <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
  </parameter>
  <parameter>
    <name>maxWait</name>
    <value>10000</value>
  </parameter>
  <parameter>
    <name>removeAbandoned</name>
    <value>true</value>
  </parameter>
  <parameter>
    <name>username</name>
    <value>USERNAME</value>
  </parameter>
  <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
  </parameter>
  <parameter>
    <name>removeAbandonedTimeout</name>
    <value>60</value>
  </parameter>
  <parameter>
    <name>password</name>
    <value>PASSWORD</value>
  </parameter>
</ResourceParams>
</Context>

The MySQL driver does have to go under {Catalina_Home}\shared\lib! Delete
any other copies you might have placed in your WEB-INF\lib or anywhere


else.


You should also remove the <context>....</context> you inserted in
server.xml as this should all go in the myWebApp.xml file.


If you ever deploy your webapp you then only have to copy your myWebApp.xml
to the Manifest dir in your webapp root dir before creating the war-file


and


Tomcat will automatically create the correct context for your webapp.

HTH, Jan


This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential or privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy the message.






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

This e-mail message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential or privileged
information.  Any unauthorized review, use, disclosure or distribution is
prohibited.  If you are not the intended recipient, please contact the
sender by reply e-mail and destroy the message.




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



Reply via email to