Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-24929

[GSS](7.4.z) NoClassDefFoundError: org/hibernate/proxy/HibernateProxy when using javassist

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 7.4.2.GA, 7.4.10.GA
    • Classloading, Hibernate
    • None
    • False
    • None
    • False
    • Workaround Exists
    • Hide

      As of EAP 7.2, Hibernate uses Byte Buddy by default.  Remove the -Dhibernate.bytecode.provider=javassist and let Byte Buddy be used.

      Or for the case where javassist must be used, create a mbean that extends DynamicMBean and use that.

      public interface IDynamicMBean extends javax.management.DynamicMBean {
      }
      @Entity
      @Proxy(proxyClass = IDynamicMBean.class)
      public class Book implements Serializable { ... } 
      Show
      As of EAP 7.2, Hibernate uses Byte Buddy by default.  Remove the -Dhibernate.bytecode.provider=javassist and let Byte Buddy be used. Or for the case where javassist must be used, create a mbean that extends DynamicMBean and use that. public interface IDynamicMBean extends javax.management.DynamicMBean { } @Entity @Proxy(proxyClass = IDynamicMBean.class) public class Book implements Serializable { ... }
    • Hide

      JBoss EAP

      • Build attached hibernate-demo application.
      • Run EAP with bin/standalone.sh -Dhibernate.bytecode.provider=javassist.
        • The issue occurs with both Java 11 and Java 17.
        • When run with Java 17, --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED are added to $JAVA_OPTS.
      • Copy hibernate-demo.war to standalone/deployments.

      Standalone

      • Build attached hibernate-standalone-demo
      • Run with mvn exec:exec
      Show
      JBoss EAP Build attached hibernate-demo application. Run EAP with bin/standalone.sh -Dhibernate.bytecode.provider=javassist . The issue occurs with both Java 11 and Java 17. When run with Java 17, --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED are added to $JAVA_OPTS . Copy hibernate-demo.war to standalone/deployments . Standalone Build attached hibernate-standalone-demo Run with mvn exec:exec

      Description

      Annotating a Hibernate entity with @Proxy(proxyClass = javax.management.DynamicMBean.class) causes the following Hibernate error when the application is deployed:

      16:09:16,212 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 70) MSC000001: Failed to start service jboss.persistenceunit."hibernate-demo.war#primary": org.jboss.msc.service.StartException in service jboss.persistenceunit."hibernate-demo.war#primary": javax.persistence.PersistenceException: [PersistenceUnit: primary] Unable to build Hibernate SessionFactory
              at org.jboss.as.jpa@7.4.10.GA-redhat-00002//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:198)
              at org.jboss.as.jpa@7.4.10.GA-redhat-00002//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:128)
              at java.base/java.security.AccessController.doPrivileged(Native Method)
              at org.wildfly.security.elytron-private@1.15.16.Final-redhat-00001//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
              at org.jboss.as.jpa@7.4.10.GA-redhat-00002//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:213)
              at org.jboss.threads@2.4.0.Final-redhat-00001//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
              at org.jboss.threads@2.4.0.Final-redhat-00001//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
              at org.jboss.threads@2.4.0.Final-redhat-00001//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
              at org.jboss.threads@2.4.0.Final-redhat-00001//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
              at java.base/java.lang.Thread.run(Thread.java:829)
              ...
      Caused by: java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy
              at java.base/java.lang.ClassLoader.defineClass1(Native Method)
              at java.base/java.lang.System$2.defineClass(System.java:2131)
              at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:962)
              at org.javassist@3.27.0.GA-redhat-00001//javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:295)
              at org.javassist@3.27.0.GA-redhat-00001//javassist.util.proxy.DefineClassHelper$Java11.defineClass(DefineClassHelper.java:48)
              at org.javassist@3.27.0.GA-redhat-00001//javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:260)
              at org.javassist@3.27.0.GA-redhat-00001//javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:154)
              at org.javassist@3.27.0.GA-redhat-00001//javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:640)
              at org.javassist@3.27.0.GA-redhat-00001//javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:624)
              at org.javassist@3.27.0.GA-redhat-00001//javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:560)
              at org.javassist@3.27.0.GA-redhat-00001//javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:481)
              at org.hibernate@5.3.28.Final-redhat-00001//org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.postInstantiate(JavassistProxyFactory.java:75)
              at org.hibernate@5.3.28.Final-redhat-00001//org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:103)
              at org.hibernate@5.3.28.Final-redhat-00001//org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:155)
              at org.hibernate@5.3.28.Final-redhat-00001//org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:51)
              ... 31 more
      

      Investigation

      The same application can be deployed to JBoss EAP 7.4.1 (javassist-3.23.2.GA-redhat-00001) with no error. The issue seems to be caused by changes introduced in EAP 7.4.2 which includes javassist-3.27.0.GA-redhat-00001, the same version in EAP 7.4.10. It's possible it is related to this commit which made changes to support Java 11.

      The application deploys OK when specifying a proxy class within the same application (com.sample.ITest), or a class like java.lang.String. Seems to be an issue with the javax.management package.

            rhn-support-bmaxwell Brad Maxwell
            rhn-support-iwalker Ian Walker
            Votes:
            0 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: