Warnings for javassist when deploying a native Hibernate application in EAP 6

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 6
  • Hibernate 4 (non-JPA/native Hibernate applications only)

Issue

  • HHH000305: Could not create proxy factory ... HHH000142: Javassist Enhancement failed when deploying a native (non-JPA) Hibernate application
... WARN  [org.hibernate.tuple.entity.PojoEntityTuplizer] ... HHH000305: Could not create proxy factory for:org.test.MyEntity: org.hibernate.HibernateException: HHH000142: Javassist Enhancement failed: org.test.MyEntity
        at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:167)
        at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.postInstantiate(JavassistProxyFactory.java:66)
        at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:229)
        ...
        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:506)
        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:146)
        ...
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:389)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1799)
...
Caused by: java.lang.RuntimeException: by java.lang.NoClassDefFoundError: javassist/util/proxy/ProxyObject
        at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:515)
        ...
        at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:163)
        ...
Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: javassist/util/proxy/ProxyObject
        at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:170)
        at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:507)
        ...
Caused by: java.lang.NoClassDefFoundError: javassist/util/proxy/ProxyObject
        at java.lang.ClassLoader.defineClass1(Native Method)
        ...
        at javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:182)
        at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:164)
        ... 62 more
Caused by: java.lang.ClassNotFoundException: javassist.util.proxy.ProxyObject ...
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213)
        ...
  • JBAS015867: Deployment ... is using a private module ("org.javassist:main") if an explicit module dependency is added to jboss-deployment-structure.xml
... WARN  [org.jboss.as.dependency.private] ... JBAS015867: Deployment ... is using a private module ("org.javassist:main") which may be changed or removed in future versions without notice.

Resolution

  • The NoClassDefFoundError may be resolved by an explicit application dependency on org.javassist in jboss-deployment-structure.xml
<jboss-deployment-structure ...>
        <deployment>
                <dependencies>
                        ...
                        <module name="org.hibernate"/>
                        <module name="org.javassist"/>
                </dependencies>
        </deployment>
</jboss-deployment-structure>
  • The JBAS015867 warning is non-fatal and there are presently no plans to remove support for javassist in EAP 6 so the warning may be ignored
  • This is This content is not included.BZ-1288251 which is resolved by applying JBoss EAP 6.4 Cumulative Patch (CP) 6 or later
    • Resolution of the dependency as part of the fix for This content is not included.BZ-1288251 is meant only to support Hibernate's internal usage (e.g. in lazy fetch)
    • Applications should not use javassist directly/explicitly as this is not supported

Root Cause

  • In order to leverage functionality such as lazy fetch, Hibernate requires bytecode instrumentation which is provided by javassist
    • This introduces a deployment time dependency manifested as the HHH000142 error for native Hibernate applications
  • The JBAS015867 warning results from an explicit dependency introduced to resolve the NoClassDefFoundError
    • org.javassist is shipped as a private module because it is not part of the JavaEE standard and is not meant to be directly used by application code
    • This issue is unique to non-JPA/native Hibernate applications which require application configuration to resolve the the org.javassist dependency
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.