quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

BuildException on Start when using hibernate orm & h2 #15612

Closed rosariop closed 3 years ago

rosariop commented 3 years ago

Describe the bug When starting the app, following stacktrace get's thrown:

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: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class de.polito.entity.PickupEntry
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:929)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at java.base/java.lang.Thread.run(Thread.java:834)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.util.concurrent.ExecutionException: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class de.polito.entity.PickupEntry
        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:196)
        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$2.execute(ExtensionLoader.java:920)
        ... 5 more
Caused by: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class de.polito.entity.PickupEntry
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(EnhancerImpl.java:138)
        at io.quarkus.hibernate.orm.deployment.HibernateEntityEnhancer$HibernateEnhancingClassVisitor.hibernateEnhancement(HibernateEntityEnhancer.java:85)
        at io.quarkus.hibernate.orm.deployment.HibernateEntityEnhancer$HibernateEnhancingClassVisitor.visitEnd(HibernateEntityEnhancer.java:78)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:715)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:394)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep.transformClass(ClassTransformingBuildStep.java:214)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep.access$000(ClassTransformingBuildStep.java:40)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep$2.call(ClassTransformingBuildStep.java:172)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep$2.call(ClassTransformingBuildStep.java:159)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.UnsupportedOperationException
        at net.bytebuddy.jar.asm.ClassVisitor.visitNestMemberExperimental(ClassVisitor.java:248)
        at net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:651)
        at net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:391)
        at net.bytebuddy.pool.TypePool$Default.parse(TypePool.java:1051)
        at net.bytebuddy.pool.TypePool$Default.doDescribe(TypePool.java:1035)
        at net.bytebuddy.pool.TypePool$Default$WithLazyResolution.access$401(TypePool.java:1115)
        at net.bytebuddy.pool.TypePool$Default$WithLazyResolution.doResolve(TypePool.java:1190)
        at net.bytebuddy.pool.TypePool$Default$WithLazyResolution$LazyTypeDescription.delegate(TypePool.java:1252)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase$OfSimpleType$WithDelegation.getSuperClass(TypeDescription.java:7051)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase.isAssignable(TypeDescription.java:6563)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase.isAssignableTo(TypeDescription.java:6596)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase.isAssignableTo(TypeDescription.java:6591)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.collectCollectionFields(EnhancerImpl.java:415)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.doEnhance(EnhancerImpl.java:189)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.lambda$enhance$0(EnhancerImpl.java:132)
        at org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.rewrite(ByteBuddyState.java:146)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(EnhancerImpl.java:132)
        ... 12 more

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:308)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:182)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:59)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:79)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:378)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:56)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:127)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:84)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:144)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
Caused by: 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: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class de.polito.entity.PickupEntry
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:929)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at java.base/java.lang.Thread.run(Thread.java:834)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.util.concurrent.ExecutionException: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class de.polito.entity.PickupEntry
        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:196)
        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$2.execute(ExtensionLoader.java:920)
        ... 5 more
Caused by: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class de.polito.entity.PickupEntry
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(EnhancerImpl.java:138)
        at io.quarkus.hibernate.orm.deployment.HibernateEntityEnhancer$HibernateEnhancingClassVisitor.hibernateEnhancement(HibernateEntityEnhancer.java:85)
        at io.quarkus.hibernate.orm.deployment.HibernateEntityEnhancer$HibernateEnhancingClassVisitor.visitEnd(HibernateEntityEnhancer.java:78)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:715)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:394)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep.transformClass(ClassTransformingBuildStep.java:214)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep.access$000(ClassTransformingBuildStep.java:40)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep$2.call(ClassTransformingBuildStep.java:172)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep$2.call(ClassTransformingBuildStep.java:159)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.UnsupportedOperationException
        at net.bytebuddy.jar.asm.ClassVisitor.visitNestMemberExperimental(ClassVisitor.java:248)
        at net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:651)
        at net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:391)
        at net.bytebuddy.pool.TypePool$Default.parse(TypePool.java:1051)
        at net.bytebuddy.pool.TypePool$Default.doDescribe(TypePool.java:1035)
        at net.bytebuddy.pool.TypePool$Default$WithLazyResolution.access$401(TypePool.java:1115)
        at net.bytebuddy.pool.TypePool$Default$WithLazyResolution.doResolve(TypePool.java:1190)
        at net.bytebuddy.pool.TypePool$Default$WithLazyResolution$LazyTypeDescription.delegate(TypePool.java:1252)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase$OfSimpleType$WithDelegation.getSuperClass(TypeDescription.java:7051)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase.isAssignable(TypeDescription.java:6563)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase.isAssignableTo(TypeDescription.java:6596)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase.isAssignableTo(TypeDescription.java:6591)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.collectCollectionFields(EnhancerImpl.java:415)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.doEnhance(EnhancerImpl.java:189)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.lambda$enhance$0(EnhancerImpl.java:132)
        at org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.rewrite(ByteBuddyState.java:146)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(EnhancerImpl.java:132)
        ... 12 more

        at io.quarkus.builder.Execution.run(Execution.java:116)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:153)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:306)
        ... 9 more
