Вопрос

I'm trying to deploy a web app to tomcat using ANT but I ran into this error (the app compiles fine in a simple ant task. The issue occurs when Tomcat is restarted):

Stacktrace:

Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    ... 24 more

I red a couple of answers around here which state that besides slf4j an implementation such as log4j. This is an excerpt of the build.xml file:

<pathelement location="${slf4j-api-1.7.2.jar}"/>
<pathelement location="${log4j.jar}"/>

These are path elements used in the classpath of the build's javac command.

Besides not adding log4j as a dependency, what may be other reasons for this issue. Any kind of help would be appreciated. Thanks!

Это было полезно?

Решение

You need to add the .jar files your app need to $TOMCAT/webapps/$YOUR_WEB_APP/WEB-INF/lib/

and then restart tomcat.

Другие советы

I solved this problem copying this 2 JARs below.

from (assuming you are using Maven to manage your dependecies):

  • .m2/repository/org/slf4j/slf4f-api/N.N.NN/slf4j-api-N.N.NN.jar
  • .m2/repository/org/slf4j/slf4f-log4j12/N.N.NN/slf4j-log4j12-N.N.NN.jar

to (apache installation folder):

  • apache-tomcat-M.M.MM/lib
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top