You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Torsten Römer <to...@luniks.net> on 2005/06/07 20:57:06 UTC
Class.forName() gives NoClassDefFoundError
Hello!
I am currently trying to migrate a webbased cashregister system from BEA
Weblogic 6.1/JDK 1.3.1 to Tomcat 5.0.25/JDK 1.4.2. After making some
minor changes the application seems to work, and it also seems to run a
lot faster.
I have one problem though: The application does a lot of
Class.forName(), which occasionally fails with a NoClassDefFoundError.
One time everything seems to work fine, another time, after a restart of
Tomcat, I sometimes get this error.
In a pretty old post here I read that I have to add the classes in
question (they are all in WEB-INF/classes) to Tomcat's classpath, so
that the classloader can find them. Does this still apply? Or have I
overlooked some setting, that for example preloads classes or something
like that?
Greetings,
Torsten
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Funny JAR file, WAS: Class.forName() gives NoClassDefFoundError
Posted by Torsten Römer <to...@luniks.net>.
Jason Bainbridge schrieb:
> On 6/8/05, Torsten Römer <to...@luniks.net> wrote:
>>Just want to follow up on this.
>>
>>Originally, the classes under /WEB-INF/classes were in a JAR file, which
>>I put in /WEB-INF/lib, but like this I always got NoClassDefFoundError.
>>
>>So I thought there may be something wrong with the JAR file. I then
>>zipped the classes manually and replaced the JAR file with that. And see
>>there: No more NoClassDefFoundErrors.
>>
>>The application JAR is, like the WAR file, created by an Ant task. It
>>can be opened/extracted without problems, but if I put it in Tomcat, I
>>always get NoClassDefFoundError. If I zip the classes manually, it works
>>just fine...
>>
>
> Sounds more like a classloader/classpath problem, NoClassDefFoundError
> means it is finding multiple copies of the class.
Doesn't NoClassDefFoundError mean, that the class in question was
present at compile time but is now missing at runtime?
>
> Are you setting your system classpath as well by any chance? If you
> are then you shouldn't be.
I don't, CLASSPATH is unset. I am pretty sure now, that the problem is
the JAR file as created by the Ant task of the project's build.xml. If I
just zip the classes manually, and use that instead of the JAR file,
everything works just fine.
I will now check the JAR task, update Ant, build on another machine and
so on to see if that makes any differences.
Torsten
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Funny JAR file, WAS: Class.forName() gives NoClassDefFoundError
Posted by Jason Bainbridge <jb...@gmail.com>.
On 6/8/05, Torsten Römer <to...@luniks.net> wrote:
> Just want to follow up on this.
>
> Originally, the classes under /WEB-INF/classes were in a JAR file, which
> I put in /WEB-INF/lib, but like this I always got NoClassDefFoundError.
>
> So I thought there may be something wrong with the JAR file. I then
> zipped the classes manually and replaced the JAR file with that. And see
> there: No more NoClassDefFoundErrors.
>
> The application JAR is, like the WAR file, created by an Ant task. It
> can be opened/extracted without problems, but if I put it in Tomcat, I
> always get NoClassDefFoundError. If I zip the classes manually, it works
> just fine...
>
Sounds more like a classloader/classpath problem, NoClassDefFoundError
means it is finding multiple copies of the class.
Are you setting your system classpath as well by any chance? If you
are then you shouldn't be.
Regards,
--
Jason Bainbridge
http://kde.org - webmaster@kde.org
Personal Site - http://jasonbainbridge.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Funny JAR file, WAS: Class.forName() gives NoClassDefFoundError
Posted by Torsten Römer <to...@luniks.net>.
Just want to follow up on this.
Originally, the classes under /WEB-INF/classes were in a JAR file, which
I put in /WEB-INF/lib, but like this I always got NoClassDefFoundError.
So I thought there may be something wrong with the JAR file. I then
zipped the classes manually and replaced the JAR file with that. And see
there: No more NoClassDefFoundErrors.
The application JAR is, like the WAR file, created by an Ant task. It
can be opened/extracted without problems, but if I put it in Tomcat, I
always get NoClassDefFoundError. If I zip the classes manually, it works
just fine...
Is this an Ant or Tomcat issue?
Torsten
Torsten Römer schrieb:
> Hello!
>
> I am currently trying to migrate a webbased cashregister system from BEA
> Weblogic 6.1/JDK 1.3.1 to Tomcat 5.0.25/JDK 1.4.2. After making some
> minor changes the application seems to work, and it also seems to run a
> lot faster.
>
> I have one problem though: The application does a lot of
> Class.forName(), which occasionally fails with a NoClassDefFoundError.
> One time everything seems to work fine, another time, after a restart of
> Tomcat, I sometimes get this error.
>
> In a pretty old post here I read that I have to add the classes in
> question (they are all in WEB-INF/classes) to Tomcat's classpath, so
> that the classloader can find them. Does this still apply? Or have I
> overlooked some setting, that for example preloads classes or something
> like that?
>
> Greetings,
> Torsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org