[RuntimeException: No JPA EntityManagerFactory configured for name [default]]

2,469 views
Skip to first unread message

sumeet

unread,
Apr 5, 2012, 10:29:34 AM4/5/12
to play-framework

Hi,

I have started using Play 2.0 framework. I was trying to implement
code similar to computer-database-jpa.

But i was getting this error

[RuntimeException: No JPA EntityManagerFactory configured for name
[default]]

Please if anybody can help me on this.

Thanks
Sumeet

Sidnei R. Basei

unread,
Apr 7, 2012, 9:38:44 AM4/7/12
to play-fr...@googlegroups.com
I've the same problem.

I am using JPA with hibernate and PostgreSQL.

My application.conf

db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost/my_database"
db.default.user=***
db.default.password="****"
db.default.jndiName=DefaultDS
hibernate.use_sql_comments=true


My META-INF/persistence.xml:

<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
</properties>
</persistence-unit>


My GenericJpaImpl.java

public T findById(Long id) {
try {
T obj = JPA.em().find(getPojoClass(), id);
return obj;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}

Sidnei Basei

unread,
Apr 7, 2012, 9:48:38 AM4/7/12
to play-fr...@googlegroups.com
Dear Sumeet,

I've found my configuration error.

In my application.conf file was missing:

jpa.default=defaultPersistenceUnit

I tried many configurations found in blogs. But now it is working pretty well.

[]'
Sidnei

--
Sidnei Basei 
twitter.com/SidneiBasei
Facebook.com/SidneiBasei

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/0rqEYDmp-0oJ.
> To post to this group, send email to play-fr...@googlegroups.com (mailto:play-fr...@googlegroups.com).
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com (mailto:play-framewor...@googlegroups.com).
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

sumeet

unread,
Apr 7, 2012, 1:04:52 PM4/7/12
to play-framework
Hi Sidnei,

I am using JPA with hibernate and mysql.

My application.conf file


db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/mydatabase"
db.default.user="user"
db.default.password="***"
db.default.jndiName=DefaultDS

jpa.default=defaultPersistenceUnit

My 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>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect"/>
</properties>
</persistence-unit>

</persistence>

Can you suggest something.

Error:PersistenceException: No Persistence provider for EntityManager
named defaultPersistenceUnit

Thanks
Sumeet
> > To view this discussion on the web visithttps://groups.google.com/d/msg/play-framework/-/0rqEYDmp-0oJ.

Sidnei Basei

unread,
Apr 7, 2012, 3:07:49 PM4/7/12
to play-fr...@googlegroups.com
Hi,

My configuration is like yours. Please, check your project/Build.scala file:

import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "EncontreQuadras"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
"postgresql" % "postgresql" % "8.4-702.jdbc4",
"org.hibernate" % "hibernate-entitymanager" % "4.1.1.Final",
"org.hibernate" % "hibernate-core" % "4.1.1.Final",
"org.hibernate" % "hibernate-validator" % "4.2.0.Final"

)
val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
// Add your own project settings here
)
}


[]'s
Sidnei

--
Sidnei Basei 
twitter.com/SidneiBasei
Facebook.com/SidneiBasei

> > twitter.com/SidneiBasei (http://twitter.com/SidneiBasei)
> > Facebook.com/SidneiBasei (http://Facebook.com/SidneiBasei)

> > > To view this discussion on the web visithttps://groups.google.com/d/msg/play-framework/-/0rqEYDmp-0oJ (http://groups.google.com/d/msg/play-framework/-/0rqEYDmp-0oJ).


> > > To post to this group, send email to play-fr...@googlegroups.com (mailto:play-fr...@googlegroups.com).
> > > To unsubscribe from this group, send email to play-framewor...@googlegroups.com (mailto:play-framewor...@googlegroups.com).
> > > For more options, visit this group athttp://groups.google.com/group/play-framework?hl=en.
> >
>
>
>

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.

Reply all
Reply to author
Forward
0 new messages