Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jars not copied to Tomcat's lib folder

I am doing some basic spring stuff and stuck at some point. I am getting ClassNotFoundException whenever I deploy my application on Tomcat.

I observed that the jars are not copied to Tomcats lib folder. When I copied the jars manually to Tomcats lib folder it works fine.

Please let me know if I am making any blunder.

PS - I am using Spring tool suite 2.6.0,Tomcat 6 and its a Maven project.

Thanks.

like image 939
Ajinkya Avatar asked May 18 '11 08:05

Ajinkya


People also ask

How are classes and jars loaded in Tomcat?

Classes and jars inside the $ {catalina.base}/lib and $ {catalina.home}/lib folders (which by default are equal to the lib folder of your Tomcat installation) are loaded by the common classloader. Classes in the WEB-INF/classes and jars in the WEB-INF/lib folder (or WAR archive) are loaded by the web application class loader.

Can I put a library on the classpath of Tomcat?

As a rule you should not put any new library in the common class loader's classpath, since this is administered by the Tomcat server admin, not the Java developer. As an exception you may assume the lib folder contains:

How to deploy dependencies in Tomcat Jar project?

When you are building the jar project, you don't need to worry about deploying dependencies, just list them in the POM file. The hard work of collecting them should be done in the web application WAR project. Tomcat has a complex classloader hierarchy, which allows every web application to use a different version of the same library.

How do I load classes from WEB-INF/classes to Tomcat?

Classes in the WEB-INF/classes and jars in the WEB-INF/lib folder (or WAR archive) are loaded by the web application class loader. As a rule you should not put any new library in the common class loader's classpath, since this is administered by the Tomcat server admin, not the Java developer. As an exception you may assume the lib folder contains:


1 Answers

Go to "Project properties -> Deployment Assembly page".
This page describes how your application will be packaged for deployment or export. And added new source "Maven dependency".

From Deployment Assembly page, Click Add... button Then select "Java Build Path Entries" "Maven dependency" should be in the list

It solves the issue and all jar got copied to tomcat

like image 152
Ajinkya Avatar answered Oct 08 '22 12:10

Ajinkya