You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Stephen More <st...@gmail.com> on 2006/05/17 23:34:31 UTC

Help with Tomcat & MySQL using JNDI

Is there a war file available for download that will do nothing more than:
    select 'HelloWorld from MySQL'; using JNDI ?


I have tried following many examples on the web and I keep ending up with:
    Cannot create JDBC driver of class '' for connect URL 'null'

At this point I am pulling out my hair and thinking their must be a
bug in tomcat 5.5.17 !

Can anyone provide me with a simple working war using MySQL ?


-Thanks
Steve More

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Help with Tomcat & MySQL using JNDI

Posted by Hugh Morgan <hu...@gmail.com>.
Stephen More wrote:
> Is there a war file available for download that will do nothing more than:
>    select 'HelloWorld from MySQL'; using JNDI ?
> 
> 
> I have tried following many examples on the web and I keep ending up with:
>    Cannot create JDBC driver of class '' for connect URL 'null'
> 
> At this point I am pulling out my hair and thinking their must be a
> bug in tomcat 5.5.17 !
> 
> Can anyone provide me with a simple working war using MySQL ?

I had exactly this error.  I do not know if it is of use to you, but my 
war is at http://www.geocities.com/hughmorgan72/minimal.zip.  It 
requires a database called smsserver, with a table called unit, with a 
column called name.

I would strongly recomend the one at 
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html, 
  MySQL DBCP Example.

The problems I had;

Make sure the Resource tag in server.xml is corect.
Make sure the Resource tags name parameter in server.xml not matching 
the res-ref-name tag in the applications WEB-INF/web.xml file.

HTH,

Hugh

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Help with Tomcat & MySQL using JNDI

Posted by Martin Gainty <mg...@hotmail.com>.
Well ..sort of 

The recommended way of creating a web application is to create a webapp .war and deploy it to %TOMCAT_HOME%\webapps
once you accomplish this objective Tomcat will 
note the new war and create folder %TOMCAT_HOME\webapps\NameOfWebApplicationWar
wait a minute ..how does Tomcat handle 'temp' and or 'work' files ???
Tomcat has a 'work' folder located at
%TOMCAT_HOME%\work\Catalina\ServerWhereDeployed\WebAppName
this is where the REAL work is being done by tomcat..you will notice that after copying a new class or a new jar or a new war your new class is not taking hold?
that is because the work folder %TOMCAT_HOME%\work\Catalina\ServerWhereDeployed\WebAppName has not been updated
doing a specific undeploy and then deploy will fix this (as well as re-reading your web.xml)
of course there is shutting down Tomcat and starting Tomcat should re-reploy the webapps

HTH,
Martin --
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



----- Original Message ----- 
From: "Stephen More" <st...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, May 30, 2006 9:57 AM
Subject: Re: Help with Tomcat & MySQL using JNDI


