jitpack / jitci

A CI with tests, coverage, dependency audit, license & vuln. checks
https://jitci.com
19 stars 5 forks source link

JUnit: CannotCompileException: cannot find org.junit.platform.launcher.Launcher #4

Open matshou opened 5 years ago

matshou commented 5 years ago

I've just discovered and started using JitCI since I am already using JitPack to host my artifacts I thought I might as well use your CI service to have it all in one place.

The builds themselves seem to produce healthy artifacts and test are being executed correctly, however there is this quite concerning exception that keeps being thrown by every build:

Exception Stack Trace
        
ext.javassist.CannotCompileException: cannot find org.junit.platform.launcher.Launcher
    at ext.javassist.CtBehavior.insertAfter(CtBehavior.java:906)
    at ext.javassist.CtBehavior.insertAfter(CtBehavior.java:824)
    at jitci.agent.Instrumenter.instrumentCall(Instrumenter.kt:41)
    at jitci.agent.junit.JUnitTransformer.transform(JUnitTransformer.kt:35)
    at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:100)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:82)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:78)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
    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:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:132)
    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:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:748)
Caused by: ext.javassist.NotFoundException: org.junit.platform.launcher.Launcher
    at ext.javassist.ClassPool.get(ClassPool.java:422)
    at ext.javassist.bytecode.Descriptor.toCtClass(Descriptor.java:571)
    at ext.javassist.bytecode.Descriptor.getReturnType(Descriptor.java:472)
    at ext.javassist.CtBehavior.getReturnType0(CtBehavior.java:331)
    at ext.javassist.CtBehavior.insertAfter(CtBehavior.java:858)
    ... 45 more
        
  

I've did a bit of experimenting and found out that it's caused by adding this method to the test task:

Note that I've not tried configuring JUnit specific options, I only know that the exception is throws when no arguments are used. As I've said, for now everything works fine but I do think this matter should be looked into because it might cause problems down the road.

jitpack-io commented 5 years ago

Hi @yooksi ,

Thank you for the detailed report! This will help us track down the issue

matshou commented 5 years ago

@jitpack-io The builds have started to fail due to this exception as is evident by looking at builds 43-47. However the same branch builds fine on both Travis-CI and Xubuntu 18.04.2.

As of now I either have to exclude tests (which is a key part of CI services) or use another CI provider which is something I would not like to do. I hope you are able to resolve this issue in the near future.

jitpack-io commented 5 years ago

We have identified the issue and are working on a fix. As a workaround, adding junit platform launcher to dependencies solves the issue:

     testRuntime 'org.junit.platform:junit-platform-launcher:1.5.0'
jitpack-io commented 5 years ago

Hi @yooksi,

This issue should be fixed now. Sorry about the interruption