Hibernate with Spring-ORM cannot load an application table class in Fuse 6.1

Solution Verified - Updated -

Issue

  • An application that uses Hibernate and Spring-ORM in Fuse fails because Hibernate cannot load a class in the application code that models a database table. This class is defined in an XML file and is therefore, presumably, passed by name to Hibernate.
  • On Deploying the bundle, we get the following exception,
Exception in thread "SpringOsgiExtenderThread-2" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundle://271.0:0/META-INF/spring/bundle-context.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: entity class not found: hibernate.TestTable

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)

Caused by: org.hibernate.MappingException: entity class not found: hibernate.TestTable
    at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:137)
    at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:390)
    at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:75)
    at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:145) 

Caused by: java.lang.ClassNotFoundException:hibernate.TestTable not found by org.hibernate.core [266]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:190)
    at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)
    at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:132)

Environment

  • Red Hat JBoss Fuse
    • 6.x
  • Spring
  • Hibernate/JPA

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.