[Java-2.5] No Persistence provider for EntityManager named defaultPersistenceUnit

843 views
Skip to first unread message

Johan Dahlberg

unread,
Sep 13, 2016, 4:33:20 AM9/13/16
to Play Framework
I am starting with a new project at work and this time I am starting with 2.5 instead of 2.4. I have set up a small project that is supposed to use JPA. But when I'm trying to inject JPAApi to my controller I get this error:

No Persistence provider for EntityManager named defaultPersistenceUnit

 I have the default conf file from the "play-java-intro" template. Modified with the following:

db {
  default {
    driver=com.mysql.jdbc.Driver
    url="jdbc:mysql://localhost/dbname"
    username="root"
    password="secret"
    jndiName=DefaultDS
    logSql=true
  }
}
jpa.default=defaultPersistenceUnit

and conf/META_INF/persistence.xml:

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             version="2.1">
    <persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <non-jta-data-source>DefaultDS</non-jta-data-source>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
        </properties>
    </persistence-unit>
</persistence>

build.sbt dependencies:
libraryDependencies ++= Seq(
  javaCore,
  javaJdbc,
  javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
  javaWs,
  "mysql" % "mysql-connector-java" % "5.1.38",
  "org.hibernate" % "hibernate-entitymanager" % "5.1.0.Final",
  "org.hibernate" % "hibernate-java8" % "5.1.0.Final",
  "org.hibernate.javax.persistence" % "hibernate-jpa-2.1-api" % "1.0.0.Final"
)



I haven't had any problems with JPA in 2.4 so this feels weird. I don't do anything with JPA except injecting JPAApi.

Greg Methvin

unread,
Sep 13, 2016, 5:07:16 AM9/13/16
to play-framework
I think you just mistyped META-INF (it's a dash, not an underscore). It looks to me that it's just not picking up persistence.xml.

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/ec628355-9fce-441b-9cd3-8be29f5bd41d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Senior Software Engineer

Johan Dahlberg

unread,
Sep 13, 2016, 5:25:15 AM9/13/16
to Play Framework
Ah, thanks. I double checked everything except that.

/Johan
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages