HibernateProxy can't be found by JBoss Fuse

Solution Verified - Updated -

Environment

  • JBoss Fuse 6.0

Issue

I'm trying to deploy Hibernate to the JBoss Fuse. Unfortunately I see the following error:

Caused by: javassist.CannotCompileException: by java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy
    at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:170)[169:javassist:3.18.1.GA]
    at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:507)[169:javassist:3.18.1.GA]
    ... 63 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy
    at java.lang.ClassLoader.defineClass1(Native Method)[:1.7.0_45]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)[:1.7.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_45]
    at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_45]
    at javassist.util.proxy.FactoryHelper.toClass2(FactoryHelper.java:182)[169:javassist:3.18.1.GA]
    at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:164)[169:javassist:3.18.1.GA]
    ... 64 more

Resolution

You need to explicitly include Hibernate proxy and Javassist in the configuration of your Maven Bundle plugin [1], just as demonstrated on the snippet below.

<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <version>2.3.7</version>
  <extensions>true</extensions>
  <configuration>
    <instructions>
      <Import-Package>
        javax.persistence,
        org.hibernate.proxy,
        javassist.util.proxy,
        *
      </Import-Package>
    </instructions>
  </configuration>
</plugin>

[1] http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

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.

Comments