1

我正在尝试更新我的 WildFly 18.0.1 服务器的 Hibernate 版本。但是我遇到了用于缓存的 Infinispan 的问题。经典的 WildFly 发行版包含 Hibernate 5.3.13.Final 和 Infinispan 9.4.16.Final。

为了更新我使用wildfly-server-provisioning-maven-plugin以下内容server-provisioning.xml

<server-provisioning xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:wildfly:server-provisioning:1.2" extract-schemas="true" copy-module-artifacts="true"
                 extract-schemas-groups="org.jboss.as org.wildfly org.wildfly.core org.jboss.metadata">
<feature-packs>
    <feature-pack
            groupId="org.hibernate"
            artifactId="hibernate-orm-jbossmodules"
            version="5.4.12.Final" />
    <feature-pack
            groupId="org.hibernate"
            artifactId="hibernate-search-jbossmodules-orm"
            version="5.10.7.Final" />
    <feature-pack
            groupId="org.infinispan"
            artifactId="infinispan-feature-pack-client"
            version="10.1.2.Final" />
    <feature-pack
            groupId="org.infinispan"
            artifactId="infinispan-feature-pack-client"
            version="10.1.2.Final" />
    <feature-pack
            groupId="org.infinispan"
            artifactId="infinispan-feature-pack-embedded"
            version="10.1.2.Final" />
    <feature-pack
            groupId="org.infinispan"
            artifactId="infinispan-feature-pack-embedded-query"
            version="10.1.2.Final" />
    <feature-pack
            groupId="org.infinispan"
            artifactId="infinispan-feature-pack-commons"
            version="10.1.2.Final" />
    <feature-pack
            groupId="org.infinispan"
            artifactId="infinispan-feature-pack-wf-modules"
            version="10.1.2.Final" />
    <feature-pack
            groupId="org.hibernate.lucene-jbossmodules"
            artifactId="lucene-jbossmodules"
            version="5.5.5.hibernate06"/>
    <feature-pack
            groupId="org.wildfly"
            artifactId="wildfly-feature-pack"
            version="${wildfly.version}" />
</feature-packs>

我尝试过不同的版本,例如9.4.18.Finalor 10.0.1.Final。将构建的 WildFly 与新版本一起使用,我得到以下异常:

15:40:15,510 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service org.wildfly.clustering.infinispan.cache-container.hibernate: org.jboss.msc.service.StartException in service org.wildfly.clustering.infinispan.cache-container.hibernate: java.lang.NoClassDefFoundError: Failed to link org/infinispan/hibernate/cache/commons/util/SecondLevelCacheMetadataModuleFinder (Module "org.infinispan.hibernate-cache" version 9.4.16.Final from local module loader @5f2108b5 (finder: local module finder @31a5c39e (roots: D:\Dev\Servers\wildfly-hibernate-5.4.11\modules,D:\Dev\Servers\wildfly-hibernate-5.4.11\modules\system\layers\base,D:\Dev\Servers\wildfly-hibernate-5.4.11\modules\system\add-ons\ispn))): org/infinispan/factories/components/ModuleMetadataFileFinder
at org.wildfly.clustering.service.FunctionalService.start(FunctionalService.java:70)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: Failed to link org/infinispan/hibernate/cache/commons/util/SecondLevelCacheMetadataModuleFinder (Module "org.infinispan.hibernate-cache" version 9.4.16.Final from local module loader @5f2108b5 (finder: local module finder @31a5c39e (roots: D:\Dev\Servers\wildfly-hibernate-5.4.11\modules,D:\Dev\Servers\wildfly-hibernate-5.4.11\modules\system\layers\base,D:\Dev\Servers\wildfly-hibernate-5.4.11\modules\system\add-ons\ispn))): org/infinispan/factories/components/ModuleMetadataFileFinder
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:423)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:555)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126)
at org.jboss.modules.Module.loadModuleClass(Module.java:731)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:370)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at org.infinispan.commons.util.ServiceFinder.addServices(ServiceFinder.java:63)
at org.infinispan.commons.util.ServiceFinder.load(ServiceFinder.java:44)
at org.infinispan.util.ModuleProperties.getModuleMetadataFiles(ModuleProperties.java:47)
at org.infinispan.factories.GlobalComponentRegistry.<init>(GlobalComponentRegistry.java:107)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:257)
at org.jboss.as.clustering.infinispan.subsystem.CacheContainerServiceConfigurator.get(CacheContainerServiceConfigurator.java:100)
at org.jboss.as.clustering.infinispan.subsystem.CacheContainerServiceConfigurator.get(CacheContainerServiceConfigurator.java:73)
at org.wildfly.clustering.service.FunctionalService.start(FunctionalService.java:67)
... 8 more

