Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
444 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...