我試圖配置一個JDBC支持的Infinispan緩存,用於在Wildfly 10/JBoss EAP 7上存儲Hibernate搜索索引。在我的應用程序服務器中安裝了infinispan.org上的Infinispan 8.1.x Wildfly/JBoss模塊,並且我最終得到了一個基本的使用文件持久性的infinispan.xml文件,現在我試圖將其更改爲使用JDBC進行持久化。我infinispan.xml文件看起來像這樣:Infinispan/Wildfly:在命名空間中找不到元素'string-keyed-jdbc-store'的解析器
<?xml version="1.0" encoding="UTF-8"?>
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:8.1 http://www.infinispan.org/schemas/infinispan-config-8.1.xsd
urn:infinispan:config:jdbc:8.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-8.0.xsd"
xmlns="urn:infinispan:config:8.1" xmlns:jdbc="urn:infinispan:config:store:jdbc:8.0">
<jgroups>
<stack-file name="default-jgroups-udp" path="default-configs/default-jgroups-udp.xml" />
</jgroups>
<cache-container name="HibernateSearch" default-cache="default"
statistics="false" shutdown-hook="DONT_REGISTER">
<transport stack="default-jgroups-udp" />
<jmx duplicate-domains="true" />
<!-- *************************************** -->
<!-- Cache to store Lucene's file metadata -->
<!-- *************************************** -->
<replicated-cache name="LuceneIndexesMetadata" mode="SYNC"
remote-timeout="25000">
<locking striping="false" acquire-timeout="10000"
concurrency-level="500" write-skew="false" />
<transaction mode="NONE" />
<eviction max-entries="-1" strategy="NONE" />
<expiration max-idle="-1" />
<persistence passivation="false">
<file-store preload="true" purge="true"
path="${jboss.server.temp.dir}/indexes" />
</persistence>
<indexing index="NONE" />
<state-transfer enabled="true" timeout="480000"
await-initial-transfer="true" />
</replicated-cache>
<!-- **************************** -->
<!-- Cache to store Lucene data -->
<!-- **************************** -->
<replicated-cache name="LuceneIndexesData" mode="SYNC"
remote-timeout="25000">
<locking striping="false" acquire-timeout="10000"
concurrency-level="500" write-skew="false" />
<transaction mode="NONE" />
<eviction max-entries="-1" strategy="NONE" />
<expiration max-idle="-1" />
<persistence passivation="false">
<string-keyed-jdbc-store xmlns="urn:infinispan:config:store:jdbc:8.0"
fetch-state="false" read-only="false" purge="false">
<data-source jndi-url="java:jboss/datasources/InfinispanCacheDS" />
<string-keyed-table drop-on-exit="false"
create-on-start="true" prefix="ISPN_STRING_TABLE">
<id-column name="ID_COLUMN" type="VARCHAR(255)" />
<data-column name="DATA_COLUMN" type="BINARY" />
<timestamp-column name="TIMESTAMP_COLUMN" type="BIGINT" />
</string-keyed-table>
</string-keyed-jdbc-store>
</persistence>
<!-- <persistence passivation="false"> <file-store preload="true" purge="true"
path="${jboss.server.temp.dir}/indexes" /> </persistence> -->
<indexing index="NONE" />
<state-transfer enabled="true" timeout="480000"
await-initial-transfer="true" />
</replicated-cache>
<!-- ***************************** -->
<!-- Cache to store Lucene locks -->
<!-- ***************************** -->
<replicated-cache name="LuceneIndexesLocking" mode="SYNC"
remote-timeout="25000">
<locking striping="false" acquire-timeout="10000"
concurrency-level="500" write-skew="false" />
<transaction mode="NONE" />
<eviction max-entries="-1" strategy="NONE" />
<expiration max-idle="-1" />
<persistence passivation="false">
<file-store preload="true" purge="true"
path="${jboss.server.temp.dir}/indexes" />
</persistence>
<indexing index="NONE" />
<state-transfer enabled="true" timeout="480000"
await-initial-transfer="true" />
</replicated-cache>
</cache-container>
</infinispan>
我也是用下面的jboss-部署-structure.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<!-- Core Java/Java EE Dependencies -->
<module name="javax.transaction.api" export="true" services="import" />
<!-- JPA/Hibernate Search Dependencies -->
<module name="javax.persistence.api" export="true" />
<module name="org.hibernate.search.engine" export="true"
services="import" slot="5.5" />
<module name="org.hibernate.search.orm" export="true"
services="import" slot="5.5" />
<module name="org.infinispan.hibernate-search.directory-provider"
slot="for-hibernatesearch-5.5" export="true" services="import" /><!--
<module name="org.apache.lucene" export="true" services="import" /> <module
name="org.infinispan.lucene-directory" slot="ispn-8.1" /> -->
<module name="org.infinispan.core" slot="ispn-8.1" services="import"
export="true" />
<module name="org.infinispan.persistence.jdbc" slot="ispn-8.1"
services="import" export="true" />
<module name="org.infinispan.persistence.remote" slot="ispn-8.1"
services="import" export="true" />
</dependencies>
</deployment>
</jboss-deployment-structure>
然而,當我部署我的應用程序出現以下情況例外:
ISPN000327: Cannot find a parser for element 'string-keyed-jdbc-store' in namespace 'urn:infinispan:config:store:jdbc:8.0'. Check that your configuration is up-to date for this version of Infinispan.
如果我將持久性從JDBC更改爲「文件」,一切工作正常。但是,一旦我放入JDBC參數,就會出現解析錯誤。我確信我正在做一些小事而愚蠢的事情,但我不能爲我的生活找出什麼。任何幫助將不勝感激!!
太棒了!非常感謝你在這樣的深度上對此進行研究。我會在明天嘗試你的解決方法,並讓你知道它是如何發生的。 – Shadowman
我正在取得進展!按照建議,我將緩存存儲添加到module.xml文件中。我現在看到與JDBC高速緩存存儲相關的日誌語句,並查看正在數據庫中創建的表。 不過,現在我得到象這樣的錯誤: ISPN000136:錯誤執行命令PutKeyValueCommand,書寫鍵[pending_segments_1 | 0 | 1048576 |]:org.infinispan.persistence.keymappers.UnsupportedKeyTypeException:不支持鍵:'org.infinispan.lucene.ChunkCacheKey'鍵:pending_segments_1 | 0 | 1048576 | 想法? –
Shadowman
看起來像是同一類問題的不同細節。您需要修補'org.infinispan.persistence.jdbc'模塊的module.xml,以允許它從'org.infinispan.lucene-directory'模塊導入服務:這包含要轉換的服務將鍵轉換爲字符串,以允許使用字符串鍵控存儲策略。 – Sanne