仪表课时的Gradle Error

时间:2014-04-11 19:26:53

标签: testing gradle task instrumentation jacoco

我正在使用Jacoco和GEGProject的gradle进行POC,并且在“测试”任务(即测试测试源代码)中进入jacoco时遇到此错误。有任何想法吗?感谢。

java.lang.instrument.IllegalClassFormatException: Error while instrumenting class org/gradle/internal/service/UnknownServiceException.
        at org.jacoco.agent.rt.internal_5d10cad.CoverageTransformer.transform(CoverageTransformer.java:91)
        at sun.instrument.TransformerManager.transform(TransformerManager.java:169)
        at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at org.gradle.process.internal.child.ImplementationClassLoaderWorker.createLoggingManager(ImplementationClassLoaderWorker.java:85)
        at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:53)
        at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:37)
        at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:43)
        at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:32)
        at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:46)
        at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:32)
        at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.run(GradleWorkerMain.java:32)
        at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.main(GradleWorkerMain.java:37)
Caused by: java.io.FileNotFoundException: build\jacoco\UT\classpathdumps\org\gradle\internal\service\UnknownServiceException.class (The requested oper
ation cannot be performed on a file with a user-mapped section open)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:145)
        at org.jacoco.agent.rt.internal_5d10cad.ClassFileDumper.dump(ClassFileDumper.java:66)
        at org.jacoco.agent.rt.internal_5d10cad.CoverageTransformer.transform(CoverageTransformer.java:83)
        ... 22 more
java.lang.instrument.IllegalClassFormatException: Error while instrumenting class org/gradle/logging/internal/DefaultStandardOutputRedirector$WriteAct
ion.
        at org.jacoco.agent.rt.internal_5d10cad.CoverageTransformer.transform(CoverageTransformer.java:91)
        at sun.instrument.TransformerManager.transform(TransformerManager.java:169)
        at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
        at org.gradle.util.FilteringClassLoader.loadClass(FilteringClassLoader.java:60)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at org.gradle.util.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:52)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at org.gradle.logging.internal.DefaultStandardOutputRedirector.<init>(DefaultStandardOutputRedirector.java:30)
        at org.gradle.api.internal.tasks.testing.junit.JULRedirector.<init>(JULRedirector.java:29)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestFramework$TestClassProcessorFactoryImpl.create(JUnitTestFramework.java:96)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.startReceivingTests(TestWorker.java:81)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:64)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:44)
        at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:78)
        at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:35)
        at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:81)
        at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:37)
        at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:43)
        at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:32)
        at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:46)
        at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:32)
        at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.run(GradleWorkerMain.java:32)
        at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.main(GradleWorkerMain.java:37)
Caused by: java.io.FileNotFoundException: build\jacoco\UT\classpathdumps\org\gradle\logging\internal\DefaultStandardOutputRedirector$WriteAction.class
(The requested operation cannot be performed on a file with a user-mapped section open)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:145)
        at org.jacoco.agent.rt.internal_5d10cad.ClassFileDumper.dump(ClassFileDumper.java:66)
        at org.jacoco.agent.rt.internal_5d10cad.CoverageTransformer.transform(CoverageTransformer.java:83)
        ... 34 more

2 个答案:

答案 0 :(得分:0)

好的,那很快。我在Gradle build.gradle文件中有以下测试{...}部分,它使用了classDumpPath设置(在我的末尾设置了自定义文件夹)。

   test {
     maxParallelForks = 5
     forkEvery = 50
     ignoreFailures = true

     testReportDir = file("$buildDir/reports/tests/UT")
     testResultsDir = file("$buildDir/test-results/UT")


     //Following Jacoco test section is required only in Jenkins instance extra common file
     jacoco {
        //The following vars works ONLY with 1.6 of Gradle
        destPath = file("$buildDir/jacoco/UT/jacocoUT.exec")
        classDumpPath = file("$buildDir/jacoco/UT/classpathdumps")

        //Following vars works only with versions >= 1.7 version of Gradle
        //destinationFile = file("$buildDir/jacoco/UT/jacocoUT.exec")
        //  classDumpFile = file("$buildDir/jacoco/UT/classpathdumps")
     }
   }

评论以下一行,做了伎俩。我稍后会研究它,为什么它解决了这个问题。

//--- classDumpPath = file("$buildDir/jacoco/UT/classpathdumps")

答案 1 :(得分:0)

我有同样的问题。帮助我的是更改JRE版本。 将其从15更改为14。