Java 8.の最終バージョンをインストールしました。Mavenでプロジェクトをビルドしようとすると、Java 8を使用すると多くのテストが失敗しますが、問題なくパスしますJava 7.私は、Java_HOMEをC:\ Program Files\Java\jdk1.8.0に設定してコマンドラインから実行し、デフォルトのJREとしてjdk1.8.0を選択してEclipse経由で実行しようとしましたインストールされたJREの両方が失敗します。失敗したテストはすべてDrools 6(およびその依存関係)を使用することに注意してください。
出力は次のとおりです。
-------------------------------------------------------------------------------
Test set: com.local.lds.rules.LocmChiTest
-------------------------------------------------------------------------------
Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 1.245 sec <<< FAILURE!
test(com.local.lds.rules.LocmChiTest) Time elapsed: 0.001 sec <<< ERROR!
Java.lang.ExceptionInInitializerError
at Sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at Sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.Java:62)
at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.Java:45)
at Java.lang.reflect.Constructor.newInstance(Constructor.Java:408)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.Java:187)
at Sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:483)
at mockit.internal.util.MethodReflection.invoke(MethodReflection.Java:63)
at mockit.Invocation.proceed(Invocation.Java:192)
at mockit.integration.junit4.internal.BlockJUnit4ClassRunnerDecorator.createTest(BlockJUnit4ClassRunnerDecorator.Java:59)
at Sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:483)
at mockit.internal.util.MethodReflection.invokeWithCheckedThrows(MethodReflection.Java:95)
at mockit.internal.mockups.MockMethodBridge.callMock(MockMethodBridge.Java:75)
at mockit.internal.mockups.MockMethodBridge.invoke(MockMethodBridge.Java:41)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.Java)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.Java:236)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.Java:15)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.Java:233)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.Java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.Java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.Java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.Java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.Java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.Java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.Java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.Java:300)
at org.Apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.Java:53)
at org.Apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.Java:123)
at org.Apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.Java:104)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:483)
at org.Apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.Java:164)
at org.Apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.Java:110)
at org.Apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.Java:175)
at org.Apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.Java:107)
at org.Apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.Java:68)
Caused by: Java.lang.RuntimeException: wrong class format
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.Java:279)
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.Java:219)
at org.Eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.Java:113)
at org.Eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.Java:49)
at org.Eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.Java:122)
at org.Eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.resolve(ParameterizedTypeBinding.Java:861)
at org.Eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.Java:100)
at org.Eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveTypeFor(BinaryTypeBinding.Java:1081)
at org.Eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.getField(BinaryTypeBinding.Java:869)
at org.Eclipse.jdt.internal.compiler.lookup.Scope.findField(Scope.Java:1052)
at org.Eclipse.jdt.internal.compiler.lookup.Scope.findField(Scope.Java:998)
at org.Eclipse.jdt.internal.compiler.lookup.MethodScope.findField(MethodScope.Java:354)
at org.Eclipse.jdt.internal.compiler.lookup.BlockScope.getBinding(BlockScope.Java:474)
at org.Eclipse.jdt.internal.compiler.ast.QualifiedNameReference.resolveType(QualifiedNameReference.Java:930)
at org.Eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.Java:374)
at org.Eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.Java:947)
at org.Eclipse.jdt.internal.compiler.ast.Block.resolve(Block.Java:90)
at org.Eclipse.jdt.internal.compiler.ast.IfStatement.resolve(IfStatement.Java:260)
at org.Eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.Java:456)
at org.Eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.Java:252)
at org.Eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.Java:415)
at org.Eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.Java:1148)
at org.Eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.Java:1258)
at org.Eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.Java:539)
at org.Eclipse.jdt.internal.compiler.Compiler.process(Compiler.Java:763)
at org.Eclipse.jdt.internal.compiler.Compiler.compile(Compiler.Java:468)
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.Java:405)
at org.drools.compiler.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.Java:49)
at org.drools.compiler.rule.builder.dialect.Java.JavaDialect.compileAll(JavaDialect.Java:405)
at org.drools.compiler.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.Java:46)
at org.drools.compiler.compiler.PackageRegistry.compileAll(PackageRegistry.Java:110)
at org.drools.compiler.compiler.PackageBuilder.compileAll(PackageBuilder.Java:1334)
at org.drools.compiler.compiler.PackageBuilder.compileAllRules(PackageBuilder.Java:975)
at org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.buildRules(CompositeKnowledgeBuilderImpl.Java:266)
at org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.buildPackages(CompositeKnowledgeBuilderImpl.Java:98)
at org.drools.compiler.compiler.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.Java:87)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.buildKnowledgePackages(AbstractKieModule.Java:204)
at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.Java:39)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.Java:323)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.Java:193)
at com.local.lds.rules.RuleEngineManager.buildKieBase(RuleEngineManager.Java:90)
at com.local.lds.rules.LocmChiTest.<clinit>(LocmChiTest.Java:33)
... 41 more
Caused by: org.Eclipse.jdt.internal.compiler.classfmt.ClassFormatException
at org.Eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.Java:372)
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler$2.createNameEnvironmentAnswer(EclipseJavaCompiler.Java:303)
at org.drools.compiler.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.Java:274)
... 82 more
testNoFeatured(com.local.lds.rules.LocmChiTest) Time elapsed: 0 sec <<< ERROR!
Java.lang.NoClassDefFoundError: Could not initialize class com.local.lds.rules.LocmChiTest
at Sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at Sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.Java:62)
at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.Java:45)
at Java.lang.reflect.Constructor.newInstance(Constructor.Java:408)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.Java:187)
at Sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:483)
at mockit.internal.util.MethodReflection.invoke(MethodReflection.Java:63)
at mockit.Invocation.proceed(Invocation.Java:192)
at mockit.integration.junit4.internal.BlockJUnit4ClassRunnerDecorator.createTest(BlockJUnit4ClassRunnerDecorator.Java:59)
at Sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:483)
at mockit.internal.util.MethodReflection.invokeWithCheckedThrows(MethodReflection.Java:95)
at mockit.internal.mockups.MockMethodBridge.callMock(MockMethodBridge.Java:75)
at mockit.internal.mockups.MockMethodBridge.invoke(MockMethodBridge.Java:41)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.Java)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.Java:236)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.Java:15)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.Java:233)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.Java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.Java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.Java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.Java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.Java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.Java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.Java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.Java:300)
at org.Apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.Java:53)
at org.Apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.Java:123)
at org.Apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.Java:104)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:483)
at org.Apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.Java:164)
at org.Apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.Java:110)
at org.Apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.Java:175)
at org.Apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.Java:107)
at org.Apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.Java:68)
testFeaturedSort(com.local.lds.rules.LocmChiTest) Time elapsed: 0.001 sec <<< ERROR!
Java.lang.NoClassDefFoundError: Could not initialize class com.local.lds.rules.LocmChiTest
at Sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at Sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.Java:62)
at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.Java:45)
at Java.lang.reflect.Constructor.newInstance(Constructor.Java:408)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.Java:187)
at Sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:483)
at mockit.internal.util.MethodReflection.invoke(MethodReflection.Java:63)
at mockit.Invocation.proceed(Invocation.Java:192)
at mockit.integration.junit4.internal.BlockJUnit4ClassRunnerDecorator.createTest(BlockJUnit4ClassRunnerDecorator.Java:59)
at Sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:483)
at mockit.internal.util.MethodReflection.invokeWithCheckedThrows(MethodReflection.Java:95)
at mockit.internal.mockups.MockMethodBridge.callMock(MockMethodBridge.Java:75)
at mockit.internal.mockups.MockMethodBridge.invoke(MockMethodBridge.Java:41)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.Java)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.Java:236)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.Java:15)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.Java:233)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.Java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.Java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.Java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.Java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.Java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.Java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.Java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.Java:300)
at org.Apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.Java:53)
at org.Apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.Java:123)
at org.Apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.Java:104)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:483)
at org.Apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.Java:164)
at org.Apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.Java:110)
at org.Apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.Java:175)
at org.Apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.Java:107)
at org.Apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.Java:68)
これはJava= 8、Maven、Surefireプラグイン、またはDroolsの問題ですか?
Drools(デフォルトのEclipseコンパイラー)のバグのように見えます:
彼らは6.1.0.Beta2
での修正を検討しています。
その間、これを試してください回避策:ecj
依存関係をバージョン4.3.1
にオーバーライドします。
この問題はmavenでpomを編集することで解決しました。
<dependency>
<groupId>org.Eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.5.1</version>
</dependency>
<!-- core -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.5.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.5.0.Final</version>
<exclusions>
<exclusion>
<groupId>org.Eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
</exclusion>
</exclusions>
</dependency>
Javaコードをコンパイルするために使用されるECJは、最近Luna(4.4)でJava 8構文をサポートするようになったため、更新が必要です。
ルールでJava 8構文を使用する場合は、Drools 6.4.0.Finalを使用することもできます。これは、Java 8 as = Java 8(ECJ 4.3の問題を修正するために8を7にマッピングしていました)
MVEL 2.2.Xバージョン以降。これは、Java構文の省略形であり、Java 8.もサポートしています。
Org.Eclipse.jdt.core.jarを入手可能な最新のものに更新します。
今回のケースでは、org.Eclipse.jdt.core-3.5.1.v_972_R35x.jarをorg.Eclipse.jdt.core_3.11.2.v20160128-0629.jarに更新しました。
これはdroolsコードがコンパイルされるJava_versionを決定するjarです。
古いJava-6互換droolsコードがJava -8でコンパイルされると、uはJava -8を使用してそのようなエラーなしで実行できます。これらは証明されています。手順疑問がある場合は元に戻してください。
Org.Eclipse.jdt.internal.compiler(ecj.jar)を最新に更新します。つまり、ecj-4.4.jarを使用して試してください。