1

Within my Java Dynamic Web Project I'm importing another Java project using Build Path so I can query the classes and use Java reflections. When writing my class I initially tested it by running it as a Java application and it worked. However I am now using the same class as part of a dynamic web project it can't seem to access the imported Java project. I have tried importing it into my project references in Eclipse and it still does not work and outputs the following error:

HTTP Status 500 - javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler

--------------------------------------------------------------------------------

type Exception report

message javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler

description The server encountered an internal error (javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler) that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause 

javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.UpdatingDb_jsp._jspService(UpdatingDb_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause 

java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler
com.q1labs.qa.xmlgenerator.controller.updatedb.DbUpdateScript.updateObjectTypes(DbUpdateScript.java:40)
com.q1labs.qa.xmlgenerator.controller.updatedb.DbUpdateScript.updateDb(DbUpdateScript.java:31)
org.apache.jsp.UpdatingDb_jsp._jspService(UpdatingDb_jsp.java:88)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

2 Answers 2

6

Check your Project Properties > Deployment Assembly configuration. Go to Add and select Project > Next and select your project. Now this will only include the classes of your project. If your Java project includes external or other JAR references, you have to also include them manually on your new Web Project by copying them to your WEB-INF/lib or by adding them as External Jars. If you do the second one, don't forget to mark them in the Order & Export tab.

Sign up to request clarification or add additional context in comments.

6 Comments

I looked in the Deployment Assembly and my Java build path entries weren't added however the project I am importing does not appear in the Java build path entries, probably because it is not a .JAR but an uncompiled project.
On the Deployment Assembly window, when you click on Add..., instead of selecting Java Build Path Entries, select Project > Next and select it there. This should probably do it. If it works I'll update the answer.
That seemed to solve the problem only to come up against a new error message: HTTP Status 500 - javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/openqa/selenium/NoAlertPresentException
Is that setup as a jar reference on the java project? If it is, you're just going to have to include it the WEB-INF/lib of your web project manually or to reference it as an external JAR (don't forget to check it in the Order & Export settings). It's very dificult to set up the dependencies through standard Eclipse options, I would recomend going Maven on this.
I have a project that is being used for automation testing which has jar files added. What I want to do is build a front end to the application, I have a script which will check specific classes for what methods they contain which are then saved to a database. I'm not interested the external jar files which get updated frequently, all I want my script to do is load particular classes which are not always known and check their contents.
|
0

Can you open the war file which is deployed and check if this class file located inside WEB-INF/classes ? If this is the case, check your source tab in buildpath

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.