tomcat - hibernate.jpa.HibernatePersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider -
im using vaadin develop ui application running hibernate 4.3.1 i'm trying bind data vaadin jpacontainer use in grid component allow lazy-loading. when try , create entitymanager throws following error
java.lang.classcastexception: org.hibernate.ejb.hibernatepersistence cannot cast javax.persistence.spi.persistenceprovider @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:54) @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:39) @ com.vaadin.addon.jpacontainer.jpacontainerfactory.createentitymanagerforpersistenceunit(jpacontainerfactory.java:122) @ com.vaadin.addon.jpacontainer.jpacontainerfactory.make(jpacontainerfactory.java:105)
i used hibernate-jpa-2.1-api-1.0.0.final.jar persistence-api-1.0.2.jar import enitymanager keep getting same error
here class create entitymanager
public class workmanager{ public static void create() { dataaccess dao= new dataaccess(); entitymanager em = persistence //error here .createentitymanagerfactory("myui") .createentitymanager(); em.gettransaction().begin(); dao.init(); list<work> list = dao.findall(); //get rows in table em.persist(list); dao.close(); em.gettransaction().commit(); }
persistence.xml
<?xml version="1.0" encoding="utf-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="myproject"> <!-- specify jpa provider use --> <provider>org.hibernate.jpa.hibernatepersistenceprovider</provider> <!-- entity beans go here --> <class>com.dao.model.work</class> <properties> <!-- db connection properties --> <property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://s12345:1111;databasename=dbname" /> <!-- property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://l71111:1111;databasename=dbname" / --> <property name="javax.persistence.jdbc.user" value="iasys" /> <property name="javax.persistence.jdbc.password" value="password" /> <property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.sqlserverdriver" /> <!-- settings c3p0 connection pooling --> <property name="hibernate.connection.provider_class" value="org.hibernate.connection.c3p0connectionprovider" /> <property name="hibernate.c3p0.max_size" value="100" /> <property name="hibernate.c3p0.min_size" value="0" /> <property name="hibernate.c3p0.acquire_increment" value="1" /> <property name="hibernate.c3p0.idle_test_period" value="300" /> <property name="hibernate.c3p0.max_statements" value="0" /> <property name="hibernate.c3p0.timeout" value="100" /> </properties> </persistence-unit>
in class create jpacontainer
private jpacontainer<work> container = jpacontainerfactory.make(work.class, jpaprojectui.persistence_unit); grid.setcontainerdatasource(container);
and here entitymanager called
public class jpapojectui extends ui { private static final long serialversionuid = 1l; public static final string persistence_unit = "myproject"; static { workmanager.create(); } @override protected void init(vaadinrequest request) { setcontent(new mainui()); }
i following addressbook demo came jpacontainer add-on
i'm using tomcat 8 run application
does have idea why happening? please feel free ask me more info if problem isn't clear!
here jars in web-inf folder
i added project build path has following list of jars
thanks
please remove persistence-api-1.0.2.jar
web application , see results. there conflict between hibernate-jpa , persistance-api
Comments
Post a Comment