1

The tomcat server is throwing a ClassNotFoundException despite the required libraries being in the WEB-INF/lib folder of my application.

All of the libraries were added in the libraries section of Netbeans, the IDE that I'm using.

Here's the full message:

Type Exception Report

Message Servlet execution threw an exception.
Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Servlet execution threw an exception
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Root Cause

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    com.amazonaws.regions.AwsRegionProviderChain.<clinit>(AwsRegionProviderChain.java:33)
    com.amazonaws.client.builder.AwsClientBuilder.<clinit>(AwsClientBuilder.java:60)
    UserCreator.createWithCognito(UserCreator.java:193)
    UserCreator.doGet(UserCreator.java:77)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Root Cause

java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1363)
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1186)
    com.amazonaws.regions.AwsRegionProviderChain.<clinit>(AwsRegionProviderChain.java:33)
    com.amazonaws.client.builder.AwsClientBuilder.<clinit>(AwsClientBuilder.java:60)
    UserCreator.createWithCognito(UserCreator.java:193)
    UserCreator.doGet(UserCreator.java:77)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Note: The full stack trace of the root cause is available in the server logs.
skomisa
  • 16,436
  • 7
  • 61
  • 102
  • [1] One cause of this problem can be having multiple instances of a jar available at run-time. Have you verified that there aren't additional instances of the jar(s) you added to your **WEB-INF/lib** directory in Tomcat's **lib** as well? [2] There are over a dozen questions on Stack Overflow relating to `ClassNotFoundException` for `LogFactory`. For example, [java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory](https://stackoverflow.com/q/40848701/2985643). Have you checked all of those? If so, please update your question to confirm that. If not, please review them. – skomisa May 30 '19 at 05:32

0 Answers0