1

我们正在开发一个使用带有 lucene 索引的休眠搜索的 Web 应用程序。首先我们使用 Windows Filesystem 目录来存储 lucene 索引文件。对于集群,我们正在从 FS 更改为 Infinspan 以存储索引。我遵循了 infinispan 和 hibernate 搜索手册,但下面提到的异常会连续显示。

JPA persistence.xml细节是,

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="inov8">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:jboss/datasources/inov8bDS</jta-data-source>       

        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>          
            <property name="hibernate.max_fetch_depth" value="3"/>

            <property name="hibernate.show_sql" value="false" />    
            <property name="hibernate.default_batch_fetch_size" value="10" />   
            <property name="hibernate.jdbc_fetch_size" value="10" />    
            <property name="hibernate.jdbc_batch_size" value="10" />    


            <property name="hibernate.id.new_generator_mappings" value="false" />            

            <!-- The following line is what's used in Hibernate 4 instead of a TransactionManagerLookup class -->
            <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />

            <property name="hibernate.cache.use_second_level_cache" value="true" />
            <property name="hibernate.cache.use_query_cache" value="true" />    



         <!--    <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"/>  -->

            <!-- TODO [clustering] need to change index location -->
            <property name="hibernate.search.default.exclusive_index_use" value="true"  />
            <property name="hibernate.search.default.directory_provider" value="infinispan" />  
        <!--    <property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/hibernate"/>   -->
            <property name="hibernate.search.infinispan.configuration_resourcename" value="C:\dev\Java\lib\hibernate-search\hibernate-search-4.2.0.Final\project\hibernate-search-infinispan\src\main\resources\default-hibernatesearch-infinispan.xml" />
            <property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/container/hibernate" />
            <property name="hibernate.search.default.data_cachename" value="LuceneIndexesData" />  
            <property name="hibernate.search.default.metadata_cachename" value="LuceneIndexesMetadata" /> 
            <property name="hibernate.search.default.locking_cachename" value="LuceneIndexesLocking" />
            <property name="hibernate.search.infinispan.cachemanager_jndiname" value="java:infinispan/myup-hibernatesearch"/> 
            <property name="hibernate.search.default.chunk_size" value="33554432"/>




            <property name="key2StringMapperClass" value="org.infinispan.lucene.LuceneKey2StringMapper" />   
            <property name="hibernate.search.default.indexBase" value="C:\dev\deploy\inov8b\lucene"/>  
            <property name="hibernate.search.lucene_version" value="LUCENE_36"/>

        </properties>        


    </persistence-unit>
</persistence>

错误堆栈跟踪:

17:23:38,474 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 54) MSC00001: Failed to start service jboss.persistenceunit."inov8.war#inov8": org.jboss.msc.service.StartException in service jboss.persistenceunit."inov8.war#inov8": org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager xx.inov8.domain.innovation.InnovationComponent
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_17]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_17]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.0.Final.jar:2.1.0.Final]
Caused by: org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager xx.inov8.domain.innovation.InnovationComponent
    at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:230)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.buildEntityIndexBinding(IndexManagerHolder.java:102)
    at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:414)
    at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:222)
    at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:146)
    at org.hibernate.search.event.impl.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:130)
    at org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:83)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:303)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742)
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99)
    ... 4 more
Caused by: org.hibernate.search.SearchException: Unable to find directory provider implementation class: org.hibernate.search.infinispan.impl.InfinispanDirectoryProvider
    at org.hibernate.search.util.impl.ClassLoaderHelper.classForName(ClassLoaderHelper.java:257)
    at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromName(ClassLoaderHelper.java:107)
    at org.hibernate.search.store.impl.DirectoryProviderFactory.createDirectoryProvider(DirectoryProviderFactory.java:74)
    at org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.createDirectoryProvider(DirectoryBasedIndexManager.java:232)
    at org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:100)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:227)
    ... 19 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.search.infinispan.impl.InfinispanDirectoryProvider from [Module "deployment.inov8.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.2.0.CR1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.2.0.CR1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.2.0.CR1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.2.0.CR1]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.2.0.CR1]
    at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17]
    at java.lang.Class.forName(Class.java:266) [rt.jar:1.7.0_17]
    at org.hibernate.search.util.impl.ClassLoaderHelper.classForName(ClassLoaderHelper.java:287)
    at org.hibernate.search.util.impl.ClassLoaderHelper.classForName(ClassLoaderHelper.java:254)
    ... 24 more

