Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Framework: 2.0.2 PersistenceException:Cannot register class in Ebean server

First of all, this question may seem much alike: Play Framework: PersistenceException: The type is not a registered entity? (Ebean) but it's not...

I'm trying to save an entity but it doesn't even render the template, after I restart Play it just gives the error in the subject. Of course, the app compiles.

I've done all the steps to use EBean with Play:

  • annotated model with @Entity (javax.persistence.Entity)
  • model extends Model (play.db.ebean.Model)
  • Ebean is enable in my application.conf ebean.default="models.*" (my classes are in the models package)

Any suggestions? Tests I can do? Things to check? To be fair, stackoverflow is my last resort...

Thanks in advance,

Complete stack trace:

play.api.Configuration$$anon$1: Configuration error [Cannot register class [models.Producer] in Ebean server]
    at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:71) ~[play_2.9.1.jar:2.0.2]
    at play.api.Configuration.reportError(Configuration.scala:258) ~[play_2.9.1.jar:2.0.2]
    at play.Configuration.reportError(Configuration.java:119) ~[play_2.9.1.jar:2.0.2]
    at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:71) ~[play_2.9.1.jar:2.0.2]
    at play.api.Play$$anonfun$start$1.apply(Play.scala:60) ~[play_2.9.1.jar:2.0.2]
    at play.api.Play$$anonfun$start$1.apply(Play.scala:60) ~[play_2.9.1.jar:2.0.2]
Caused by: java.lang.ExceptionInInitializerError: null
    at java.lang.Class.forName0(Native Method) ~[na:1.7.0_02]
    at java.lang.Class.forName(Class.java:264) ~[na:1.7.0_02]
    at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:69) ~[play_2.9.1.jar:2.0.2]
    at play.api.Play$$anonfun$start$1.apply(Play.scala:60) ~[play_2.9.1.jar:2.0.2]
    at play.api.Play$$anonfun$start$1.apply(Play.scala:60) ~[play_2.9.1.jar:2.0.2]
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) ~[scala-library.jar:0.11.3]
Caused by: java.lang.RuntimeException: DataSource user is null?
    at com.avaje.ebeaninternal.server.lib.sql.DataSourcePool.<init>(DataSourcePool.java:198) ~[ebean.jar:na]
    at com.avaje.ebeaninternal.server.lib.sql.DataSourceManager.getDataSource(DataSourceManager.java:210) ~[ebean.jar:na]
    at com.avaje.ebeaninternal.server.lib.sql.DataSourceGlobalManager.getDataSource(DataSourceGlobalManager.java:63) ~[ebean.jar:na]
    at com.avaje.ebeaninternal.server.core.DefaultServerFactory.getDataSourceFromConfig(DefaultServerFactory.java:427) ~[ebean.jar:na]
    at com.avaje.ebeaninternal.server.core.DefaultServerFactory.setDataSource(DefaultServerFactory.java:388) ~[ebean.jar:na]
    at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:168) ~[ebean.jar:na]
like image 956
user1637212 Avatar asked Aug 30 '12 22:08

user1637212


1 Answers

I had exactly the same issue described in the first post. It is weird, in my case, just running

# play 

> clean
> compile
> run

the app started to work again

like image 125
user9869932 Avatar answered Sep 20 '22 08:09

user9869932