Closed irizzant closed 1 year ago
@irizzant The Jakarta version of Hypersistence Optimizer works from Hibernate 6 onwards, which uses Java 11.
The JBoss EAP 7.3 is Java EE 8 compliant as stated by the docs:
JBoss EAP 7.3 is a certified implementation of the Java EE 8 Full Platform and the Web Profile specifications.
See Java™ EE 8 Technologies for the complete list of Java ™ EE 8 APIs.
So you should use the standard Hypersistence Optimizer with the JPA 2.2 and Hibernate 5.3 that's built for Java EE. Why are you using it with Jakarta Persistence?
@vladmihalcea thanks for the update.
I used the Jakarta version because the installation doc reports: 4.1. Jakarta Persistence If your application is running with Jakarta Persistence, you should use the 2.6.3-jakarta dependency version.
It doesn't mention that it works for Hibernate 6 onwards.
I replaced the dependency with:
`
`
and the application server starts correctly but I don't see anything in the logs, which I suppose it's because I have to instantiate HypersistenceOptimizer as reported in the installation instructions: Step 6: Instantiating HypersistenceOptimizer
Given I'm using Java EE, should I use the following approach?
new HypersistenceOptimizer( new JpaConfig( getEntityManagerFactory() ) );
Thanks
@irizzant The compatibility matrix shows you how the Hypersistence Optimizer versions relate to Hibernate and JPA versions.
Using the JpaConfig is the way to go, yes.
@vladmihalcea ok then I instantiated the Hypersistence Optimizer like this:
new HypersistenceOptimizer( new JpaConfig( myFactory ) );
and now when the application starts I get some logs from the tool, but I start getting:
20230331_093248_824 ERROR #[[default task-2@srv=wms-f9bb87b48-98js8]]# #[[org.hibernate.internal.ExceptionMapperStandardImpl]]# HHH000346: Error during managed flush [org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions. Collection : [it.sdb.apps.crmtrk.data.archive.db.Country.states#IT]] 20230331_093248_826 WARN #[[default task-2@srv=wms-f9bb87b48-98js8]]# #[[com.arjuna.ats.arjuna]]# ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffff0a2a00b1:-13d57e5b:64268c66:2f6, org.wildfly.transaction.client.AbstractTransaction$AssociatingSynchronization@49f4f178 >: javax.persistence.PersistenceException: org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions. Collection : [it.sdb.apps.crmtrk.data.archive.db.Country.states#IT]
I don't see how these issues could be triggered by Hypersistence Optimizer.
Try enabling the tool only for your integration tests first.
@irizzant Have you managed to find the source of that Illegal attempt to associate a collection with two open sessions
issue?
@vladmihalcea nope, but I managed to get the tool working by activating it only in specific use cases, for now at least
If you can provide me with a replicating test case of that issue, I could investigate it for you.
Hello
I have my application deployed in Jboss EAP 7.3, which uses Jakarta EE and Hibernate 5.3.20.SP2-redhat-00001 and runs in Java 8.
I followed the setup instructions provided, added the dependency 2.6.3-jakarta and started the application.
As soon as the application server starts I get the following error:
Failed to define class io.hypersistence.optimizer.hibernate.decorator.HypersistenceSessionFactoryBuilderFactory in Module "deployment.WmsIntegration-7.0.1-SNAPSHOT.war" from Service Module Loader: java.lang.UnsupportedClassVersionError: Failed to link io/hypersistence/optimizer/hibernate/decorator/HypersistenceSessionFactoryBuilderFactory (Module "deployment.WmsIntegration-7.0.1-SNAPSHOT.war" from Service Module Loader): io/hypersistence/optimizer/hibernate/decorator/HypersistenceSessionFactoryBuilderFactory has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_362] at java.lang.ClassLoader.defineClass(ClassLoader.java:757) [rt.jar:1.8.0_362] at java.lang.ClassLoader.defineClass(ClassLoader.java:833) [rt.jar:1.8.0_362] at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:424) at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:555) at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339) at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126) at org.jboss.modules.Module.loadModuleClass(Module.java:753) at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116) at org.hibernate.boot.registry.classloading.internal.AggregatedClassLoader.findClass(AggregatedClassLoader.java:202) [hibernate-core-5.3.20.SP2-redhat-00001.jar:5.3.20.SP2-redhat-00001] at java.lang.ClassLoader.loadClass(ClassLoader.java:419) [rt.jar:1.8.0_362] at java.lang.ClassLoader.loadClass(ClassLoader.java:352) [rt.jar:1.8.0_362] at java.lang.Class.forName0(Native Method) [rt.jar:1.8.0_362] at java.lang.Class.forName(Class.java:348) [rt.jar:1.8.0_362] at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:370) [rt.jar:1.8.0_362] at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) [rt.jar:1.8.0_362] at java.util.ServiceLoader$1.next(ServiceLoader.java:480) [rt.jar:1.8.0_362] at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:245) [hibernate-core-5.3.20.SP2-redhat-00001.jar:5.3.20.SP2-redhat-00001] at org.hibernate.boot.internal.MetadataImpl.getSessionFactoryBuilder(MetadataImpl.java:156) [hibernate-core-5.3.20.SP2-redhat-00001.jar:5.3.20.SP2-redhat-00001] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1246) [hibernate-core-5.3.20.SP2-redhat-00001.jar:5.3.20.SP2-redhat-00001] at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:170) [wildfly-jpa-7.3.10.GA-redhat-00003.jar:7.3.10.GA-redhat-00003] at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:128) [wildfly-jpa-7.3.10.GA-redhat-00003.jar:7.3.10.GA-redhat-00003] at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_362] at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:659) [wildfly-elytron-security-manager-1.10.15.Final-redhat-00001.jar:1.10.15.Final-redhat-00001] at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:213) [wildfly-jpa-7.3.10.GA-redhat-00003.jar:7.3.10.GA-redhat-00003] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377) at java.lang.Thread.run(Thread.java:750) [rt.jar:1.8.0_362] at org.jboss.threads.JBossThread.run(JBossThread.java:485)
Which suggests the jar was compiled using a more recent Java version than Java 8. Also I get:
Caused by: java.util.ServiceConfigurationError: org.hibernate.boot.spi.SessionFactoryBuilderFactory: Provider io.hypersistence.optimizer.hibernate.decorator.HypersistenceSessionFactoryBuilderFactory not found", "jboss.persistenceunit.\"WmsIntegration-7.0.1-SNAPSHOT.war#webtng\"" => "org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [com.vladmihalcea.hibernate.type.json.JsonBinaryType] Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [com.vladmihalcea.hibernate.type.json.JsonBinaryType]
which is strange since I have in the build path: com.vladmihalcea:hibernate-types-52:jar:2.10.4