Neatoro
Neatoro

Reputation: 173

Play Framework JPA - Entity not found

I am currently trying to run my Play App as an deployed app. It has an JPA integration which works fine if I am running the app locally. But if I am trying to run in productive mode, I am currently getting this error:

Caused by: java.lang.IllegalArgumentException: Not an entity: class 
      com.mm.entities.Message
      at org.hibernate.jpa.internal.metamodel.MetamodelImpl.entity(MetamodelImpl.java:194)
      at org.hibernate.jpa.criteria.QueryStructure.from(QueryStructure.java:124)
      at org.hibernate.jpa.criteria.CriteriaQueryImpl.from(CriteriaQueryImpl.java:156)
      at com.mm.helpers.QueryBuilder.<init>(QueryBuilder.java:24)
      at com.mm.persistence.MessagePersistence.getByReceiver(MessagePersistence.java:49)
      at com.mm.controllers.Messages.getMessageByReceiver(Messages.java:47)
      at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(Routes.scala:91)
      at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(Routes.scala:91)
      at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:157)
      at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:156)

Has anyone an idea where it could come from? My persistence unit inside persistence.xml looks like that:

<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <non-jta-data-source>MMChat</non-jta-data-source>
    <properties>
        <property name="hibernate.archive.autodetection" value="class" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        <property name="hibernate.hbm2ddl.auto" value="create-drop" />
    </properties>
</persistence-unit>

Upvotes: 0

Views: 328

Answers (1)

asch
asch

Reputation: 1963

For production mode each DB-entity related class should be added into the persistence.xml with full package name. DB-entity related class is any of entity, embeddable class or attribute converter class. In your case this should be something like this:

<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <non-jta-data-source>MMChat</non-jta-data-source>
    <class>com.mm.entities.Message</class>
    <properties>
    ...
    </properties>
</persistence-unit>

Upvotes: 1

Related Questions