I am Using Play frame work 2.1.0 Integration with JPA
======================================================
I am getting this below error. PersistenceException: No Persistence provider for EntityManager named defaultPersistenceUnit
--------------------------
play.api.UnexpectedException: Unexpected exception[PersistenceException: No Persistence provider for EntityManager named defaultPersistenceUnit]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:150) ~[play_2.10-2.1.3.jar:2.1.3]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:114) ~[play_2.10-2.1.3.jar:2.1.3]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:114) ~[play_2.10-2.1.3.jar:2.1.3]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10-2.1.3.jar:2.1.3]
at scala.util.Either$RightProjection.flatMap(Either.scala:523) ~[scala-library.jar:na]
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named defaultPersistenceUnit
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) ~[hibernate-jpa-2.0-api.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) ~[hibernate-jpa-2.0-api.jar:1.0.1.Final]
at play.db.jpa.JPAPlugin.onStart(JPAPlugin.java:35) ~[play-java-jpa_2.10-2.1.0.jar:2.1.0]
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:68) ~[play_2.10-2.1.3.jar:2.1.3]
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:68) ~[play_2.10-2.1.3.jar:2.1.3]
at scala.collection.immutable.List.foreach(List.scala:309) ~[scala-library.jar:na]
application.conf
---------------------
application.langs="en"
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/atlas_n"
db.default.user=postgres
db.default.pass=postgres
db.default.jndiName=DefaultDS
evolutionplugin=disabled
ebean.default="models.*"
logger.root=ERROR
logger.play=INFO
logger.application=DEBUG
#secure social
include "securesocial.conf"
jpa.default=defaultPersistenceUnit
conf/META-INF/persistence.xml
----------------------------
<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="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
Application.java
----------------
package controllers;
import javax.persistence.criteria.CriteriaQuery;
import models.Department;
import play.Logger.ALogger;
import play.db.jpa.JPA;
import play.db.jpa.Transactional;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.index;
public class Application extends Controller {
private static ALogger logger = play.Logger.of("Application");
@Transactional public Result index() { CriteriaQuery c =JPA.em().getEntityManagerFactory().getCriteriaBuilder().createQuery(Department.class); c.from(Department.class); return ok(index.render(JPA.em().createQuery(c).getResultList())); } }
Build.scala
-----------
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "STOrder"
val appVersion = "1.0"
val appDependencies = Seq(
javaCore,
javaJpa,
javaJdbc,
javaEbean,
"org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final",
"postgresql" % "postgresql" % "9.1-901.jdbc4",
"securesocial" %% "securesocial" % "2.1.1"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers += Resolver.url("sbt-plugin-releases", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
)
}
Please anybody help me to solve this issue.