Hibernate ENVERS 类加载问题

发布于 2024-12-01 01:59:55 字数 3333 浏览 3 评论 0原文

我正在尝试将 Hibernate Envers 集成到一个已经开发的应用程序中。

我将 Hibernate Envers JAR 放在 EAR 包中,它抛出了一个关于类加载器的丑陋异常和某种冲突。

如果我避免在 EAR 内运送 Envers JAR 并将其放置在 JBoss 的“lib”目录中,那么一切都会正常工作,但我需要将库与应用程序一起运送,因为我有无法访问此全局“lib”目录。

我正在 JBoss 5.1.0.GA 上部署,使用 Hibernate 3.3.GA 和 Envers 1.2.2.GA。

有什么线索吗?

例外的是这个:

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.TwoPhaseCoordinator.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)

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.TwoPhaseCoordinator.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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稳稳的幸福 2024-12-08 01:59:55

这看起来像是处理多个类加载器时的经典 Java 继承问题。您是否尝试过将 jboss-classloading.xml 添加到您的 EAR META-INF/lib 目录中?

<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>

您可能必须开始打包 Hibernate 以及您依赖的应用程序服务器提供的任何其他第 3 方库。

这似乎也是一个很好的资源 http://phytodata.wordpress.com/2010/10/21/demystifying-the-jboss5-jboss-classloading-xml-file/

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文