【问题标题】:BigMemory 4.0.5 Terrocatta Distributed + hibernate second level cache not able to configureBigMemory 4.0.5 Terrocatta Distributed + hibernate 二级缓存无法配置
【发布时间】:2013-12-23 10:28:59
【问题描述】:

我正在使用 Bigmemory Max 4.0.5,因为 terracotta 将我的应用程序的缓存分配为休眠二级缓存,但在服务器启动时出现以下异常。

引起:com.tc.config.schema.setup.ConfigurationSetupException:


来自“localhost:9510”服务器的基本配置中的配置数据不符合 Terracotta 模式: [0]:第 7 行,第 5 列:不允许属性(不允许使用通配符):在元素服务器中是安全的 [1]:第 9 行,第 9 列:元素服务器中的预期元素“服务器”而不是“镜像组” [2]:第 28 行,第 9 列:元素服务器中的预期元素“服务器”而不是“更新检查” [3]:第 32 行,第 9 列:元素服务器中的预期元素“服务器”而不是“垃圾收集” [4]:第 37 行,第 9 列:元素服务器中的预期元素“服务器”而不是“可重新启动” [5]:第 38 行,第 9 列:元素服务器中的预期元素“服务器”而不是“客户端重新连接窗口”

我的 tc-config.xml 如下:-

<?xml version="1.0" encoding="UTF-8" ?>
<tc:tc-config xmlns:tc="http://www.terracotta.org/config"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-8.xsd">

  <servers>
    <server host="localhost" name="MyServerName">
      <!-- Specify the path where the server should store its data. -->
      <data>E:\Bratton\Pocs\bigmemory-max-4.0.5\data-test</data>
       <!-- Specify the port where the server should listen for client 
       traffic. -->
       <tsa-port>9510</tsa-port>
       <jmx-port>9520</jmx-port>
       <tsa-group-port>9530</tsa-group-port>
       <!-- Enable BigMemory on the server. -->
       <offheap>
         <enabled>true</enabled>
         <maxDataSize>512m</maxDataSize>
       </offheap>
     </server>
    <!-- Add the restartable element for Fast Restartability (optional). -->
    <restartable enabled="true"/>
  </servers>
  <clients>
    <logs>logs-%i</logs>
  </clients>
</tc:tc-config>

下面是 ehcache.xml :-

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
     <terracottaConfig url="localhost:9510"/>
    <defaultCache
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120">
       <terracotta/>    

    </defaultCache>        

</ehcache>

以下是我正在使用的依赖项

 <dependency> 
                <groupId>net.sf.ehcache</groupId> 
                <artifactId>ehcache-core</artifactId> 
                <version>2.6.0</version> 
            </dependency>

            <dependency>
              <groupId>org.hibernate</groupId>
              <artifactId>hibernate-ehcache</artifactId>
              <version>4.2.4.Final</version>
            </dependency>

            <dependency> 
                <groupId>net.sf.ehcache</groupId> 
                <artifactId>ehcache-terracotta</artifactId> 
                <version>2.6.0</version> 
            </dependency> 

            <dependency> 
                <groupId>org.terracotta</groupId> 
                <artifactId>terracotta-toolkit-runtime-ee</artifactId>
                <version>4.0.5</version> 
            </dependency> 

我尝试了各种依赖版本的组合,但没有任何帮助。请让我知道这出了什么问题。

提前致谢。

【问题讨论】:

    标签: hibernate caching terracotta ehcache-bigmemory


    【解决方案1】:

    您是否尝试使用镜像组标签? 有效的配置如下所示:

    <?xml version="1.0" encoding="UTF-8" ?>
    <tc:tc-config xmlns:tc="http://www.terracotta.org/config"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-8.xsd">
    
      <servers>
        <mirror-group group-name="tsa01">
          <server host="localhost" name="MyServerName">
            <!-- Specify the path where the server should store its data. -->
            <data>E:\Bratton\Pocs\bigmemory-max-4.0.5\data-test</data>
            <!-- Specify the port where the server should listen for client
                    traffic. -->
            <tsa-port>9510</tsa-port>
            <jmx-port>9520</jmx-port>
            <tsa-group-port>9530</tsa-group-port>
            <!-- Enable BigMemory on the server. -->
            <offheap>
              <enabled>true</enabled>
              <maxDataSize>512m</maxDataSize>
            </offheap>
          </server>
        </mirror-group>
        <!-- Add the restartable element for Fast Restartability (optional). -->
        <restartable enabled="true"/>
      </servers>
      <clients>
        <logs>logs-%i</logs>
      </clients>
    </tc:tc-config>
    

    【讨论】:

    • 无论如何感谢您的回复
    • 奇怪的是它不适合你:你还有 ConfigurationSetupException 吗?如果是这样,那么您的配置中还有其他问题;您可以使用您的 IDE 针对架构验证 xml 以找出您的错误。您还可以阅读发行说明,名为“简化配置文件”的章节terracotta.org/confluence/display/release/…
    【解决方案2】:

    hibernate-ehcache 依赖于 ehcache-core,其版本比您指定的版本旧。尝试按如下方式禁用此依赖项:

        <dependency> 
            <groupId>org.hibernate</groupId>            
            <artifactId>hibernate-ehcache</artifactId>
            <version>4.2.4.Final</version>
            <exclusions>
                <exclusion>
                    <artifactId>ehcache-core</artifactId>
                    <groupId>net.sf.ehcache</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    

    【讨论】:

      猜你喜欢
      • 2014-09-11
      • 2016-06-05
      • 2014-10-18
      • 1970-01-01
      • 2015-09-07
      • 1970-01-01
      • 1970-01-01
      • 2015-05-14
      • 1970-01-01
      相关资源
      最近更新 更多