Search code examples
eclipsetomcatclasspathclassloader

Eclipse & Tomcat dependency causes ClassNotFoundException: org.slf4j.LoggerFactory


I have a weird problem.

I switched my project from JUL to slf4j and this is also working when I deploy the war file on a tomcat.

When I start it from eclipse, the main code is working (the slf4j jar file is in the classpath and in the lib folder in wtpwebapps) but as soon as a class from another jar file is used that also needs slf4j it breaks with a ClassNotFoundException. But the class is obviously there, just a line above it logs through the Logger that was created by the LoggerFactory... but in the dependency jar it obviously uses a different classloader that does not know the slf4j jar file...

As I say it works when I build a war file and deploy it to tomcat.

Any help?

Found a similar question but there is no helpful answer yet.


Solution

  • Actually deleting the server in Eclipse and adding a new one solved this.