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.
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.
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:
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.
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:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With