• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[EclipseLink] How do I export a JPA Project on Eclipse properly?

 
Diego Guachala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The errors seems to indicate that you do not have the persistence.jar and eclipselink.jar on Tomcat's classpath. Try adding these and any other dependencies you have.
 
Diego Guachala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did just like you told me and it worked just fine.

Thanks a lot James.
Take care.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic