You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kyle Bahr <kb...@rogue-engr.com> on 2009/06/25 00:30:27 UTC

Tomcat 5.5, getting exception while creating database driver instance

Hello all,

I'm running Tomcat 5.5 on a linux (CentOS) box and attempting to 
implement a  set of web services (.jws).  I'm getting an exception 
thrown when trying to instantiate a mysql database driver using the line 
of code:
Class.forName("com.mysql.jdbc.Driver").newInstance();

I am using the mysql connector mysql-connector-java-3.1.8-bin-g.jar and 
it is in the CATALINA_HOME/common/lib directory with full permissions.

I've done untold amounts of google searches and putting the jar in the 
right place solved 90%+ of peoples' problems, but those that still had 
the issue didn't get replies (this was on various message boards).

Has anyone else encountered this and what was the solution?  If any 
other information is necessary please let me know.  I don't know what 
all is pertinent and I didn't want to just fill this question with junk 
to be sifted through.

Thanks,
--Kyle


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


Re: Tomcat 5.5, getting exception while creating database driver instance

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kyle,

On 6/24/2009 7:23 PM, Kyle Bahr wrote:
> The exact exception is java.lang.reflect.InvocationTargetException, but
> sadly I don't have a stack trace available.

Hmm... that's going to make it pretty hard to debug. Any error message
along with the InvocationTargetException itself?

This kind of thing usually happens because of some tiny misconfiguration
of a JNDI DataSource, but it looks like you are probably registering the
driver yourself. Can you give us a bit larger code sample?

If you are able to modify the code, you could just put a try/catch block
around the Class.forName(...).newInstance() line and print any
InvocationTargetExceptions thrown to stdout:

try { Class.forName(...).newInstance(); }
catch (InvocationTargetException ite) { ite.printStackTrace();
       throw ite; }

WTF JAR file placement, make sure that your Connector/J JAR file is in
common/lib and /nowhere else/: check your webapp. Check shared/lib.
Check server/lib. Check for multiple versions of the same driver (like
mysql-connector-3.1.4.jar AND mysql-connector-3.1.5.jar).

Also, Connector/J 3.x is super old. Any chance of upgrading? They're on
5.1 these days...

> I'm getting that except
> back as the web service faultstring and the stack trace isn't being
> logged to the catalina.log.  I've tried changing the log4j.properties to
> capture the error, but still nothing is getting logged.

If the error is happening on the server, then you'll have a hard time
getting a client to give you the full stack trace: you'll have to check
the server's logs.

> I don't know where to find the exact level of Tomcat.

Try this (output shown from my environment):

$ /usr/local/tomcat/bin/catalina.sh version
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:       /home/chris/.gentoo/java-config-2/current-user-vm
Server version: Apache Tomcat/5.5.26
Server built:   Jan 28 2008 01:35:23
Server number:  5.5.26.0
OS Name:        Linux
OS Version:     2.6.14-gentoo-r5
Architecture:   i386
JVM Version:    1.6.0_13-b03
JVM Vendor:     Sun Microsystems Inc.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkpNdEsACgkQ9CaO5/Lv0PAX6gCdG+E4GFjNzCWQoSj3jFYug3fq
cTIAni6ViZg0E1koaPgI5XHjHckVDpyY
=fmX4
-----END PGP SIGNATURE-----

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


Re: Tomcat 5.5, getting exception while creating database driver instance

Posted by Kyle Bahr <kb...@rogue-engr.com>.
Thanks for getting back to me so quickly:

The exact exception is java.lang.reflect.InvocationTargetException, but 
sadly I don't have a stack trace available.  I'm getting that except 
back as the web service faultstring and the stack trace isn't being 
logged to the catalina.log.  I've tried changing the log4j.properties to 
capture the error, but still nothing is getting logged.

I don't know where to find the exact level of Tomcat.

I'm using java 1.6.0.

Caldarale, Charles R wrote:
>> From: Kyle Bahr [mailto:kbahr@rogue-engr.com]
>> Subject: Tomcat 5.5, getting exception while creating database driver
>> instance
>>
>> I'm getting an exception thrown when trying to instantiate a
>> mysql database driver using the line of code:
>>     
>
> Would you mind telling us the exception (and providing a stack trace), or is that a security risk?
>
> What exact Tomcat level are you using?
>
> What JVM version are you using?
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> 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: Tomcat 5.5, getting exception while creating database driver instance

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Kyle Bahr [mailto:kbahr@rogue-engr.com]
> Subject: Tomcat 5.5, getting exception while creating database driver
> instance
> 
> I'm getting an exception thrown when trying to instantiate a
> mysql database driver using the line of code:

Would you mind telling us the exception (and providing a stack trace), or is that a security risk?

What exact Tomcat level are you using?

What JVM version are you using?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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