开发者

Hibernate ENVERS Classloading issue

I am trying to integrate Hibernate Envers in an already developed application.

I ship the Hibernate Envers JAR inside an EAR package, and it throws an ugly exception regarding to class loader and some kind of conflict.

If I avoid shipping the Envers JAR inside the EAR and I place it in the "lib" directory of JBoss, then everything works fine, but I need to ship the library along with the application, since I have no access to this global "lib" directory.

I am deploying on JBoss 5.1.0.GA, using Hibernate 3.3.GA and Envers 1.2.2.GA.

Any clue?

The exception is this one:

15:31:21,621 WARN  [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeC
ompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@84697f
java.lang.LinkageError: loader constraint violation: when resolving interface method "org.hibernate.Transaction.register
Synchronization(Ljavax/transaction/Synchronization;)V" the class loader (instance of org/jboss/classloader/spi/base/Base
ClassLoader) of the current class, org/hibernate/envers/synchronization/AuditSyncManager, and the class loader (instance
 of org/jboss/classloader/spi/base/BaseClassLoader) for resolved class, org/hibernate/Transaction, have different Class
objects for the type javax/transaction/Synchronization used in the signature
        at org.hibernate.envers.synchronization.AuditSyncManager.get(AuditSyncManager.java:56)
        at org.hibernate.envers.event.AuditEventListener.onPostUpdate(AuditEventListener.java:163)
        at org.hibernate.action.EntityUpdateAction.postUpdate(EntityUpdateAction.java:200)
        at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:179)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:32
1)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
        at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:504)
        at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.j
ava:101)
        at com.arjuna.ats.arjuna.coordinator.Tw开发者_JAVA技巧oPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)
        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)
        at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
        at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.ja
va:1423)
        at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137)
        at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
        at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:170)
        at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
        at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)


This looks like the classic Java inheritance issue when dealing with multiple classloaders. Have you tried adding jboss-classloading.xml to your EAR META-INF/lib directory?

<classloading xmlns="urn:jboss:classloading:1.0"
              parent-first="false"
              domain="DefaultDomain"
              top-level-classloader="true"
              parent-domain="Ignored"
              export-all="NON_EMPTY"
              import-all="true">
</classloading>

You'll probably have to start packaging Hibernate as well as any other 3rd party libraries that you rely on being provided by the application server.

This also appears to be a good resource http://phytodata.wordpress.com/2010/10/21/demystifying-the-jboss5-jboss-classloading-xml-file/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