intellij-platform-gradle-plugin
intellij-platform-gradle-plugin copied to clipboard
1.14.2-SNAPSHOT: `NoSuchMethodError` after updating from 1.13.1
I updated my build from 1.13.1 to 1.14.2-SNAPSHOT. With the updates version, a test is always failing now. The test is passing with 1.13.1 (for several weeks already).
The test is located in a Gradle submodule, which has these additional dependencies in gradle.build.kts:
dependencies {
testImplementation("org.testcontainers:testcontainers:1.18.3") {
exclude(group = "com.fasterxml.jackson.core", module = "jackson-annotations")
}
testImplementation("org.apache.sshd:apache-sshd:2.10.0") {
exclude(group = "org.slf4j", module = "slf4j-jdk14")
exclude(group = "org.apache.sshd", module = "sshd-netty")
exclude(group = "org.apache.sshd", module = "sshd-mina")
}
}
The configured IDE build IU-2022.1.
I'm not sure what you need to debug this, but I'll gladly provide more details when needed.
Exception with 1.14.2-SNAPSHOT:
java.lang.NoSuchMethodError: 'java.lang.Integer com.github.dockerjava.api.command.LogContainerCmd.getUntil()'
at org.testcontainers.shaded.com.github.dockerjava.core.exec.LogContainerCmdExec.execute0(LogContainerCmdExec.java:35)
at org.testcontainers.shaded.com.github.dockerjava.core.exec.LogContainerCmdExec.execute0(LogContainerCmdExec.java:12)
at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrAsyncDockerCmdExec.execute(AbstrAsyncDockerCmdExec.java:56)
at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrAsyncDockerCmdExec.exec(AbstrAsyncDockerCmdExec.java:21)
at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrAsyncDockerCmdExec.exec(AbstrAsyncDockerCmdExec.java:12)
at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrAsyncDockerCmd.exec(AbstrAsyncDockerCmd.java:21)
at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:38)
at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:964)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:490)
at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
at org.testcontainers.utility.RyukResourceReaper.maybeStart(RyukResourceReaper.java:78)
at org.testcontainers.utility.RyukResourceReaper.init(RyukResourceReaper.java:42)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:229)
at org.testcontainers.DockerClientFactory$1.getDockerClient(DockerClientFactory.java:104)
at com.github.dockerjava.api.DockerClientDelegate.authConfig(DockerClientDelegate.java:109)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:321)
at pro.bashsupport.shell.runConfig.RemoteUtilsKt.launchDockerContainer(remoteUtils.kt:64)
at pro.bashsupport.shell.runConfig.AbstractRemoteExecutionTest.setUp(AbstractRemoteExecutionTest.kt:42)
at com.intellij.testFramework.UsefulTestCase.invokeSetUp(UsefulTestCase.java:476)
at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:468)
at com.intellij.testFramework.UsefulTestCase.runBare(UsefulTestCase.java:544)
at com.intellij.testFramework.UsefulTestCase$1.evaluate(UsefulTestCase.java:153)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
I tried to reproduce it but with no luck — can you please prepare a minimal setup for that case?
You have a dependency to org.testcontainers:testcontainers:1.18.3 added in your module (a blue one on the screenshot).
Then, the Docker plugin defined in intellij.plugins is applied to the module. The Docker plugin archive is actually added to the z50_ideaPlugins configuration, so it's not interfering with your testImplementation. Eventually, testImplementation configuration is extended with z50_ideaPlugins, and dependencies get merged (red entry on the screenshot).
The Docker plugin contains a bundled com.github.docker-java:docker-java-api:xxx dependency in a pretty old version — however, it's still placed below org.testcontainers:testcontainers:1.18.3.
Eventually, Gradle resolves transitive dependencies of testcontainers and put them at the end of the list. One of them is org.testcontainers:testcontainers:1.18.3 you expect to use but gets shadowed with Docker's one. (green entry).
As a workaround, you can add an explicit dependency to org.testcontainers:testcontainers:1.18.3 in your dependencies {} setup:
dependencies {
testImplementation("org.apache.sshd:apache-sshd:2.10.0") {
exclude(group = "org.slf4j", module = "slf4j-jdk14")
exclude(group = "org.apache.sshd", module = "sshd-netty")
exclude(group = "org.apache.sshd", module = "sshd-mina")
}
testImplementation("org.testcontainers:testcontainers:1.18.3") {
exclude(group = "com.fasterxml.jackson.core", module = "jackson-annotations")
}
implementation("com.github.docker-java:docker-java-api:3.3.0")
}
With this approach, docker-java-api is placed right below testcontainers.
A note to self — to reproduce the issue, it's enough to put the following code in any class:
(null as LogContainerCmd?)?.getUntil()If a dependency from the
DockerPlugin is resolved,getUntil()is not available.
With the IntelliJ Platform Gradle Plugin 2.0, it is now possible to define the exact order of dependencies — IntelliJ Platform, plugins, and "regular" Maven dependencies. See: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html