28

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.

Ajinkya
  • 22,324
  • 33
  • 110
  • 161
  • Can you see the library 'Maven Dependencies'? Are your jars in it? In project Properties / Deployment Assembly can you see 'Maven Dependencies'? Is its deploy path 'WEB-INF/lib'? – abalogh May 18 '11 at 08:56
  • 3
    Got the solution. Tried following "Went to your project properties -> Deployment Assembly page. This page describes how your app will be packaged for deployment or export. And added new source "Maven dependency". It solves the issue and all jar got copied to tomcat. – Ajinkya May 18 '11 at 10:15

4 Answers4

85

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

jeremyvillalobos
  • 1,795
  • 2
  • 19
  • 39
Ajinkya
  • 22,324
  • 33
  • 110
  • 161
  • 5
    In Eclipse Juno: Project properties -> Deployment Assembly -> Add (button) -> Java Build Path Entries (select) -> Maven dependencies (select and click on finish) – Ritesh Nov 20 '12 at 21:41
  • 4
    Does anyone have any idea why "Maven dependencies" doesn't show up in my Java Build Path Entries list under Deployment Assembly? It was there earlier this week, and with no changes to my project, it now doesn't show up... and I canNOT for the life of me figure out why. – delfuego Dec 20 '12 at 14:29
  • 1
    Sometimes the JARs aren't copied despite having that configured. Then I recommend cleaning Tomcat and re-publishing modules in Eclipse. – Piohen Jul 16 '14 at 11:43
  • @delfuego, Have you found the answer? I have the same question as yours – Vahid Aug 02 '17 at 17:12
1

Put your jars in the WEB-INF/lib directory: In Project properties -> Deployment Assembly you should have a Source of /web with a Deployment Path of /. If this is there then any jars in the web/WEB-INF/lib directory will get deployed and picked up by the class loader. Note that sub-directories will not be picked up though, so put your jars directly in the lib directory.

jsaven
  • 404
  • 1
  • 7
  • 7
1

If you define "war" packaging for your maven project then your dependent libraries should be automatically copied to the WEB-INF/lib directory of the created .war file by the Maven WAR plugin.

splash
  • 13,037
  • 1
  • 44
  • 67
0

You run three command in cmd or bash(where your pom.xml file placed) to get jar file and copy it into your WEB-INF/lib folder

mvn compile
mvn package
mvn install

I find only this way for resolved my problem:

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
nobjta_9x_tq
  • 1,205
  • 14
  • 16