Caused by: java.lang.IllegalStateException: java.util.concurrent.ExecutionException: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class de.polito.entity.PickupEntry
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:929)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at java.base/java.lang.Thread.run(Thread.java:834)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.util.concurrent.ExecutionException: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class de.polito.entity.PickupEntry
        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:196)
        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$2.execute(ExtensionLoader.java:920)
        ... 5 more
Caused by: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class de.polito.entity.PickupEntry
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(EnhancerImpl.java:138)
        at io.quarkus.hibernate.orm.deployment.HibernateEntityEnhancer$HibernateEnhancingClassVisitor.hibernateEnhancement(HibernateEntityEnhancer.java:85)
        at io.quarkus.hibernate.orm.deployment.HibernateEntityEnhancer$HibernateEnhancingClassVisitor.visitEnd(HibernateEntityEnhancer.java:78)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:715)
        at org.objectweb.asm.ClassReader.accept(ClassReader.java:394)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep.transformClass(ClassTransformingBuildStep.java:214)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep.access$000(ClassTransformingBuildStep.java:40)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep$2.call(ClassTransformingBuildStep.java:172)
        at io.quarkus.deployment.steps.ClassTransformingBuildStep$2.call(ClassTransformingBuildStep.java:159)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.UnsupportedOperationException
        at net.bytebuddy.jar.asm.ClassVisitor.visitNestMemberExperimental(ClassVisitor.java:248)
        at net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:651)
        at net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:391)
        at net.bytebuddy.pool.TypePool$Default.parse(TypePool.java:1051)
        at net.bytebuddy.pool.TypePool$Default.doDescribe(TypePool.java:1035)
        at net.bytebuddy.pool.TypePool$Default$WithLazyResolution.access$401(TypePool.java:1115)
        at net.bytebuddy.pool.TypePool$Default$WithLazyResolution.doResolve(TypePool.java:1190)
        at net.bytebuddy.pool.TypePool$Default$WithLazyResolution$LazyTypeDescription.delegate(TypePool.java:1252)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase$OfSimpleType$WithDelegation.getSuperClass(TypeDescription.java:7051)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase.isAssignable(TypeDescription.java:6563)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase.isAssignableTo(TypeDescription.java:6596)
        at net.bytebuddy.description.type.TypeDescription$AbstractBase.isAssignableTo(TypeDescription.java:6591)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.collectCollectionFields(EnhancerImpl.java:415)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.doEnhance(EnhancerImpl.java:189)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.lambda$enhance$0(EnhancerImpl.java:132)
        at org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.rewrite(ByteBuddyState.java:146)
        at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(EnhancerImpl.java:132)
        ... 12 more

Expected behavior I exptected that quarkus generates my database table and starts the server.

Actual behavior (Describe the actual behavior clearly and concisely.)

To Reproduce mvn dependencies:

    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-hibernate-orm</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-jdbc-h2</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-agroal</artifactId>
    </dependency>

entity:

@Entity
public class PickupEntry {

    @Id
    @GeneratedValue
    Long id;

    Date timestamp;
//getters and setters
}

Environment: using mvnw 3.6.3

quarkus-bot[bot] commented 3 years ago

/cc @Sanne, @gsmet, @yrodiere

gsmet commented 3 years ago

Please provide the information that are requested in this template: https://github.com/quarkusio/quarkus/issues/new?assignees=&labels=kind%2Fbug&template=bug_report.md&title= .

There's no way we will be able to help with so little information.

Thanks.

rosariop commented 3 years ago

oh sure, sorry. My english is really bad. I build a example repository you can checkout and try to reproduce the error yourself if this helps? https://github.com/rosariop/Quarkus-Hibernate-Orm-Error

Describe the bug When starting quarkus it throws the exception mentioned by my first posting.

Expected behavior Quarkus starting and Hibernate beeing able to persist my created entity by using the entitymanager

Actual behavior Throwing exception

To Reproduce https://github.com/rosariop/Quarkus-Hibernate-Orm-Error running it via quarkus devtools vs-code

Configuration

quarkus.datasource.db-kind=h2
quarkus.datasource.username=admin
quarkus.datasource.password=admin
quarkus.datasource.jdbc.url=jdbc:h2:mem:default
quarkus.hibernate-orm.database.generation=drop-and-create

Environment (please complete the following information):

I hope that will help @gsmet. Thanks for your time!

Sanne commented 3 years ago

The problem is caused by the dependency to Selenium. Apparently it's depending on an old version of ByteBuddy, while Hibernate ORM requires version 1.10.21.

Sanne commented 3 years ago

Thanks, it's an interesting case @rosariop . So technically the problem is just wrong dependencies being used, but we need to improve the detection of this case and improve the error messages such situations produce.

I'll open a new issue

rosariop commented 3 years ago

Would be cool to know what dependencies are wrong and what are right. I tried to stay JEE compatible when using the EntityManager but only found Sprint JPA guides on the Interwebs

Sanne commented 3 years ago

@rosariop I agree. Opened https://github.com/quarkusio/quarkus/issues/15635 to make sure Quarkus can give better suggestions and error messages in the future.

In your case, just add this to your pom.xml

    <dependency>
      <groupId>net.bytebuddy</groupId>
      <artifactId>byte-buddy</artifactId>
      <version>1.10.21</version>
    </dependency>