在使用Play Framework v1和IntelliJ 13 CE并运行jUnit测试时,我在启动时收到UnExpectedException

时间:2014-03-19 16:50:43

标签: intellij-idea playframework playframework-1.x

过去两周我一直在使用IntelliJ CE,突然之间我遇到了在IntelliJ中运行单元测试的问题。我的团队使用Play Framework v1.2.5,如果我从命令行运行项目,它编译并运行正常。如果我在Eclipse Kepler中运行项目测试,它们可以正常工作。只有当我在IntelliJ中运行测试时,我才会在启动时收到此异常:

    play.exceptions.UnexpectedException: While applying play.CorePlugin@5d0a70af on models.PortfolioHoldingItem$Field$8
    at play.plugins.PluginCollection.enhance(PluginCollection.java:556)
    at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:235)
    at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:163)
    at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:427)
    at play.Play.start(Play.java:515)
    at play.test.PlayJUnitRunner.<init>(PlayJUnitRunner.java:34)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
Caused by: play.exceptions.UnexpectedException: While applying class play.classloading.enhancers.PropertiesEnhancer on models.PortfolioHoldingItem$Field$8
    at play.CorePlugin.enhance(CorePlugin.java:306)
    at play.plugins.PluginCollection.enhance(PluginCollection.java:551)
    ... 18 more
Caused by: play.exceptions.UnexpectedException: Error in PropertiesEnhancer
    at play.classloading.enhancers.PropertiesEnhancer$1.edit(PropertiesEnhancer.java:177)
    at javassist.expr.ExprEditor.loopBody(ExprEditor.java:198)
    at javassist.expr.ExprEditor.doit(ExprEditor.java:91)
    at javassist.CtBehavior.instrument(CtBehavior.java:664)
    at play.classloading.enhancers.PropertiesEnhancer.enhanceThisClass(PropertiesEnhancer.java:135)
    at play.CorePlugin.enhance(CorePlugin.java:301)
    ... 19 more
Caused by: javassist.NotFoundException: field: $assertionsDisabled in models.PortfolioHoldingItem$Field
    at javassist.CtClassType.checkGetField(CtClassType.java:907)
    at javassist.CtClassType.getField(CtClassType.java:896)
    at javassist.CtClass.getField(CtClass.java:699)
    at javassist.expr.FieldAccess.getField(FieldAccess.java:114)
    at play.classloading.enhancers.PropertiesEnhancer$1.edit(PropertiesEnhancer.java:142)
    ... 24 more

该课程在项目中,但未经过测试。我试过:

  1. 播放干净(删除播放缓存)
  2. 播放idealize(重新生成IntelliJ项目,重新导入)
  3. 播放eclipsify(重新生成eclipse项目,然后导入IntelliJ)
  4. 从IntelliJ,File |中使缓存无效并重新启动
  5. 将我的JDK从1.7.0_45升级到1.7.0_51
  6. 升级至IntelliJ CE 13.1
  7. 克隆回购的新副本,重新导入
  8. 我在Mac上,如果这有任何区别。还有其他人经历过吗?有什么建议可以尝试吗?

    编辑:我的Linux开发机器上存在同样的问题。

1 个答案:

答案 0 :(得分:0)

我相信我找到了解决方案。 PlayFramework v1与Java 7的验证程序有一些问题。

将-XX:-UseSplitVerifier添加到jUnit Run / Debug配置解决了这个问题。

Run/Debug Configuration | Defaults | jUnit