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

Continuous testing fails when a dependency brings in an optional dependency and a Jandex index #24943

Closed
bnazare opened this issue Apr 14, 2022 · 5 comments · Fixed by #25019
Closed
Labels
Milestone

Comments

@bnazare
Copy link

bnazare commented Apr 14, 2022

Describe the bug

When in a multi-module maven project, with a quarkus module A depending on a regular java module B. If module B contains both an optional dependecy (not declared by A too) and a Jandex index, then continuous testing fails with a BuildException.

It makes no difference whether the classes in B using the optional dependencies are used by the quarkus module or its tests.

Regular testing via maven still works correctly, though.

Expected behavior

Continuous testing should build and execute the tests.

Actual behavior

A BuildException is thrown:

[INFO] --- quarkus-maven-plugin:2.8.0.Final:test (default-cli) @ code-with-quarkus ---
[INFO] Invoking org.apache.maven.plugins:maven-resources-plugin:2.6:resources) @ code-with-quarkus
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Invoking io.quarkus.platform:quarkus-maven-plugin:2.8.0.Final:generate-code) @ code-with-quarkus
[INFO] Invoking org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile) @ code-with-quarkus
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/bnazare/Projects/quarkus-21226-reproducer/code-with-quarkus/target/classes
[INFO] Invoking org.apache.maven.plugins:maven-resources-plugin:2.6:testResources) @ code-with-quarkus
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/bnazare/Projects/quarkus-21226-reproducer/code-with-quarkus/src/test/resources
[INFO] Invoking io.quarkus.platform:quarkus-maven-plugin:2.8.0.Final:generate-code-tests) @ code-with-quarkus
[INFO] Invoking org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile) @ code-with-quarkus
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /home/bnazare/Projects/quarkus-21226-reproducer/code-with-quarkus/target/test-classes
[INFO] /home/bnazare/Projects/quarkus-21226-reproducer/code-with-quarkus/src/test/java/org/acme/NativeGreetingResourceIT.java: /home/bnazare/Projects/quarkus-21226-reproducer/code-with-quarkus/src/test/java/org/acme/NativeGreetingResourceIT.java uses or overrides a deprecated API that is marked for removal.
[INFO] /home/bnazare/Projects/quarkus-21226-reproducer/code-with-quarkus/src/test/java/org/acme/NativeGreetingResourceIT.java: Recompile with -Xlint:removal for details.
Listening for transport dt_socket at address: 5005
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2022-04-14 16:59:51,823 INFO  [io.qua.test] (main) Quarkus continuous testing mode started

2022-04-14 16:59:52,032 INFO  [io.qua.test] (Test runner thread) Running 1/1. Running: #JUnit Jupiter
2022-04-14 16:59:52,041 INFO  [io.qua.test] (Test runner thread) Running 1/1. Running: #JUnit Jupiter
2022-04-14 16:59:52,051 INFO  [io.qua.test] (Test runner thread) Running 1/1. Running: org.acme.GreetingResourceTest#GreetingResourceTest
2022-04-14 16:59:52,220 INFO  [org.jbo.threads] (Test runner thread) JBoss Threads version 3.4.2.Final
2022-04-14 16:59:52,684 INFO  [io.qua.test] (Test runner thread) Running 1/1. Running: org.acme.GreetingResourceTest#testHelloEndpoint()
2022-04-14 16:59:52,690 ERROR [io.qua.test] (Test runner thread) ==================== TEST REPORT #1 ====================
2022-04-14 16:59:52,691 ERROR [io.qua.test] (Test runner thread) Test GreetingResourceTest#testHelloEndpoint() failed 
: java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.deployment.steps.ClassTransformingBuildStep#handleClassTransformation threw an exception: java.lang.IllegalStateException: java.util.concurrent.ExecutionException: java.lang.TypeNotPresentException: Type com/itextpdf/text/DocumentException not present
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:934)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.util.concurrent.ExecutionException: java.lang.TypeNotPresentException: Type com/itextpdf/text/DocumentException not present
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep.handleClassTransformation(ClassTransformingBuildStep.java:234)
        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 io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:925)
        ... 6 more

(the stack trace goes on for around 300 lines, but this is the most relevant part)

How to Reproduce?

Reproducer: https://github.com/linkareti/quarkus-optional-dep-test-issue-reproducer

Steps to reproduce the behaviour:

  1. run mvn clean install in the project's root
  2. change to folder code-with-quarkus
  3. run mvn clean quarkus:test

Output of uname -a or ver

Linux [...] 5.16.18-200.fc35.x86_64 #1 SMP PREEMPT Mon Mar 28 14:10:07 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment 18.9 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.14.1+1, mixed mode, sharing)

GraalVM version (if different from Java)

n/a

Quarkus version or git rev

2.8.0.Final, but I've seen the issue since 2.6.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /home/bnazare/tools/apache-maven-3.8.1
Java version: 11.0.14.1, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.14.1.1-5.fc35.x86_64
Default locale: pt_PT, platform encoding: UTF-8
OS name: "linux", version: "5.16.18-200.fc35.x86_64", arch: "amd64", family: "unix"

Additional information

No response

@bnazare bnazare added the kind/bug Something isn't working label Apr 14, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 14, 2022

/cc @stuartwdouglas

@stuartwdouglas
Copy link
Member

I don't know if there is much we can do here. This happens because you have an application class (i.e. one in the same maven project), that is referencing a missing dependency. Continuous testing will attempt to transform this class to do usage tracing, so we know what tests we need to run if it is modified.

For now you can work around it by moving this code into a different project, so it is not considered hot replaceable and won't be instrumented.

@bnazare
Copy link
Author

bnazare commented Apr 19, 2022

@stuartwdouglas, I wanted to make sure this issue was signalled but if it's something that can't be fixed than I can workaround it without much problem. That said, I feel that this might be a not-so-uncommon issue (particularly for people migrating older projects to Quarkus) so I think it should at least be shown in the documentation as a known limitation. Maybe here, where the Jandex plugin is described or in the continuous testing guide.

Workaround wise, I use a slightly less intrusive one than the one you suggest, I just add the optional dependency to the quarkus module in the test scope.

@stuartwdouglas
Copy link
Member

The linked PR should help.

@SHAX1PTb
Copy link

The live testing is not reloading changes!!

@quarkus-bot quarkus-bot bot added this to the 2.9 - main milestone Apr 20, 2022
@gsmet gsmet modified the milestones: 2.9 - main, 2.8.2.Final Apr 24, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants