Warnings for javassist when deploying a native Hibernate application in EAP 6
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 failedwhen 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 tojboss-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
NoClassDefFoundErrormay be resolved by an explicit application dependency onorg.javassistinjboss-deployment-structure.xml
<jboss-deployment-structure ...>
<deployment>
<dependencies>
...
<module name="org.hibernate"/>
<module name="org.javassist"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
- The
JBAS015867warning is non-fatal and there are presently no plans to remove support forjavassistin 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
javassistdirectly/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
HHH000142error for native Hibernate applications
- This introduces a deployment time dependency manifested as the
- The
JBAS015867warning results from an explicit dependency introduced to resolve theNoClassDefFoundErrororg.javassistis 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.javassistdependency
Components
Category
Tags
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.