Java Resilience to Tomcat - EntityManager Entity Missing Provider Named

I am trying to learn how to use perseverance and have already managed to successfully launch a project on a glass fish on my local machine. Now the next step for me was to run it on my server on Tomcat, but that would not work.

I always get the error "There is no entity provider for EntityManager named MyPersistence"

This is what the structure of war looks like

. |____index.jsp |____WEB-INF | |____classes | | |____Mainpackage | | | |____Ente.class | | |____META-INF | | | |____persistence.xml | |____lib | | |____javax.persistence.jar | | |____mysql-connector-java-5.1.24-bin.jar | |____web.xml 

the contents of my jsp

  EntityManagerFactory fac = Persistence.createEntityManagerFactory("MyPersistence"); EntityManager mgr = fac.createEntityManager(); mgr.getTransaction().begin(); Ente e = new Ente(); e.setName("Quietscheente"); mgr.persist(e); mgr.getTransaction().commit(); mgr.close(); fac.close(); 

and my persistence.xml looks like

 <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> <persistence-unit name="MyPersistence"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.connection.url" value="jdbc:mysql://h2134265.stratoserver.net/persistencetest"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.username" value="persistence"/> <property name="hibernate.connection.password" value="XXXXXXXXX"/> <property name="hibernate.archive.autodetection" value="class"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> <property name="hbm2ddl.auto" value="update"/> </properties> <class>Mainpackage.Ente</class> </persistence-unit> </persistence> 

I tried moving persistence.xml to another place, but according to several sources on the internet, the location should be correct.

+4
source share
1 answer

There are no hibernation libraries according to your WEB-INF/lib content.

Therefore, please download your libraries and add them to your WEB-INF/lib folder.

Here is a list of required libraries (note that javax.persistence.jar needs to be removed to avoid a possible JAR conflict):

  • ANTLR-2.7.7.jar
  • dom4j-1.6.1.jar
  • sleeping-Wikimedia Commons annotations-4.0.1.Final.jar
  • hibernate-core-4.1.8.Final.jar
  • winter-EntityManager-4.1.8.Final.jar
  • sleep mode JPA-2.0-api-1.0.1.Final.jar-
  • Javassist-3.15.0-GA.jar
  • JBoss-logging 3.1.0.GA.jar
  • JBoss transaction api_1.1_spec-1.0.0.Final.jar
+1
source

All Articles