payara / Payara

Payara Server is an open source middleware platform that supports reliable and secure deployments of Java EE (Jakarta EE) and MicroProfile applications in any environment: on premise, in the cloud or hybrid.
http://www.payara.fish
Other
882 stars 306 forks source link

Bug Report: Deployment crash when Hibernate 6.2 is used/FISH-7338 #6248

Open ctabin opened 1 year ago

ctabin commented 1 year ago

Brief Summary

Hello,

We just upgraded our persistence library from Hibernate 6.1.7 to 6.2.0. With this new version, our application crashes during the deployment with a lifecycle error:

SEVERE: Exception during lifecycle processing
java.lang.ClassCircularityError: org/hibernate/bytecode/enhance/spi/EnhancementContextWrapper
        at org.hibernate.jpa.internal.enhance.EnhancingClassTransformerImpl.transform(EnhancingClassTransformerImpl.java:50)
        at org.glassfish.persistence.jpa.ServerProviderContainerContractInfo$1.transform(ServerProviderContainerContractInfo.java:101)
        at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:734)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
        at com.sun.enterprise.loader.CurrentBeforeParentClassLoader.loadClass(CurrentBeforeParentClassLoader.java:83)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:166)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1380)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1451)
        at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:142)
        at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:207)
        at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:114)
        at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:267)
        at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:571)
        at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:286)
        at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:183)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:1197)
        at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:301)
        at org.glassfish.javaee.full.deployment.EarDeployer.lambda$prepare$0(EarDeployer.java:164)
        at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:221)
        at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:233)
        at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:259)
        at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:162)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:1197)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.prepare(ApplicationLifecycle.java:511)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:612)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:556)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:552)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/javax.security.auth.Subject.doAs(Subject.java:376)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:551)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:582)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:574)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/javax.security.auth.Subject.doAs(Subject.java:376)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:573)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1497)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1869)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1755)
        at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:131)

This has been reported in Hibernate in HHH-16299, but it seems related to Payara/GlassFish (there is a reproducer here).

It seems to be related to this PR and the variable hibernate.bytecode.provider, but even when forcing it to none in persistence.xml the same error occurs.

Environment

Expected Outcome

Application should deploy as normally.

Current Outcome

Crash with java.lang.ClassCircularityError.

Reproducer

https://github.com/grommitz/hibernate-deployment-issue-reproducer

Operating System

Linux Debian

JDK Version

JDK 17

Payara Distribution

Payara Embedded All

monish-byte commented 1 year ago

hey @ctabin I am a beginner contributer. Can you assign this issue to me and guide me through it? thank you.

ctabin commented 1 year ago

Hi @monish-byte, Unfortunately I can't help about it, I'm also just a contributor not part of Payara/GlassFish and without any access to the repository. Probably @shub8968 can assign this issue to whomever can handle it.

ctabin commented 1 year ago

FYI the problem is still present with the Hibernate 6.2.1.Final and payara-embedded-all 6.2023.3.

grommitz commented 1 year ago

@shub8968 any news on this? It is a complete blocker to payara 6 adoption for us.

shub8968 commented 1 year ago

Hi @ctabin @grommitz

I have escalated this issue to the platform development team as FISH-7338

shub8968 commented 1 year ago

Hi @monish-byte

Refer to our blog on how to contribute to Payara - https://blog.payara.fish/how-to-contribute-to-payara-server

ctabin commented 1 year ago

FYI the problem is still present with Hibernate 6.2.2.Final and payara-embedded-all 6.2023.4.

ctabin commented 1 year ago

FYI here is a hint to circumvent this problem and allow the application to be deployed.

Note that the entities need to be enhanced during the compilation then.

grommitz commented 1 year ago

Thanks @ctabin that worked for me (Hibernate 6.2.2, Payara Micro 6.2023.4)

ctabin commented 1 year ago

This issue hast just been resolved in GlassFish with this PR.

ctabin commented 1 year ago

Since this issue is still open in GlassFish, I've create a project to reproduce the problem also on Payara.

igorvsd commented 2 months ago

Is there any plans to fix this? Already a year passed after issue reported and it's still not fixed. Confirming to fail the same way on Payara 6.2024.7 and Hibernate 6.5.2.Final

Is there any workaround to temporary fix it in payara?

We've to downgrade Hibernate to 6.1.7.Final for now (this version hit end-of-life already)