tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Earl Lewis" <>
Subject Tomcat 5.0.28 "wrong name" problem
Date Wed, 17 Nov 2004 22:29:10 GMT

I recently went from Tomcat 3.3.1 to Tomcat 5.0.28 and my old
application won't run on the new version. This isn't all that
but I'm having some problems figuring out the whys and wherefores. Any
help is greatly appreciated.

My config is a Windows XP workstation, Java 1.4.2_06 SE and Java 1.4

Since starting to track down this problem I've seen it suggested that
you should NEVER use default packages anymore and always package your
classes so I faithfully followed that advice and "refactored" to make
sure everything is packaged neatly. I setup the packages using the
following package declarations (no, they're not all declared in the
class file):

package aim.pages;
package aim.util.html;
package aim.util.db;

Each class file gets its appropriate package declaration and I import
the other packages when appropriate. Something like this:

package aim.pages;

import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
import aim.util.html.*;
import aim.util.db.*;

Remember, all this worked before packaging so I'm sure I'm doing
something wrong in that process - I just can't see what it is.

It took me a while to get my java classpath setup so I could get
everything recompiled but I got that all working. javac did a nice job
of creating the package tree for me with the appropriate classes in
right folders, etc...

After compiling I put my compiled classes/folders under
webapps\aim\web-inf\classes\aim and that's when the fun stops.

Stopping and restarting Tomcat successfully loads the web app. It
appears in the HTMLManager application and I can successfully call my
index.jsp. Then when I try to run my servlets I throw an error in the
servlet init method. Here's some of it.


javax.servlet.ServletException: Servlet.init() for servlet Projects
threw exception
	org.apache.tomcat.util.threads.ThreadPool$ Source)

root cause

java.lang.NoClassDefFoundError: ConnectionPool (wrong name:
	java.lang.ClassLoader.defineClass0(Native Method)
	java.lang.ClassLoader.defineClass(Unknown Source) Source)

Notice the "wrong name" comment in the first line of the root cause
section. This is exactly the path where the ConnectionPool class is
found (see below).
>From what I've read the Tomcat classloader is independent (by design)
from any classpath that gets set for your JDK installation. That's
- but my Tomcat classloader doesn't seem to want to recognize my
packages. Apparently I've either got something wrong with my package
locations or I need to do some configuration tweaking in
to make sure Tomcat knows how to find the packages.

my webapps directory structure looks like this

Under the directory:

I have this directory structure which contain the compiled class files

My ConnectionPool class (the one causing the error in servlet init) is
in the db folder. Also, when it gets compiled it creates a second file
called ConnectionPool$PooledConnection.class. I thought I could handle
this be just specifying the import as "import aim.util.db.*;" This
doesn't seem to do any good either. 

I've also tried changing the JVM that Tomcat is using to match the
version I'm using for compiling but still no go.

Is there a declaration in web.xml that I need to make? Everything I've
read is that you can just drop your application into the webapps
restart Tomcat and away it goes. I know that's somewhat over
but I'm not sure where to look next. Any thoughts or suggestions?

Sorry for the long winded message but I want readers to know that I'm
not just crying wolf - I've tried quite a few things to resolve this.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message