I am trying to create multi submodule project in PlayFramework (play framework 2.2.1).
How should I name package in submodules?
F.E. I have structure as follow:
- app
- conf
- doc
- logs
- modules:
- common:
- app:
- controllers
- models
- views
- conf:
- common.routes
- build.sbt
- app:
- common:
- project
- public
- target
- test
How package (namespace) I should named in file:
/modules/common/app/controllers/Aplication.java
Wich one should it be:
package controllers;
package controllers.common;
package common.app.controllers;
actually I have like that:
package controllers.common;
public class Index extends Controller {}
The same issue I have with my model classes in submodules. F.e. in file: /modules/common/app/models/User.java
Wich one should it be:
package models;
package models.common;
package common.app.models;
actually I have like that:
package models.common;
public class User {}
runtime error that I get:
[IllegalArgumentException: Unknown entity: models.Cart]
I've found solution.
It dosn't matter how I named packages. One requirement from play framework is to start name of package with:
package controllers.common;
)package models.common;
, or justpackage models;
)Runtime error:
Is caused by Jpa/Hibernate configuration. Problem is that Jpa/Hibernate sees my entities (mark by annotation @Entity) while compilation, but in runtime dosn't. To fix that I've to manually point all my models class (entitites) in persistance.xml file as follow:
/conf/META-INF/persistence.xml
See more here: How to persist models entity in playframework submodule using jpa/hibernate