I have one web dynamic project called “eshop” for which I am making a JPA for. I have added via File New JPA project a new JPA and called it “jpa” with the package name called “model” In the servlet in the eshop project i call it via
import model.*;
ProductModelDAO dao4 = new ProductModelDAOImpl("jpa");
ArrayList products = dao4.getProductsByCategory(categoryId);
It however keeps giving the NoClassDefFoundError error. Eclipse won’t allow me to give the JPA the same package name as the eshop project which has the package name “eshop”. In the JPA project using the properties window I tried to reference to the eshop project without any result. In the JPA project in Java Build Path I also added via Add Class Folder the class folder of the eshop project. Also without any result. I’ve spent hours checking why this is happening. Could anyone can give me a clear instruction how to solve this? I’m using Weblogic 11gR1 (10.3.3). The error is the following:
java.lang.NoClassDefFoundError: model/ProductModelDAOImplat eshop.Servlet.doPost(Servlet.java:110)
at eshop.Servlet.doGet(Servlet.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3686)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
It appeared to be a package issue. I solved it by giving the jpa package name eshop.