[JAVA] Resolve NoClassDefFoundError, ClassNotFoundException

Premise

When compiling with Eclipse, an error occurs due to class relations. Both of the following have not found the library (jar file).

ClassNotFoundException: org.apache.tomcat.dbcp.dbcp2.BasicDataSource

jar file location → tomcat / 9 / lib / tomcat-dbcp.jar (This package contains the BasicDataSource class)

java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory

jar file location → tomcat / 9 / bin / tomcat-juli.jar

solution

  1. Right-click on the project name → Properties
  2. Java build path → Library
  3. Click "Add External JAR" → select the corresponding jar → open 2.jpg

Recommended Posts

Resolve NoClassDefFoundError, ClassNotFoundException
[Servlet / Ajax] How to resolve NoClassDefFoundError [Eclipse]