Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Error Adding external jar to a Dynamic Web Project(When deploying to Tomcat causes validateJarFile/jar not loaded then NoClassDefFoundError)
icon5.gif  Error Adding external jar to a Dynamic Web Project [message #1739695] Thu, 04 August 2016 02:48 Go to next message
Erich Lima is currently offline Erich LimaFriend
Messages: 1
Registered: August 2016
Junior Member
Hello folks!

It would be so good if a kind soul helped me.

I am stuck in this: when trying to deploy a small Test Servlet to Tomcat (inside Eclipse), the console shows this message and the deployment fails:
...
03/08/2016 23:04:11 org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
INFO: validateJarFile
(D:\Dev\JavaEEProjects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestWeb\WEB-INF\lib\MyUtils.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class

Followed by:
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestWeb]]
...
Caused by: java.lang.NoClassDefFoundError: Lcom/erich/myUtils/RandomSeedGenerator;
...
Then deployment is halted.



This RandomSeedGenerator Class is actually part of the jar I am trying to include in the Project - MyUtils.jar.

Before anyone asks, this Jar is working flawlessly as I already use it in other Projects (Swing/Awt and others).
I just cannot make it work with Servlets (Dynamic Web Project) for Tomcat 7.

What I have tried so far:
- Project -> Properties -> Deployment Assembly -> Add... -> Archives from Filesystem -> Add... (select Jar file) ---- this leads to the same error as above;
- Copying the jar into the Tomcat/lib folder --- This works ok in Windows. The Servlet deploys and works, but I fail to make it work in Tomcat for Ubuntu (same error as above) and afterall what I want is a single file (the WAR) containing all the classes required by my Project in a single file;
- Dragging the jar file from File Explorer and Dropping into WebContent/WEB-INF/lib folder in Eclipse ---- this leads to the very same error as above. Actually the error I captured above was from this last attempt.


Of course, for it to be able to compile, this Jar is already added to the Build Path (Project -> Java Build Path -> Add External Jar), but this only enables to compile.

If it helps, I am using Eclipse Java EE IDE for Web Developers. Version: Luna Service Release 2 (4.4.2) Build id: 20150219-0600. The JDK I am working with is 1.6, Tomcat is version 7.


Thanks in advance...
Re: Error Adding external jar to a Dynamic Web Project [message #1739741 is a reply to message #1739695] Thu, 04 August 2016 13:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30353
Registered: July 2009
Senior Member
It's best to ask on the Web Tools forum.


On 04.08.2016 14:38, Erich Lima wrote:
> Hello folks!
>
> It would be so good if a kind soul helped me.
>
> I am stuck in this: when trying to deploy a small Test Servlet to
> Tomcat (inside Eclipse), the console shows this message and the
> deployment fails:
> ..
> 03/08/2016 23:04:11 org.apache.catalina.loader.WebappClassLoaderBase
> validateJarFile
> INFO:
> validateJarFile(D:\Dev\JavaEEProjects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestWeb\WEB-INF\lib\MyUtils.jar)
> - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending
> class: javax/servlet/Servlet.class
>
> Followed by:
> java.util.concurrent.ExecutionException:
> org.apache.catalina.LifecycleException: Failed to start component
> [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TestWeb]]
>
> ..
> Caused by: java.lang.NoClassDefFoundError:
> Lcom/erich/myUtils/RandomSeedGenerator;
> ..
> Then deployment is halted.
>
>
> This RandomSeedGenerator Class is actually part of the jar I am trying
> to include in the Project - MyUtils.jar.
>
> Before anyone asks, this Jar is working flawlessly as I already use it
> in other Projects (Swing/Awt and others).
> I just cannot make it work with Servlets (Dynamic Web Project) for
> Tomcat 7.
>
> What I have tried so far:
> - Project -> Properties -> Deployment Assembly -> Add... -> Archives
> from Filesystem -> Add... (select Jar file) ---- this leads to the
> same error as above;
> - Copying the jar into the Tomcat/lib folder --- This works ok in
> Windows. The Servlet deploys and works, but I fail to make it work in
> Tomcat for Ubuntu (same error as above) and afterall what I want is a
> single file (the WAR) containing all the classes required by my
> Project in a single file;
> - Dragging the jar file from File Explorer and Dropping into
> WebContent/WEB-INF/lib folder in Eclipse ---- this leads to the very
> same error as above. Actually the error I captured above was from this
> last attempt.
>
>
> Of course, for it to be able to compile, this Jar is already added to
> the Build Path (Project -> Java Build Path -> Add External Jar), but
> this only enables to compile.
>
> If it helps, I am using Eclipse Java EE IDE for Web Developers.
> Version: Luna Service Release 2 (4.4.2) Build id: 20150219-0600. The
> JDK I am working with is 1.6, Tomcat is version 7.
>
>
> Thanks in advance...
Re: Error Adding external jar to a Dynamic Web Project [message #1739815 is a reply to message #1739695] Thu, 04 August 2016 17:03 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3470
Registered: July 2009
Senior Member

What have you tried regarding the "Offending class: javax/servlet/Servlet.class"? Tomcat itself provides and uses that class, and you only get one of them for the entire JVM.

Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Eclipse takes very long time to delete files during build.
Next Topic:Adding "Show" Command to custom MarkerSupportView
Goto Forum:
  


Current Time: Wed Aug 21 01:16:57 GMT 2019

Powered by FUDForum. Page generated in 0.03046 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top