>I think I have identified the problem.
> 
> I deployed a 'broken' HelloWorld war file to tomcat by coping it to
> apache-tomcat-5.5.17/webapps. Tomcat then expanded it, so there is now
> both a war file and a expanded directory structure.
> 
> In all of my attempts to fix the code, I was modifying the code within
> the expanded structure and nothing seemed to work. Once I delete the
> war file, everything now worked.
> 
> Why does tomcat work like this ? I would have expected one of the following:
>   - Expand the war then delete the war
>   - Do not expand the war
> 
> Can someone shed some light on where I might have gone wrong ?
> 
> -Thanks
> Steve More
> 
> On 5/19/06, Stephen More <st...@gmail.com> wrote:
>> On 5/17/06, Parsons Technical Services <pa...@earthlink.net> wrote:
>> > Now I will assume you have reviewed
>> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
>> > for a per context and
>>
>> Yes
>>
>> > http://tomcat.apache.org/tomcat-5.5-doc/config/globalresources.html for a
>> > global approach.
>>
>> Yes.
>>
>> > Now for a few questions.
>> > Is the jndi for one app or several?
>>
>> Right now, one app.
>>
>> > Well if for one app, you can set it up in the context of the app.
>>
>> I have been trying to do this.
>>
>> > Both cases you need to add the drivers to the common/lib (thus the reason a
>> > simple war won't do).
>>
>> I have copied mysql-connector-java-3.1.12-bin.jar to
>> apache-tomcat-5.5.17/common/lib
>>
>> > Class.forName("com.mysql.jdbc.Driver");
>> >
>> >     connection =
>> >      DriverManager.getConnection(
>> >       "jdbc:mysql://192.168.1.19:3306/golive",
>> >       "daname",
>> >       "depassword");
>> >
>>
>> I have this working fine.
>>
>> Now that we have verified this first layer ( JDBC Driver installed OK
>> ), how can I test the next layer ?
>>
>> $CATALINA_HOME/webapps/DBTest/META-INF/context.xml
>>
>> What can I do to verify that my context.xml is set correctly ?
>>
>>
>>
>> -Thanks
>> Steve More
>>
>> > ----- Original Message -----
>> > From: "Stephen More" <st...@gmail.com>
>> > To: <us...@tomcat.apache.org>
>> > Sent: Wednesday, May 17, 2006 5:34 PM
>> > Subject: Help with Tomcat & MySQL using JNDI
>> >
>> >
>> > Is there a war file available for download that will do nothing more than:
>> >     select 'HelloWorld from MySQL'; using JNDI ?
>> >
>> >
>> > I have tried following many examples on the web and I keep ending up with:
>> >     Cannot create JDBC driver of class '' for connect URL 'null'
>> >
>> > At this point I am pulling out my hair and thinking their must be a
>> > bug in tomcat 5.5.17 !
>> >
>> > Can anyone provide me with a simple working war using MySQL ?
>> >
>> >
>> > -Thanks
>> > Steve More
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> > For additional commands, e-mail: users-help@tomcat.apache.org
>> >
>> >
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> > For additional commands, e-mail: users-help@tomcat.apache.org
>> >
>> >
>>
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: Help with Tomcat & MySQL using JNDI

Posted by Stephen More <st...@gmail.com>.
I think I have identified the problem.

I deployed a 'broken' HelloWorld war file to tomcat by coping it to
apache-tomcat-5.5.17/webapps. Tomcat then expanded it, so there is now
both a war file and a expanded directory structure.

In all of my attempts to fix the code, I was modifying the code within
the expanded structure and nothing seemed to work. Once I delete the
war file, everything now worked.

Why does tomcat work like this ? I would have expected one of the following:
   - Expand the war then delete the war
   - Do not expand the war

Can someone shed some light on where I might have gone wrong ?

-Thanks
Steve More

On 5/19/06, Stephen More <st...@gmail.com> wrote:
> On 5/17/06, Parsons Technical Services <pa...@earthlink.net> wrote:
> > Now I will assume you have reviewed
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> > for a per context and
>
> Yes
>
> > http://tomcat.apache.org/tomcat-5.5-doc/config/globalresources.html for a
> > global approach.
>
> Yes.
>
> > Now for a few questions.
> > Is the jndi for one app or several?
>
> Right now, one app.
>
> > Well if for one app, you can set it up in the context of the app.
>
> I have been trying to do this.
>
> > Both cases you need to add the drivers to the common/lib (thus the reason a
> > simple war won't do).
>
> I have copied mysql-connector-java-3.1.12-bin.jar to
> apache-tomcat-5.5.17/common/lib
>
> > Class.forName("com.mysql.jdbc.Driver");
> >
> >     connection =
> >      DriverManager.getConnection(
> >       "jdbc:mysql://192.168.1.19:3306/golive",
> >       "daname",
> >       "depassword");
> >
>
> I have this working fine.
>
> Now that we have verified this first layer ( JDBC Driver installed OK
> ), how can I test the next layer ?
>
> $CATALINA_HOME/webapps/DBTest/META-INF/context.xml
>
> What can I do to verify that my context.xml is set correctly ?
>
>
>
> -Thanks
> Steve More
>
> > ----- Original Message -----
> > From: "Stephen More" <st...@gmail.com>
> > To: <us...@tomcat.apache.org>
> > Sent: Wednesday, May 17, 2006 5:34 PM
> > Subject: Help with Tomcat & MySQL using JNDI
> >
> >
> > Is there a war file available for download that will do nothing more than:
> >     select 'HelloWorld from MySQL'; using JNDI ?
> >
> >
> > I have tried following many examples on the web and I keep ending up with:
> >     Cannot create JDBC driver of class '' for connect URL 'null'
> >
> > At this point I am pulling out my hair and thinking their must be a
> > bug in tomcat 5.5.17 !
> >
> > Can anyone provide me with a simple working war using MySQL ?
> >
> >
> > -Thanks
> > Steve More
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Help with Tomcat & MySQL using JNDI

Posted by Stephen More <st...@gmail.com>.
On 5/17/06, Parsons Technical Services <pa...@earthlink.net> wrote:
> Now I will assume you have reviewed
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> for a per context and

Yes

> http://tomcat.apache.org/tomcat-5.5-doc/config/globalresources.html for a
> global approach.

Yes.

> Now for a few questions.
> Is the jndi for one app or several?

Right now, one app.

> Well if for one app, you can set it up in the context of the app.

I have been trying to do this.

> Both cases you need to add the drivers to the common/lib (thus the reason a
> simple war won't do).

I have copied mysql-connector-java-3.1.12-bin.jar to
apache-tomcat-5.5.17/common/lib

> Class.forName("com.mysql.jdbc.Driver");
>
>     connection =
>      DriverManager.getConnection(
>       "jdbc:mysql://192.168.1.19:3306/golive",
>       "daname",
>       "depassword");
>

I have this working fine.

Now that we have verified this first layer ( JDBC Driver installed OK
), how can I test the next layer ?

$CATALINA_HOME/webapps/DBTest/META-INF/context.xml

What can I do to verify that my context.xml is set correctly ?



-Thanks
Steve More

> ----- Original Message -----
> From: "Stephen More" <st...@gmail.com>
> To: <us...@tomcat.apache.org>
> Sent: Wednesday, May 17, 2006 5:34 PM
> Subject: Help with Tomcat & MySQL using JNDI
>
>
> Is there a war file available for download that will do nothing more than:
>     select 'HelloWorld from MySQL'; using JNDI ?
>
>
> I have tried following many examples on the web and I keep ending up with:
>     Cannot create JDBC driver of class '' for connect URL 'null'
>
> At this point I am pulling out my hair and thinking their must be a
> bug in tomcat 5.5.17 !
>
> Can anyone provide me with a simple working war using MySQL ?
>
>
> -Thanks
> Steve More
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Help with Tomcat & MySQL using JNDI

Posted by Parsons Technical Services <pa...@earthlink.net>.
There is no such critter. I wish it was that simple but due to the needed 
elements that lie outside the war you need to roll up your sleeves and dig 
in.

First I need to let you know I may not be able to respond in a timely 
manner. Busy schedule.

Now I will assume you have reviewed 
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html 
for a per context and

http://tomcat.apache.org/tomcat-5.5-doc/config/globalresources.html for a 
global approach.

Now for a few questions.

Is the jndi for one app or several?

Well if for one app, you can set it up in the context of the app. If for 
several you need it to be global.

Difference is that for global you move the parts to the server.xml and add a 
pointer to the context called a resource link.

Both cases you need to add the drivers to the common/lib (thus the reason a 
simple war won't do).

One common mistake is spelling errors and case issues. Make sure the names 
match exactly. You will also need to restart Tomcat to make it work. One 
suggestion I have is as a test to use the default connection method of:


Class.forName("com.mysql.jdbc.Driver");

    connection =
     DriverManager.getConnection(
      "jdbc:mysql://192.168.1.19:3306/golive",
      "daname",
      "depassword");

This will test the database and the drivers. If this fails you need to 
resolve these issue first then move on.

If you search the archives you will find several discussions on this topic 
and I am involved in many of them.

Doug

----- Original Message ----- 
From: "Stephen More" <st...@gmail.com>
To: <us...@tomcat.apache.org>
Sent: Wednesday, May 17, 2006 5:34 PM
Subject: Help with Tomcat & MySQL using JNDI


Is there a war file available for download that will do nothing more than:
    select 'HelloWorld from MySQL'; using JNDI ?


I have tried following many examples on the web and I keep ending up with:
    Cannot create JDBC driver of class '' for connect URL 'null'

At this point I am pulling out my hair and thinking their must be a
bug in tomcat 5.5.17 !

Can anyone provide me with a simple working war using MySQL ?


-Thanks
Steve More

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org