Classpath problem with Tomcat

I

Ike

Ive got a major problem with Tomcat unable to find directories or a major
FUBAR on CLASSPATH. For example, since my servlet, which needs to access a
particular jar file (a MySQL Driver), and cannot find it in WEB-INF/lib, I
have unpacked it and put the corresponding class files into the proper
directories under WEB-INF/classes. Yes, I still get tyhe following
exception:

java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at ConnectionPool.makeNewConnection(ConnectionPool.java:133)

The code to do this is simply:

private Connection makeNewConnection()
throws SQLException {
try {
// Load database driver if not already loaded
Class.forName("org.gjt.mm.mysql.Driver");

How can this NOT be found ? It SHOULD be looking for it in
WEB-INF/classes/org/gjt/mm/mysql/Driver.class
and that file IS there with all the appropriate read permissions.
 
T

Tony Morris

Ike said:
Ive got a major problem with Tomcat unable to find directories or a major
FUBAR on CLASSPATH. For example, since my servlet, which needs to access a
particular jar file (a MySQL Driver), and cannot find it in WEB-INF/lib, I
have unpacked it and put the corresponding class files into the proper
directories under WEB-INF/classes. Yes, I still get tyhe following
exception:

java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at ConnectionPool.makeNewConnection(ConnectionPool.java:133)

The code to do this is simply:

private Connection makeNewConnection()
throws SQLException {
try {
// Load database driver if not already loaded
Class.forName("org.gjt.mm.mysql.Driver");

How can this NOT be found ? It SHOULD be looking for it in
WEB-INF/classes/org/gjt/mm/mysql/Driver.class
and that file IS there with all the appropriate read permissions.

You're not being completely honest - that code sample will not produce
that stack trace. Try being honest, then I'll return the favour - your
problem is simple.
 
I

Ike

Tony Morris said:
You're not being completely honest - that code sample will not produce
that stack trace. Try being honest, then I'll return the favour - your
problem is simple.

Tony -- I don;t understant -- what am I missing here? -Ike
 
O

Owen Jacobson

Tony -- I don;t understant -- what am I missing here? -Ike

Passing a string literal to Class.forName (String) will never, ever
generate a NullPointerException in a valid runtime environment.

So either there's a variable you've replaced with a literal in the example
without actually checking it (very likely), or your runtime is hosed (very
unlikely).
 
I

Ike

message
Passing a string literal to Class.forName (String) will never, ever
generate a NullPointerException in a valid runtime environment.

So either there's a variable you've replaced with a literal in the example
without actually checking it (very likely), or your runtime is hosed (very
unlikely).

Ah, yes - exactly, I DID replace the string variable with the literal there.
The variable gets it's value from a properties file which is evidently
therefore NOT being read. Thank you -Ike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top