Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My Model is NOT an Entity Bean registered with this server?

I'm using Playframework for the firstime in combination with Ebean.

Now I want to use MySQL as database so I added:

db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost:3306/TestDb"
db.default.user=root
db.default.password="test"

to my Application.conf file.

I disabled the evolutionplugin in the Application.conf file because I don't want to use it.

evolutionplugin=disabled

I added the ebean default location for my models:

ebean.default="models.*"

In my package models I've got a class User like this:

import play.db.ebean.Model;

import javax.persistence.Id;

public class User extends Model {
    @Id
    private Integer id;
    private String firstname;
    private String lastname;
    private String email;
    private String token_facebook;
    private String token_google;
    private String reg_date;
    private String id_facebook;
    private String id_google;

    public static Finder<Integer, User> find = new Finder<Integer, User>(
            Integer.class, User.class
    );
}

Now I just want to retrieve every user like this:

User.find.all()

This gives me:

[error] play - Cannot invoke the action, eventually got an error: javax.persistence.PersistenceException: models.User is NOT an Entity Bean registered with this server?
[error] application - 

! @6l806jcli - Internal server error, for (POST) [/register] ->

play.api.Application$$anon$1: Execution exception[[PersistenceException: models.User is NOT an Entity Bean registered with this server?]]
    at play.api.Application$class.handleError(Application.scala:296) ~[play_2.11-2.3.8.jar:2.3.8]
    at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.11-2.3.8.jar:2.3.8]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.8.jar:2.3.8]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.11-2.3.8.jar:2.3.8]
    at scala.Option.map(Option.scala:145) [scala-library-2.11.1.jar:na]
Caused by: javax.persistence.PersistenceException: models.User is NOT an Entity Bean registered with this server?
    at com.avaje.ebeaninternal.server.core.DefaultServer.createQuery(DefaultServer.java:998) ~[avaje-ebeanorm-3.3.4.jar:na]
    at com.avaje.ebeaninternal.server.core.DefaultServer.createQuery(DefaultServer.java:955) ~[avaje-ebeanorm-3.3.4.jar:na]
    at com.avaje.ebeaninternal.server.core.DefaultServer.find(DefaultServer.java:991) ~[avaje-ebeanorm-3.3.4.jar:na]
    at play.db.ebean.Model$Finder.all(Model.java:258) ~[play-java-ebean_2.11-2.3.8.jar:2.3.8]
    at controllers.Register.register(Register.java:21) ~[classes/:na]

My database has every field that my User class has.

Anyone an idea?

like image 355
user1007522 Avatar asked Feb 17 '15 07:02

user1007522


1 Answers

I found the problem.

I forgot to annotate the class with the @Entity annotation.

This solved the problem.

like image 116
user1007522 Avatar answered Sep 25 '22 16:09

user1007522