Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

exception - NoClassDefFoundError in Eclipse when adding project in build path

I am receiving an NoClassDefFoundError in Eclipse when I try to run my project.

My Project looks like this:

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:

  1. index.html loads
  2. index.html has a form that redirects to execute.jsp
  3. execute.jsp takes the info returned in the form and makes a static call to Login.java
  4. execute.jsp prints the results of the call

Controller.java uses Login.java. I was receiving compilation errors. To resolve them I did this:

  1. Right click on JSPTesting -> properties
  2. Choose java build path on the left bar
  3. Choose projects tab
  4. Click add
  5. Choose BulkAdmin (Project)

I am not sure why but now when I am getting a NoClassDefFoundError. I have done some googling. I think that this means that I have messed up my classpath somehow but I am 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)

Other information:

  • I am using tomcat (in Eclipse) as my server
  • The exception shows up in the browser and the eclipse console
  • execute.jsp is a JSP

It seems like there are many similar questions to this on SO. I have read about 15 of them and tried various things however I think that my question has a different solution. I can provide more information.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Rightclick your dynamic web project, go to Properties > Deployment Assembly and add the dependent projects there. This way they will end up as JAR in /WEB-INF/lib, exactly there where you want it to be.

Eclipse Project Properties Deployment Assembly

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

See also:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...