我如何理解这个异常是因为org.infinispan.hibernate-cache更新中缺少模块而引发的。由于我不知道如何更新它,我手动添加了罐子。如果我使用 Infinispan10.1.2.Final并添加 hibernate-cache 模块,我仍然会遇到异常:

15:43:53,638 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service org.wildfly.clustering.infinispan.cache-container.hibernate: org.jboss.msc.service.StartException in service org.wildfly.clustering.infinispan.cache-container.hibernate: org.infinispan.commons.CacheException: Unable to load component metadata!
at org.wildfly.clustering.service.FunctionalService.start(FunctionalService.java:70)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.infinispan.commons.CacheException: Unable to load component metadata!
at org.infinispan.factories.components.ComponentMetadataRepo.initialize(ComponentMetadataRepo.java:175)
at org.infinispan.factories.GlobalComponentRegistry.<init>(GlobalComponentRegistry.java:107)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:257)
at org.jboss.as.clustering.infinispan.subsystem.CacheContainerServiceConfigurator.get(CacheContainerServiceConfigurator.java:100)
at org.jboss.as.clustering.infinispan.subsystem.CacheContainerServiceConfigurator.get(CacheContainerServiceConfigurator.java:73)
at org.wildfly.clustering.service.FunctionalService.start(FunctionalService.java:67)
... 8 more
Caused by: java.lang.NullPointerException
at org.infinispan.factories.components.ComponentMetadataRepo.readMetadata(ComponentMetadataRepo.java:44)
at org.infinispan.factories.components.ComponentMetadataRepo.initialize(ComponentMetadataRepo.java:173)
... 13 more

我不确定这个异常,但它似乎表明配置错误。我正在使用standalone.xmlWildFly 的默认设置:

    <subsystem xmlns="urn:jboss:domain:infinispan:9.0">
        <cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
            <local-cache name="passivation">
                <locking isolation="REPEATABLE_READ" />
                <transaction mode="BATCH" />
                <file-store passivation="true" purge="false" />
            </local-cache>
            <local-cache name="sso">
                <locking isolation="REPEATABLE_READ" />
                <transaction mode="BATCH" />
            </local-cache>
            <local-cache name="routing" />
        </cache-container>
        <cache-container name="server" default-cache="default" module="org.wildfly.clustering.server">
            <local-cache name="default">
                <transaction mode="BATCH" />
            </local-cache>
        </cache-container>
        <cache-container name="ejb" aliases="sfsb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan">
            <local-cache name="passivation">
                <locking isolation="REPEATABLE_READ" />
                <transaction mode="BATCH" />
                <file-store passivation="true" purge="false" />
            </local-cache>
        </cache-container>
        <cache-container name="hibernate" module="org.infinispan.hibernate-cache">
            <local-cache name="entity">
                <object-memory size="10000" />
                <expiration max-idle="100000" />
            </local-cache>
            <local-cache name="local-query">
                <object-memory size="10000" />
                <expiration max-idle="100000" />
            </local-cache>
            <local-cache name="timestamps" />
        </cache-container>
    </subsystem>

如果此配置架构发生更改,我无法确定要在此处使用的正确架构。简而言之,我想知道哪个 Infinispan 版本与当前的 Hibernate 版本兼容,以及如果我必须将 Infinispan 更新为10.1.2.Final.

4

1 回答 1

1

在 WildFly 中替换 Hibernate 和 Infinispan 并非易事,尤其是因为服务器内部依赖于这些组件(JPA 子系统、集群子系统等)。如果您想使用较新的组件,您应该将它们打包到部署中,或者使用模块/系统/附加组件层次结构下的专用插槽(而不是“主”)创建并行模块结构,并通过部署结构导入它们XML 或清单。但是请注意,在这种情况下,您将失去来自服务器的任何“帮助”(例如,持久性单元的自动检测、在应用程序之外定义的缓存)

于 2020-02-18T09:06:22.750 回答