play framework 2.1 junit test not working from eclipse

By | December 17, 2017

im following the zentask tutorial and wrote a junit test,
the test wont run from the eclipse IDE its giving the following exception

javax.persistence.PersistenceException: java.lang.IllegalStateException: Class [class play.db.ebean.Model] is enhanced and [class models.User] is not - (you can not mix!!)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setEntityBeanClass(
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(
    at com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(
    at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(
    at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(

I read a bit and found that for some people
editing the buils.scala adding the following line inside main helped : ebeanEnabled := true

to me it didnt nither closeing the ide running play clean compile

any ideas???


There is blog post about setting up unit tests to run in IDEs. It suggests to add following command-line to java used when running tests:


Seems that Play not ships with ebean agent, it should be downloaded from Ebean website first (in main ebean package).

I not tried it.

Ebean user guide also mentions it (15.5.2 javaagent section), there is even example for configuring Eclipse.

Also, to speed up enhancement maybe this will be better:


So it will only look into models.* (default package for ORM models in Play).


You can use the Avaje Ebean Eclipse Plugin:

After the installation, activate Ebean enhancement by right clicking on your project and selecting Enable Ebean Enhancement.


i got this error when i tried to remove the public modifier from the declaration of one of classes extending Model.

i was using a model to make a “through” table (a many to many relationship with additional information), so protected access makes sense. perhaps there’s another way to do this, but the play javadoc is pretty sparse.

Leave a Reply

Your email address will not be published. Required fields are marked *