Hibernate OEM does not work in Eclipse RCP

Hello together,

We are not able to get hibernate to run in our eclipse rcp application. It works from the IDE, but not in build environment. We get the following error:

Caused by: java.lang.IllegalArgumentException: Not an entity: org.teraport.persistence.dao.mocca.TeraportDao at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.entity(JpaMetamodelImpl.java:204) at org.hibernate.query.sqm.tree.select.AbstractSqmSelectQuery.from(AbstractSqmSelectQuery.java:237) at org.hibernate.query.sqm.tree.select.AbstractSqmSelectQuery.from(AbstractSqmSelectQuery.java:42) at 

Hibernate knows this class and the class is annotated. Also annotations are not skiped by javac.The error is annotation related, due to old xml based config works.

We have tried everything Buddy-ClassPath related, but without success. We don’t use any persistance.xml or external config files, but configuration code:

protected void addAllClassesInHierachyAsAnnotated( Configuration configuration ) { Set<Class<?>> knownList = HibernateConnectionBuffer.getAllKNownClasses(); for ( Class<?> currentClass : knownList ) { configuration.addAnnotatedClass( currentClass ); } }

All annotated DAO classes lies in one plugin together with the hibernate libs.

Has anybody experience or an hint how to get hibernate annotations to run in OSGI classpath magic environment?

This sounds like a class loader problem. Maybe you need to set configure a thread context class loader or configure the precedence. Also see the documentation: Hibernate ORM User Guide