Tomcat + Eclipse Link + Vaadin, NoClassDefFoundError javax/persistence/Pers

I’m using Vaadin and Eclipse Link for my web application based on MySQL database. I have a following class to manage db operations:

[code]
public class DatabaseManager {
private static final String PERSISTENCE_UNIT_NAME = “students”;
private static EntityManagerFactory factory;
private static EntityManager em;

public DatabaseManager() {
    factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
    em = factory.createEntityManager();
}

public void addEntry(Student student) {
    em.getTransaction().begin();
    em.persist(student);
    em.getTransaction().commit();
}

}
[/code]and the following persistence.xml file:

[code]

<?xml version="1.0" encoding="UTF-8" ?> com.example.simplegradebook.Student
  <!-- EclipseLink should create the database schema automatically -->
  <!-- <property name="eclipselink.ddl-generation" value="drop-and-create-tables" /> -->
  <property name="eclipselink.ddl-generation.output-mode" value="both" />
</properties>
[/code]I also have a DBTest class in which I test DatabaseManager in console and everything seems to be okay. But when I put for example: [code] DatabaseManager dbm = new DatabaseManager(); dbm.addEntry(new Student(/*some stuff here*/)); [/code]

in my VaadinUI class, I get errors like that:

com.vaadin.server.ServiceException: java.lang.NoClassDefFoundError: javax/persistence/Persistence
com.vaadin.server.VaadinService.handleExceptionDuringRequest(VaadinService.java:1463) 
com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1417) 
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
java.lang.NoClassDefFoundError: javax/persistence/Persistence
	com.example.simplegradebook.DatabaseManager.<init>(DatabaseManager.java:19)
	com.example.simplegradebook.SimplegradebookUI.init(SimplegradebookUI.java:44)
	com.vaadin.ui.UI.doInit(UI.java:641)
	com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:222)
	com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
	com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
	com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1405)
	com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)

I have these libraries included in my project:

javax.persistence_2.1.0.v201304241213.jar
javax.persistence.source_2.1.0.v201304241213.jar

Any ideas what may cause the problem?

Do you use Maven to build your project? Have you verified that there is no conflicting dependencies, i.e. two different version of javax.persistence.jar? If you build war of your project, does it contain javax.persistence_XXX.jar file? Could you show more code of DatabaseManager class, what is in the line 19?

Thanks for your reply, I’ve already solved my problem. It turned out that I didn’t have javax.persistence library in my WEB-INF/lib folder.