Quarkus: ClassNotFoundException at Hibernate ORM ProxyBuildingHelper

Created on 16 Jul 2020  路  6Comments  路  Source: quarkusio/quarkus

Describe the bug
Hello everyone,

I have a Maven multi-module project where Module A declares an "AbstractEntity" and in the Quarkus app an entity extending it. Module A has the Jandex plugin configured and AbstractEntity is annotated. During the Maven build the Quarkus plugin is throwing an ClassNotFoundException for the entity on Hibernate ProxyBuildingHelper.

PS D:\projects\quarkus-issue> mvn clean package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] _master [pom]
[INFO] external [jar]
[INFO] app [war]
[INFO]
[INFO] --------------< org.github.cpoels.quarkus.issue:_master >---------------
[INFO] Building _master 1.0.0-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ _master ---
[INFO]
[INFO] --------------< org.github.cpoels.quarkus.issue:external >--------------
[INFO] Building external 1.0.0-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ external ---
[INFO] Deleting D:\projects\quarkus-issue\external\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ external ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ external ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\projects\quarkus-issue\external\target\classes
[INFO]
[INFO] --- jandex-maven-plugin:1.0.7:jandex (make-index) @ external ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ external ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\projects\quarkus-issue\external\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ external ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ external ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ external ---
[INFO] Building jar: D:\projects\quarkus-issue\external\target\external-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] ----------------< org.github.cpoels.quarkus.issue:app >-----------------
[INFO] Building app 1.0.0-SNAPSHOT [3/3]
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ app ---
[INFO] Deleting D:\projects\quarkus-issue\app\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\projects\quarkus-issue\app\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\projects\quarkus-issue\app\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ app ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ app ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ app ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/C:/Users/Chris%20Beistal/.m2/repository/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar) to field java.util.Properties.defaults
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Packaging webapp
[INFO] Assembling webapp [app] in [D:\projects\quarkus-issue\app\target\app-1.0.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in [297 msecs]
[INFO] Building war: D:\projects\quarkus-issue\app\target\app-1.0.0-SNAPSHOT.war
[INFO]
[INFO] --- quarkus-maven-plugin:1.6.0.Final:build (default) @ app ---
[INFO] [org.jboss.threads] JBoss Threads version 3.1.1.Final
[WARNING] [io.quarkus.agroal.deployment.AgroalProcessor] The Agroal dependency is present but no JDBC datasources have been defined.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for _master 1.0.0-SNAPSHOT:
[INFO]
[INFO] _master ............................................ SUCCESS [ 0.390 s]
[INFO] external ........................................... SUCCESS [ 3.247 s]
[INFO] app ................................................ FAILURE [ 10.410 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.823 s
[INFO] Finished at: 2020-07-16T20:45:36+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.6.0.Final:build (default) on project app: Failed to build quarkus application:
io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] at io.quarkus.hibernate.orm.deployment.ProxyBuildingHelper.uninitializedClass(ProxyBuildingHelper.java:42)
[ERROR] at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.generatedProxies(HibernateOrmProcessor.java:409)
[ERROR] at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.pregenProxies(HibernateOrmProcessor.java:300)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR] at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:932)
[ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR] at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] Caused by: java.lang.ClassNotFoundException: org.github.cpoels.quarkus.issue.app.Project
[ERROR] at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:398)
[ERROR] at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:333)
[ERROR] at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:396)
[ERROR] at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:333)
[ERROR] at java.base/java.lang.Class.forName0(Native Method)
[ERROR] at java.base/java.lang.Class.forName(Class.java:398)
[ERROR] at io.quarkus.hibernate.orm.deployment.ProxyBuildingHelper.uninitializedClass(ProxyBuildingHelper.java:40)
[ERROR] ... 14 more
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :app

I dont know if I am missing something but this is working using Quarkus 1.3.0.Final. I cannot reproduce for versions between 1.3.0 and 1.6.0 because I am getting some other weird errors.
Maybe I am missing something but I dont get it for now. Any help and clarifications are appreciated :)

Best regards,
Christoph

Expected behavior
Should work as in version 1.3.0.Final.

Actual behavior
See excecption above.

To Reproduce
Steps to reproduce the behavior:

  1. Little reproducer at https://github.com/cpoels/quarkus-issue
  2. mvn clean package

Configuration

quarkus.datasource.db-kind = h2
quarkus.datasource.username = sa
quarkus.datasource.password = sa
quarkus.datasource.jdbc.url = jdbc:h2:~/.h2/quarkus-issue
quarkus.hibernate-orm.database.generation = drop-and-create

Screenshots

Environment (please complete the following information):

openjdk version "11.0.6" 2020-01-14 LTS
OpenJDK Runtime Environment Zulu11.37+17-CA (build 11.0.6+10-LTS)
OpenJDK 64-Bit Server VM Zulu11.37+17-CA (build 11.0.6+10-LTS, mixed mode)

Quarkus 1.6.0.Final

Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)
Maven home: D:\tools\apache-maven-3.6.2\bin\..
Java version: 11.0.6, vendor: Azul Systems, Inc., runtime: D:\java\jdk11.37.17
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
arehibernate-orm arepersistence kinbug triaginvalid

Most helpful comment

nice catch @famod , and thanks @cpoels for reporting this.
Opened #10807 as a possible follow-up

All 6 comments

/cc @gsmet, @Sanne

Hm, <packaging>war</packaging> is a bit uncommon for a Quarkus application.
Can you try without packaging (=jar)?

<packaging>jar</packaging> fixed it. Thanks a lot.

I feel a little bit uncomfortable now that I bothered you with this issue, because I could have compared it with the Quarkus Quickstarts ...
But maybe can you explain why it's uncommon? Okay, it's obsolete to build it because it's not used anyway, but is there any other reason than this?

<packaging>jar</packaging> fixed it. Thanks a lot.

Excellent! Thanks for your feedback.

I feel a little bit uncomfortable now that I bothered you with this issue, because I could have compared it with the Quarkus Quickstarts ...

No worries! That's what the community is for.

But maybe can you explain why it's uncommon? Okay, it's obsolete to build it because it's not used anyway, but is there any other reason than this?

Well, it is simply unnecessary/misleading since the Quarkus build plugin is creating its own custom jar which _has_ to be used to run the Quarkus application.
You wouldn't be able to use the war-file in a common appserver or servlet container anyway.

Maybe @aloubyansky can add some details why it fails like this but as I outlined above it just doesn't make sense for the Quarkus bootstrapping to consider war-packaging.

nice catch @famod , and thanks @cpoels for reporting this.
Opened #10807 as a possible follow-up

You are welcome.
I also gave my two cents to your follow-up issue. Could be one way I can imagine.

Was this page helpful?
0 / 5 - 0 ratings