17:23:38,693 ERROR [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS015870: Deploy of deployment "inov8.war" was rolled back with the following failure message: 
{"JBAS014671: Failed services" => {"jboss.persistenceunit.\"inov8.war#inov8\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"inov8.war#inov8\": org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager xx.inov8.domain.innovation.InnovationComponent
    Caused by: org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager xx.inov8.domain.innovation.InnovationComponent
    Caused by: org.hibernate.search.SearchException: Unable to find directory provider implementation class: org.hibernate.search.infinispan.impl.InfinispanDirectoryProvider
    Caused by: java.lang.ClassNotFoundException: org.hibernate.search.infinispan.impl.InfinispanDirectoryProvider from [Module \"deployment.inov8.war:main\" from Service Module Loader]"}}
17:23:38,693 INFO  [org.jboss.weld.deployer] (MSC service thread 1-15) JBAS016009: Stopping weld service for deployment inov8.war
17:23:38,709 INFO  [org.jboss.as.clustering.infinispan] (MSC service thread 1-15) JBAS010282: Stopped inov8.war#inov8.org.hibernate.cache.spi.UpdateTimestampsCache cache from hibernate container
17:23:38,709 INFO  [org.jboss.as.clustering.infinispan] (MSC service thread 1-15) JBAS010282: Stopped inov8.war#inov8.org.hibernate.cache.internal.StandardQueryCache cache from hibernate container
17:23:38,709 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (MSC service thread 1-15) ISPN000080: Disconnecting and closing JGroups Channel
17:23:38,724 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (MSC service thread 1-15) ISPN000082: Stopping the RpcDispatcher
17:23:38,802 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment inov8.war (runtime-name: inov8.war) in 119ms

默认-hibernatesearch-infinispan.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Hibernate, Relational Persistence for Idiomatic Java
 * 
 * Copyright (c) 2012, Red Hat, Inc. and/or its affiliates or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  All third-party contributions are
 * distributed under license by Red Hat, Inc.
 * 
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
  -->
<infinispan
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"
    xmlns="urn:infinispan:config:5.1">

    <!-- *************************** -->
    <!-- System-wide global settings -->
    <!-- *************************** -->

    <global>

        <!-- Duplicate domains are allowed so that multiple deployments with default configuration 
            of Hibernate Search applications work - if possible it would be better to use JNDI to share 
            the CacheManager across applications -->
        <globalJmxStatistics
            enabled="true"
            cacheManagerName="HibernateSearch"
            allowDuplicateDomains="true" />

        <!-- If the transport is omitted, there is no way to create distributed or clustered
            caches. There is no added cost to defining a transport but not creating a cache that uses one,
            since the transport is created and initialized lazily. -->
        <transport
            clusterName="HibernateSearch-Infinispan-cluster"
            >

            <!-- Note that the JGroups transport uses sensible defaults if no configuration 
                property is defined. See the JGroupsTransport javadocs for more flags -->
        </transport>

        <!-- Note that the JGroups transport uses sensible defaults if no configuration property 
            is defined. See the Infinispan wiki for more JGroups settings:
            http://community.jboss.org/wiki/ClusteredConfigurationQuickStart -->

        <!-- Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER, DONT_REGISTER. 
            Hibernate Search takes care to stop the CacheManager so registering is not needed -->
        <shutdown
            hookBehavior="DONT_REGISTER" />

    </global>

    <!-- *************************** -->
    <!-- Default "template" settings -->
    <!-- *************************** -->

    <default>

        <locking
            lockAcquisitionTimeout="20000"
            writeSkewCheck="false"
            concurrencyLevel="500"
            useLockStriping="false" />

        <!-- Invocation batching is required for use with the Lucene Directory -->
        <invocationBatching
            enabled="true" />

        <!-- This element specifies that the cache is clustered. modes supported: distribution 
            (d), replication (r) or invalidation (i). Don't use invalidation to store Lucene indexes (as 
            with Hibernate Search DirectoryProvider). Replication is recommended for best performance of 
            Lucene indexes, but make sure you have enough memory to store the index in your heap.
            Also distribution scales much better than replication on high number of nodes in the cluster. -->
        <clustering
            mode="replication">

            <!-- Prefer loading all data at startup than later -->
            <stateTransfer
                timeout="480000"
                fetchInMemoryState="true" />

            <!-- Network calls are synchronous by default -->
            <sync
                replTimeout="20000" />
        </clustering>

        <jmxStatistics
            enabled="true" />

        <eviction
            maxEntries="-1"
            strategy="NONE" />

        <expiration
            maxIdle="-1" />

    </default>

    <!-- ******************************************************************************* -->
    <!-- Individually configured "named" caches.                                         -->
    <!--                                                                                 -->
    <!-- While default configuration happens to be fine with similar settings across the -->
    <!-- three caches, they should generally be different in a production environment.   -->
    <!--                                                                                 -->
    <!-- Current settings could easily lead to OutOfMemory exception as a CacheStore     -->
    <!-- should be enabled, and maybe distribution is desired.                           -->
    <!-- ******************************************************************************* -->

    <!-- *************************************** -->
    <!--  Cache to store Lucene's file metadata  -->
    <!-- *************************************** -->
    <namedCache
        name="LuceneIndexesMetadata">
        <clustering
            mode="replication">
            <stateTransfer
                fetchInMemoryState="true" />
            <sync
                replTimeout="25000" />
        </clustering>
       <loaders>

   <loader class="org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore" fetchPersistentState="false" ignoreModifications="false"
purgeOnStartup="false">
      <properties>
         <property name="stringsTableNamePrefix" value="ISPN_STRING_TABLE"/>
         <property name="idColumnName" value="ID_COLUMN"/>
         <property name="dataColumnName" value="DATA_COLUMN"/>
         <property name="timestampColumnName" value="TIMESTAMP_COLUMN"/>
         <property name="timestampColumnType" value="BIGINT"/>
         <property name="connectionFactoryClass" value="org.infinispan.loaders.jdbc.connectionfactory.PooledConnectionFactory"/>
         <property name="connectionUrl" value="jdbc:h2:mem:string_based_db;DB_CLOSE_DELAY=-1"/>
         <property name="userName" value="sa"/>
         <property name="driverClass" value="org.h2.Driver"/>
         <property name="idColumnType" value="VARCHAR(255)"/>
         <property name="dataColumnType" value="BINARY"/>
         <property name="dropTableOnExit" value="true"/>
         <property name="createTableOnStart" value="true"/>
      </properties>
   </loader>
</loaders>
    </namedCache>

    <!-- **************************** -->
    <!--  Cache to store Lucene data  -->
    <!-- **************************** -->
    <namedCache
        name="LuceneIndexesData">
        <clustering
            mode="replication">
            <stateTransfer
                fetchInMemoryState="true" />
            <sync
                replTimeout="25000" />
        </clustering>
      <loaders>

   <loader class="org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore" fetchPersistentState="false" ignoreModifications="false"
purgeOnStartup="false">
      <properties>
         <property name="stringsTableNamePrefix" value="ISPN_STRING_TABLE"/>
         <property name="idColumnName" value="ID_COLUMN"/>
         <property name="dataColumnName" value="DATA_COLUMN"/>
         <property name="timestampColumnName" value="TIMESTAMP_COLUMN"/>
         <property name="timestampColumnType" value="BIGINT"/>
         <property name="connectionFactoryClass" value="org.infinispan.loaders.jdbc.connectionfactory.PooledConnectionFactory"/>
         <property name="connectionUrl" value="jdbc:h2:mem:string_based_db;DB_CLOSE_DELAY=-1"/>
         <property name="userName" value="sa"/>
         <property name="driverClass" value="org.h2.Driver"/>
         <property name="idColumnType" value="VARCHAR(255)"/>
         <property name="dataColumnType" value="BINARY"/>
         <property name="dropTableOnExit" value="true"/>
         <property name="createTableOnStart" value="true"/>
      </properties>
   </loader>
</loaders>
    </namedCache>

    <!-- ***************************** -->
    <!--  Cache to store Lucene locks  -->
    <!-- ***************************** -->
    <namedCache
        name="LuceneIndexesLocking">
        <clustering
            mode="replication">
            <stateTransfer
                fetchInMemoryState="true" />
            <sync
                replTimeout="25000" />
        </clustering>
    </namedCache>

</infinispan>

任何指示或指导都会非常有帮助。

问候,公羊


我动了一点。jar 文件 [hibernate-search-infinispan.jar、infinispan-lucene-directory.jar 和 infinispan-core.jar] 不在类路径中。这就是之前错误的原因。我清除了它,但在尝试使用 JDBC 缓存存储在 DB 中存储 infinispan 创建的索引时遇到了新错误。

这次我检查了 jar 文件的依赖关系。当我将 infinispan-cachestore-jdbc-5.2.1.Final.jar 文件复制到类路径时,它堆积了无数错误消息。错误堆栈跟踪是,

17:46:08,301 错误 [org.jboss.msc.service.fail] (ServerService 线程池 -- 55) MSC00001: 无法启动服务 jboss.persistenceunit."inov8.war#inov8": org.jboss.msc.service .StartException in service jboss.persistenceunit."inov8.war#inov8": org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager xx.inov8.domain.innovation.InnovationComponent at org.jboss.as.jpa.service。 PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_17] 在 java.util.concurrent.ThreadPoolExecutor$Worker.run( ThreadPoolExecutor.java:615) [rt.jar:1.7.0_17] at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17] at org.jboss.threads.JBossThread.run( JBossThread.java:122) 由:org.hibernate.search 引起。SearchException:HSEARCH000103:无法在 org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:230) 在 org.hibernate.search.indexes.impl.IndexManagerHolder 初始化 IndexManager xx.inov8.domain.innovation.InnovationComponent .buildEntityIndexBinding(IndexManagerHolder.java:102) 在 org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:414) 在 org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:222) 在 org. hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:146) 在 org.hibernate.search.event.impl.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:130) 在 org.hibernate.search.hcore.impl.HibernateSearchIntegrator。在组织中集成(HibernateSearchIntegrator.java:83)。hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:303) 在 org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742) 在 org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:94) 在 org.hibernate .ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) 在 org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) 在 org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74) 在 org. jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57) at org.jboss.as.jpa.service .PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99) ...4 更多原因:org.hibernate.search.SearchException:无法初始化目录提供程序:org.hibernate.search.store.impl.DirectoryProviderFactory.createDirectoryProvider(DirectoryProviderFactory.java:87) 处的 xx.inov8.domain.innovation.InnovationComponent org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.createDirectoryProvider(DirectoryBasedIndexManager.java:232) 在 org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:100) 在 org.hibernate.search.indexes。 impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:227) ... 19 更多原因:org.infinispan.config.ConfigurationException:org.infinispan.CacheConfigurationException:无法实例化类 org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore org.infinispan.configuration.parsing.Parser。在 org.infinispan.manager.DefaultCacheManager 的 org.infinispan.configuration.parsing.Parser.parse(Parser.java:130) 解析(Parser.java:168)。(DefaultCacheManager.java:368) 在 org.infinispan.manager。 DefaultCacheManager.(DefaultCacheManager.java:340) at org.infinispan.manager.DefaultCacheManager.(DefaultCacheManager.java:327) at org.hibernate.search.infinispan.CacheManagerServiceProvider.start(CacheManagerServiceProvider.java:93) at org.hibernate.search .engine.impl.StandardServiceManager$ServiceProviderWrapper.startVirtual(StandardServiceManager.java:178) at org.hibernate.search.engine.impl.StandardServiceManager.requestService(StandardServiceManager.java:124) at org.hibernate.search.infinispan.impl.InfinispanDirectoryProvider .initialize(InfinispanDirectoryProvider.java:86) 在 org.hibernate.search.store.impl.DirectoryProviderFactory。createDirectoryProvider(DirectoryProviderFactory.java:84) ... 22 更多原因:org.infinispan.CacheConfigurationException:无法在 org.infinispan.util.Util.loadClass(Util. java:90) 在 org.infinispan.util.Util.getInstance(Util.java:208) 在 org.infinispan.configuration.parsing.Parser.parseLoader(Parser.java:546) 在 org.infinispan.configuration.parsing.Parser .parseLoaders(Parser.java:524) 在 org.infinispan.configuration.parsing.Parser.parseCache(Parser.java:295) 在 org.infinispan.configuration.parsing.Parser.parseNamedCache(Parser.java:254) 在 org. infinispan.configuration.parsing.Parser.doParse(Parser.java:211) at org.infinispan.configuration.parsing.Parser.parse(Parser.java:154) ... 31 更多原因:java.lang.ClassNotFoundException: org .infinispan.loaders。jdbc.stringbased.JdbcStringBasedCacheStore 在 java.net.URLClassLoader$1.run(URLClassLoader.java:366) [rt.jar:1.7.0_17] 在 java.net.URLClassLoader$1.run(URLClassLoader.java:355) [rt.jar :1.7.0_17] 在 java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_17] 在 java.net.URLClassLoader.findClass(URLClassLoader.java:354) [rt.jar:1.7.0_17]在 java.lang.ClassLoader.loadClass(ClassLoader.java:423) [rt.jar:1.7.0_17] 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [rt.jar:1.7.0_17]在 java.lang.ClassLoader.loadClass(ClassLoader.java:356) [rt.jar:1.7.0_17] 在 java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17] 在 java.lang。 Class.forName(Class.java:266) [rt.jar:1.7.0_17] at org.infinispan.util.Util.loadClassStrict(Util.java:127) at org.infinispan.util.Util.loadClass(Util.java :88) ... 38 更多JdbcStringBasedCacheStore 在 java.net.URLClassLoader$1.run(URLClassLoader.java:366) [rt.jar:1.7.0_17] 在 java.net.URLClassLoader$1.run(URLClassLoader.java:355) [rt.jar:1.7.0_17 ] 在 java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_17] 在 java.net.URLClassLoader.findClass(URLClassLoader.java:354) [rt.jar:1.7.0_17] 在 java.lang .ClassLoader.loadClass(ClassLoader.java:423) [rt.jar:1.7.0_17] 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [rt.jar:1.7.0_17] 在 java.lang .ClassLoader.loadClass(ClassLoader.java:356) [rt.jar:1.7.0_17] at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17] at java.lang.Class.forName( Class.java:266) [rt.jar:1.7.0_17] 在 org.infinispan.util.Util.loadClassStrict(Util.java:127) 在 org.infinispan.util.Util.loadClass(Util.java:88) 。 .. 还有 38 个JdbcStringBasedCacheStore 在 java.net.URLClassLoader$1.run(URLClassLoader.java:366) [rt.jar:1.7.0_17] 在 java.net.URLClassLoader$1.run(URLClassLoader.java:355) [rt.jar:1.7.0_17 ] 在 java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_17] 在 java.net.URLClassLoader.findClass(URLClassLoader.java:354) [rt.jar:1.7.0_17] 在 java.lang .ClassLoader.loadClass(ClassLoader.java:423) [rt.jar:1.7.0_17] 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [rt.jar:1.7.0_17] 在 java.lang .ClassLoader.loadClass(ClassLoader.java:356) [rt.jar:1.7.0_17] at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17] at java.lang.Class.forName( Class.java:266) [rt.jar:1.7.0_17] 在 org.infinispan.util.Util.loadClassStrict(Util.java:127) 在 org.infinispan.util.Util.loadClass(Util.java:88) 。 .. 还有 38 个在 java.net.URLClassLoader$1.run(URLClassLoader.java:355) [rt.jar:1.7.0_17] 在 java.security.AccessController.doPrivileged 运行(URLClassLoader.java:366)[rt.jar:1.7.0_17] (本机方法)[rt.jar:1.7.0_17] at java.net.URLClassLoader.findClass(URLClassLoader.java:354) [rt.jar:1.7.0_17] at java.lang.ClassLoader.loadClass(ClassLoader.java: 423) [rt.jar:1.7.0_17] 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [rt.jar:1.7.0_17] 在 java.lang.ClassLoader.loadClass(ClassLoader.java: 356) [rt.jar:1.7.0_17] 在 java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17] 在 java.lang.Class.forName(Class.java:266) [rt. jar:1.7.0_17] 在 org.infinispan.util.Util.loadClassStrict(Util.java:127) 在 org.infinispan.util.Util.loadClass(Util.java:88) ... 38 更多在 java.net.URLClassLoader$1.run(URLClassLoader.java:355) [rt.jar:1.7.0_17] 在 java.security.AccessController.doPrivileged 运行(URLClassLoader.java:366)[rt.jar:1.7.0_17] (本机方法)[rt.jar:1.7.0_17] at java.net.URLClassLoader.findClass(URLClassLoader.java:354) [rt.jar:1.7.0_17] at java.lang.ClassLoader.loadClass(ClassLoader.java: 423) [rt.jar:1.7.0_17] 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [rt.jar:1.7.0_17] 在 java.lang.ClassLoader.loadClass(ClassLoader.java: 356) [rt.jar:1.7.0_17] 在 java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17] 在 java.lang.Class.forName(Class.java:266) [rt. jar:1.7.0_17] 在 org.infinispan.util.Util.loadClassStrict(Util.java:127) 在 org.infinispan.util.Util.loadClass(Util.java:88) ... 38 更多355) [rt.jar:1.7.0_17] 在 java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_17] 在 java.net.URLClassLoader.findClass(URLClassLoader.java:354) [rt.jar:1.7.0_17] jar:1.7.0_17] 在 java.lang.ClassLoader.loadClass(ClassLoader.java:423) [rt.jar:1.7.0_17] 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [rt.jar:1.7.0_17] jar:1.7.0_17] 在 java.lang.ClassLoader.loadClass(ClassLoader.java:356) [rt.jar:1.7.0_17] 在 java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17 ] 在 java.lang.Class.forName(Class.java:266) [rt.jar:1.7.0_17] 在 org.infinispan.util.Util.loadClassStrict(Util.java:127) 在 org.infinispan.util.Util .loadClass(Util.java:88) ... 38 更多355) [rt.jar:1.7.0_17] 在 java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_17] 在 java.net.URLClassLoader.findClass(URLClassLoader.java:354) [rt.jar:1.7.0_17] jar:1.7.0_17] 在 java.lang.ClassLoader.loadClass(ClassLoader.java:423) [rt.jar:1.7.0_17] 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [rt.jar:1.7.0_17] jar:1.7.0_17] 在 java.lang.ClassLoader.loadClass(ClassLoader.java:356) [rt.jar:1.7.0_17] 在 java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17 ] 在 java.lang.Class.forName(Class.java:266) [rt.jar:1.7.0_17] 在 org.infinispan.util.Util.loadClassStrict(Util.java:127) 在 org.infinispan.util.Util .loadClass(Util.java:88) ... 38 更多java.lang 的 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [rt.jar:1.7.0_17] 的 ClassLoader.loadClass(ClassLoader.java:423) [rt.jar:1.7.0_17]。 ClassLoader.loadClass(ClassLoader.java:356) [rt.jar:1.7.0_17] at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17] at java.lang.Class.forName(Class .java:266) [rt.jar:1.7.0_17] 在 org.infinispan.util.Util.loadClassStrict(Util.java:127) 在 org.infinispan.util.Util.loadClass(Util.java:88) .. . 38 更多java.lang 的 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [rt.jar:1.7.0_17] 的 ClassLoader.loadClass(ClassLoader.java:423) [rt.jar:1.7.0_17]。 ClassLoader.loadClass(ClassLoader.java:356) [rt.jar:1.7.0_17] at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_17] at java.lang.Class.forName(Class .java:266) [rt.jar:1.7.0_17] 在 org.infinispan.util.Util.loadClassStrict(Util.java:127) 在 org.infinispan.util.Util.loadClass(Util.java:88) .. . 38 更多127) 在 org.infinispan.util.Util.loadClass(Util.java:88) ... 38 更多127) 在 org.infinispan.util.Util.loadClass(Util.java:88) ... 38 更多

