Wildfly 10 可以与旧版 Hibernate 3.5 一起使用吗?

Can Wildfly 10 work with legacy Hibernate 3.5?

我正在尝试从 Jboss 4.2.3 升级到 WildFly 10。
剩下的主要未决问题是 Hibernate。
我现在不想升级到 Hibernate 5(Wildfly 10 的默认设置) 因此,我尝试使用使用 Hibernate 3.5 的现有代码,但我遇到了一些问题。

我有一个 Ear,其中包含几个 war 和一些 ejb-jars。

我现在在我的 ejb-jars 和耳朵里有 jboss-deployment-structure.xml, 全部指定:

<exclusions>
    <module name="org.hibernate" />
</exclusions>

我在耳边的库中包含了以下 jar(在 JBoss 4.2.3 部署中也有):

hibernate-annotations-jboss.4.2.3.jar
hibernate-commons-annotations-3.0.0.ga.jar
hibernate-jboss.4.2.3.jar
hibernate-validator-4.0.2.GA.jar
jbossall-client-4.2.3.GA.jar

我还将以下 jar 添加到 ear 的库中:

hibernate-entitymanager-jboss.4.2.3.jar  

我在部署 ear 期间收到以下错误消息:

    INFO  [org.hibernate.ejb.Ejb3Configuration] (ServerService Thread Pool -- 83) Processing PersistenceUnitInfo [
    name: AuditTrailPU
    ...]
2016-11-03 15:45:01,521 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 86) MSC000001: Failed to start service jboss.persistenceunit."InSyncEar-11.0.0-SNAPSHOT.ear/SchedulerCore.jar#SchedulerPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."InSyncEar-11.0.0-SNAPSHOT.ear/SchedulerCore.jar#SchedulerPU": java.lang.RuntimeException: error trying to scan <jar-file>: vfs:/C:/TFSROOT/Purchasing_Trunk/InsyncRuntime/target/InTync/wildfly-10.1.0.Final/bin/content/InTyncEar-11.0.0-SNAPSHOT.ear/SchedulerCore.jar/
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:179)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:121)
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:193)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: vfs:/C:/TFSR/Purch/IntyncRuntime/target/InTync/wildfly-10.1.0.Final/bin/content/InTyncEar-11.0.0-SNAPSHOT.ear/SchedCore.jar/
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:619)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:341)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:341)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access00(PersistenceUnitServiceImpl.java:69)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:174)
    ... 7 more
Caused by: java.lang.RuntimeException: Archive browser cannot handle protocol: vfs:/C:/TFSR/Purch/IntyncRuntime/target/InTync/wildfly-10.1.0.Final/bin/content/InTyncEar-11.0.0-SNAPSHOT.ear/SchedCore.jar/
    at org.jboss.util.file.ArchiveBrowser.getBrowser(ArchiveBrowser.java:56)
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:610)
    ... 12 more

我看到其他人遇到这种错误,但他们得到的建议是从 ear/war 中删除休眠罐。在我的例子中,Hibernate jar 必须存在,因为我已经排除了 "built in" Hibernate。 问题可能是因为 Hibernate class (Ejb3Configuration) 正在调用 JBoss 实用程序 class (ArchiveBrowser)。但是 ArchiveBrowser 在 jbossall-client-4.2.3.GA.jar(在我的 ear/lib)中。

我还尝试将以下内容放入我的 ejb-jars 的 persistence.xml 中:

 <property name="jboss.as.jpa.providerModule" value="hibernate3-bundled" />

正如网站上向遇到同样问题的人所建议的那样,但结果是消息:

org.jboss.modules.ModuleNotFoundException: hibernate3-bundled:main

我应该设置这样的模块吗?

所以有没有人知道问题出在哪里,有解决办法吗?

另外,我的ear部署在wildfly-10.1.0.Final\standalone\deployments文件夹

但消息是:

尝试扫描时出错:

vfs:/C:/TFSROOT/Purchasing_Trunk/InsyncRuntime/target/InTync/wildfly-10.1.0.Final/bin/content/InTyncEar-11.0.0-SNAPSHOT.ear/SchedulerCore.jar/

如果我查看文件系统,现有 "bin" 文件夹下没有 "content" 文件夹。
那是问题所在吗?它看错地方了吗?

最后,是否有可能,有没有人能够让 Wildfly 10 成功地与 Hibernate 3 一起工作? (我看到了关于这个的问题和答案,但没有 "working" 解决方案)

如有任何帮助,我们将不胜感激。

看来答案是否定的。因为 Hibernate 和 Wildfly 是交织在一起的。我已经放弃了这种方法,并努力将代码迁移到休眠 5,因此它可以与 wildfly 10

一起使用