Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading au.com.dius.pact.provider:junit5 from 4.3.14 to 4.3.15 results in failure #1615

Closed
edeandrea opened this issue Oct 3, 2022 · 7 comments

Comments

@edeandrea
Copy link

edeandrea commented Oct 3, 2022

I have a project using the au.com.dius.pact.provider:junit5 artifact for running verification tests. When I upgrade the dependency from version 4.3.14 to 4.3.15 the tests no longer run and result in a failure with ANTLR:

ANTLR Tool version 4.11.1 used for code generation does not match the current runtime version 4.9.2
ANTLR Runtime version 4.11.1 used for parser compilation does not match the current runtime version 4.9.2
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.884 s <<< FAILURE! - in io.quarkus.sample.superheroes.villain.ContractVerificationTests
[ERROR] io.quarkus.sample.superheroes.villain.ContractVerificationTests.pactVerificationTestTemplate(PactVerificationContext)  Time elapsed: 8.88 s  <<< ERROR!
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
        at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:44)
        at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:84)
        at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:45)
        at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:106)
        at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:110)
        at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:44)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
        at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
        at org.apache.maven.surefire.junitplatform.LazyLauncher.execute(LazyLauncher.java:55)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:223)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:175)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:139)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:456)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:169)
        at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:595)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:581)
Caused by: java.lang.ExceptionInInitializerError
        at au.com.dius.pact.core.support.Version.parse(Version.java:79)
        at au.com.dius.pact.core.model.DefaultPactReader.pactFromJson(PactReader.kt:219)
        at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:214)
        at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:268)
        at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:130)
        at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$pactSources$1$pacts$1.invoke(PactJUnit5VerificationProvider.kt:84)
        at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:39)
        ... 61 more
Caused by: java.lang.UnsupportedOperationException: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 4 (expected 3).
        at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:187)
        at au.com.dius.pact.core.support.VersionLexer.<clinit>(VersionLexer.java:121)
        ... 68 more
Caused by: java.io.InvalidClassException: org.antlr.v4.runtime.atn.ATN; Could not deserialize ATN with version 4 (expected 3).
        ... 70 more

08:19:16 INFO  [io.qu.sa.su.vi.VillainApplicationLifeCycle] (main) The application VILLAIN is stopping...
08:19:16 INFO  [io.quarkus] (main) rest-villains stopped in 0.019s
[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   ContractVerificationTests.pactVerificationTestTemplate(PactVerificationContext) » Runtime java.lang.ExceptionInInitializerError
[INFO] 
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
@holly-cummins
Copy link
Contributor

I am able to work around the issue with the following maven incantation, but it's not obvious to me why it's necessary. In my project's dependency management section, I need to exclude antlr4-runtime from being pulled in by pact, and explicitly include the 4.11.1 version of the dependency:

     <dependency>
        <groupId>au.com.dius.pact.core</groupId>
        <artifactId>support</artifactId>
        <version>${pact.version}</version>
        <exclusions>
          <exclusion>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>org.antlr</groupId>
        <artifactId>antlr4-runtime</artifactId>
        <version>4.11.1</version>
      </dependency>
    </dependencies>

@edeandrea
Copy link
Author

Anyone have any insights into this?

@holly-cummins
Copy link
Contributor

I think this may be Quarkus-specific. It seems similar to #1380, except in the other direction (Quarkus's pact is too old, rather than too new). I'm also looking at quarkusio/quarkus#27298, which is a Quarkus PR to upgrade Antlr from 4.9.2 to a higher version. There's some discussion of Pact on that work item.

I've raised quarkiverse/quarkus-pact#1 to track what changes a Pact Quarkus extension could do to fix this.

@rholshausen
Copy link
Contributor

I'm going to have to remove Antlr from Pact-JVM (which is sad, as it is a great tool), but that will allow the Pact-JVM libs to be used in any project that also uses Antlr.

@holly-cummins
Copy link
Contributor

I agree, it's sad. It seems like it might a somewhat common issue, so replacing Antlr may be the pragmatic solution.

Other solutions are:

  • Everyone starts using OSGi to avoid classpath leakage (not going to happen, realistically :) )
  • Various combinations of shaded jars and maven excludes so that projects which depend on Pact bring in a version with Antlr stripped out, and then use the Antlr that's already on the classpath. I think that would work, but it ends up being work for whatever consumes Pact, which isn't ideal. (We could do it for the Quarkus Pact extension so anyone using Quarkus would just use the extension and have it pre-done, but that only helps for the Quarkus case.)

@rholshausen
Copy link
Contributor

Version 4.3.16 released

@edeandrea
Copy link
Author

Thank you @rholshausen

I can confirm (via quarkusio/quarkus-super-heroes#173 and quarkusio/quarkus-super-heroes#174) that the issue is resolved with the upgrade to 4.3.16.

Thanks for the quick turnaround!

@holly-cummins ^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants