You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Earl Lewis <Ea...@it.utah.edu> on 2004/11/17 23:29:10 UTC

Tomcat 5.0.28 "wrong name" problem

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
unexpected
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
EE.

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
same
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.io.*;
import java.sql.*;
import java.util.*;
import java.net.URLEncoder;
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
the
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.

exception

javax.servlet.ServletException: Servlet.init() for servlet Projects
threw exception
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
	org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
	org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
	java.lang.Thread.run(Unknown Source)

root cause

java.lang.NoClassDefFoundError: ConnectionPool (wrong name:
aim/util/db/ConnectionPool)
	java.lang.ClassLoader.defineClass0(Native Method)
	java.lang.ClassLoader.defineClass(Unknown Source)
	java.security.SecureClassLoader.defineClass(Unknown 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
fine
- 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
web/server.xml
to make sure Tomcat knows how to find the packages.

my webapps directory structure looks like this

Under the directory:
blah\blah\webapps\aim\WEB-INF\classes

I have this directory structure which contain the compiled class files
                                       |_aim
                                              |__pages
                                              |__util
                                                      |__html
                                                      |__db

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
java
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
folder,
restart Tomcat and away it goes. I know that's somewhat over
simplified
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.

Earl



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