Hi guys.
I'm starting my studies on
J2EE and I have a problem. Can you help me out?
I have two projects in my workspace, a dynamic web project and a JPA project.
My first project depends on the second. I created classes in the web project that uses the entities and utility classes from the JPA project and whenever I execute them as
Java Application, everything works fine. The problem appeared when I tried to use the JPA project's classes in a
Servlet. Initially it was related to the fact that the Web Container (
Tomcat 7) wasn't finding the classes. I exported my JPA project as a .jar file and moved it to the container's lib folder. Then the original problem was solved but another one appeared:
Servlet.service() for servlet TestServlet threw exception
java.lang.NoClassDefFoundError: Could not initialize class eyra.db.EMFactory
The EMFactory is a utility class that creates a EntityManagerFactory. This is its code:
Can someone please tell what is wrong or if there is a easier way to integrate a Eclipse's JPA Project into a Dynamic Web Project?