Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

play framework 2.1 junit test not working from eclipse

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(BeanDescriptorManager.java:1475)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:1138)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1058)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:565)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:252)
    at com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:124)
    at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:210)
    at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:64)

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???

like image 957
naoru Avatar asked Feb 16 '13 18:02

naoru


2 Answers

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:

-javaagent:/path/to/ebean/ebean-2.7.3-agent.jar

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:

-javaagent:/path/to/ebean/ebean-2.7.3-agent.jar;packages=models.*

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

like image 200
kolen Avatar answered Sep 30 '22 16:09

kolen


You can use the Avaje Ebean Eclipse Plugin:

http://www.avaje.org/eclipseupdate/site.xml

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

like image 32
Miguel Figueiredo Avatar answered Sep 30 '22 17:09

Miguel Figueiredo