• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did just like you told me and it worked just fine.

Thanks a lot James.
Take care.
 
I knew that guy would be trouble! Thanks tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic