hibernate - No Persistence provider for EntityManager -


i trying configure hibernate work scala code, , when go run application following:

javax.persistence.persistenceexception: no persistence provider entitymanager named studentalerts   javax.persistence.persistence.createentitymanagerfactory(persistence.java:61)   hibernateconfig.hibernateconfig$.getentitymanager(hibernateconfig.scala:29)   hibernateconfig.hibernateconfig$.createentitymanager(hibernateconfig.scala:11)   controller.test.<init>(test.scala:8)   controller.testhome.doget(register.scala:11 

my persistence.xml file (in web-inf/classes/meta-inf folder follows

<persistence-unit name="studentalerts" transaction-type="resource_local">     <provider>org.hibernate.jpa.hibernatepersistenceprovider</provider>     <non-jta-data-source>jdbc/studentalerts</non-jta-data-source>     <properties>     </properties> </persistence-unit> 

and relevant scala code

object hibernateconfig {   var mapping: searchmapping = _   def createentitymanager(): entitymanager = getentitymanager   def getentitymanager: entitymanager = {     val properties: properties = new properties()      properties.put("javax.persistence.provider", "org.hibernate.jpa.hibernatepersistenceprovider")     properties.put("javax.persistence.transactiontype", "resource_local")     properties.put("javax.persistence.jdbc.url", "jdbc:mysql://localhost:3306/studentalerts")     properties.put("javax.persistence.jdbc.user", "alert")     properties.put("javax.persistence.jdbc.password", "12345")     properties.put("javax.persistence.jdbc.driver", "com.mysql.jdbc.driver")     properties.put("hibernate.hbm2ddl.auto", "update")     properties.put("hibernate.show_sql", "false")     properties.put("hibernate.format_sql", "false")     properties.put("hibernate.current_session_context_class", "thread")     properties.put("hibernate.transaction.factory_class", "org.hibernate.transaction.jdbctransactionfactory")     properties.put("hibernate.dialect", "org.hibernate.dialect.mysql5dialect")      val emf: entitymanagerfactory = persistence.createentitymanagerfactory("studentalerts", properties)     emf.createentitymanager()   } } 

the line having hard time

val emf: entitymanagerfactory = persistence.createentitymanagerfactory("studentalerts", properties) 

any appreciated.

thanks

the package declaration provider seems incorrect.

<provider>org.hibernate.jpa.hibernatepersistenceprovider<provider> 

try changing configuration below.

<provider>org.hibernate.ejb.hibernatepersistence</provider> 

also, mixing both things, configuring programmatically + xml. should done either ways.

configure through xml setting properties & use it, below.

entitymanagerfactory = persistence.createentitymanagerfactory("studentalerts"); 

persistence.xml - add properties accordingly.

<?xml version="1.0" encoding="utf-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence"         xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"         xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"         version="2.0">     <persistence-unit name="studentalerts">         <properties>             <property name="javax.persistence.jdbc.driver" value="xyz"/>             <property name="javax.persistence.jdbc.url" value="xyz"/>             <property name="hibernate.show_sql" value="true"/>         </properties>     </persistence-unit> </persistence> 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -