NoClassDefFoundError in Eclipse when adding project to build path

I get a NoClassDefFoundError in Eclipse when I try to start my project.

My project is as follows:

 JavaProject: BulkAdmin - src - com.mycompany.bulkadmin.SDK.util - Login.java Dynamic Web Project: JSPTesting - src - com.mycompany.bulkadmin.jspController - Controller.java - WebContent - index.html - execute.jsp 

This is the control flow:

  • index.html loads
  • index.html has a form that redirects to execute.jsp
  • execute.jsp takes the information returned in the form and makes a static call to Login.java
  • execute.jsp prints the results of the call

Controller.java uses Login.java. I was getting compilation errors. To solve them, I did the following:

  • Right click on JSPTesting -> properties
  • Choose java build path in left pane
  • Select the Projects tab
  • Press button
  • Select BulkAdmin (Project)

I'm not sure why, but now that I get a NoClassDefFoundError . I have done some searches. I think this means that I messed up my class somehow, but I'm not sure how to resolve this.

 java.lang.NoClassDefFoundError: com/myCompany/bulkadmin/SDK/util/Login at com.myCompany.bulkadmin.jspController.Controller.process(Controller.java:44) at org.apache.jsp.execute_jsp._jspService(execute_jsp.java:63) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:595) 

Additional Information:

  • I use tomcat (in Eclipse) as my server
  • Exception displayed in browser and eclipse console
  • execute.jsp is a JSP

There seem to be many similar questions on SO. I read about 15 of them and tried different things, but I think my question has a different solution. I can provide additional information.

+6
source share
2 answers

Choose your dynamic web project correctly, go to Properties> Build Deployment and add dependent projects there. That way they will end up as a JAR in /WEB-INF/lib , exactly where you want.

Eclipse Project Properties Deployment Assembly

For versions of Eclipse older than 3.5, you need to go to Properties> Java EE Module Dependencies.

See also:

+22
source

NoClassDefFoundError indicates that the class available at compile time is no longer available at run time. Your problem is that the class com/myCompany/bulkadmin/cSDK/util/Login is available in the compilation class path (in Eclipse via the Project link added to the build path), but not in the runtime path (Tomcat, which has no idea has how to find this class).

You need to add the BulkAdmin project to the web application class class if it is also installed on Tomcat.

One way to do this is to export the BulkAdmin project as a JAR and place it in the WEB-INF/lib your JSPTesting project.

+2
source

Source: https://habr.com/ru/post/886253/


All Articles