任何配置 jdbc 缓存存储或指针的示例都会非常有帮助。

谢谢和问候,公羊

4

1 回答 1

1

按照休眠搜索文档中的指南,我通过将休眠搜索模块(v4.3 是我能找到的最接近 AS7.2 附带的 v4.2)从文件hibernate-search-modules-4.3.0.Final-jbossas-72-dist.zip添加到 JBoss AS7 的modules目录中,然后在war文件中添加jboss-deployment-structure.xml

   <jboss-deployment-structure>
      <deployment>
          <dependencies>
              <module name="org.hibernate.search.orm"/>
          </dependencies>
      </deployment>
  </jboss-deployment-structure>

我在这里使用了解决方法https://issues.jboss.org/browse/WFLY-1632,添加

<module name="org.infinispan.cachestore.jdbc"/>

进入文件modules/system/layers/base/org/infinispan/main/module.xml

在 JBoss'sstandalone-ha.xml中,我添加了一个新cache-container元素,它下面有三个replicated-cache元素:

<cache-container name="hibernateSearch" default-cache="repl">
    <transport lock-timeout="60000"/>
<replicated-cache name="LuceneIndexesMetadata" mode="SYNC"  >
 <binary-keyed-jdbc-store datasource="java:/db/[datasource in JNDI]"
          passivation="false" shared="true" purge="false">
    <property name="createTableOnStart" >true</property>
    <binary-keyed-table>
        <id-column name="ID_COLUMN" type="VARCHAR(255)" />
        <data-column name="DATUM" type="BLOB"/>
    </binary-keyed-table>
 </binary-keyed-jdbc-store>
</replicated-cache>

<!-- Above replicated-cache section additionally repeated for
name="LuceneIndexesData",name="LuceneIndexesLocking"   -->

</cache-container>

并将以下内容添加到persistence.xml

<property name="hibernate.search.infinispan.cachemanager_jndiname" value="java:jboss/infinispan/container/hibernateSearch" />
<property name="hibernate.search.default.directory_provider" value="infinispan" />

我没有部署的战争中包含任何核心休眠或休眠搜索 jar,因为它们是由 JBoss 提供的,所以我更新了战争 POM 以排除它们:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-search</artifactId>
    <version>4.2.0.Final</version>
    <scope>provided</scope>
</dependency>
... and so on for all other hibernate jars
于 2013-11-11T09:55:33.940 回答