【问题标题】:Terracotta and shiro兵马俑和四郎
【发布时间】:2013-08-25 01:18:49
【问题描述】:

我想使用 terracotta + Shiro 来实现 SSO。当我尝试对其进行测试时,出现错误:

    The configuration data in the base configuration from server at 'localhost:9510' does not obey the Terracotta schema:
    [0]: Line 4, column 5: Expected elements 'tc-properties servers clients' instead of 'system' here in element tc-config@http://www.terracotta.org/config
    [1]: Line 16, column 13: Expected elements 'offheap authentication http-authentication data-backup tsa-port jmx-port tsa-group-port security' instead of 'statistics' here in element server
    [2]: Line 19, column 13: Expected elements 'offheap authentication http-authentication data-backup tsa-port jmx-port tsa-group-port security' instead of 'dso-port' here in element server
    [3]: Line 21, column 13: Expected elements 'offheap authentication http-authentication data-backup tsa-port tsa-group-port security' instead of 'l2-group-port' here in element server
    [4]: Line 32, column 13: Expected elements 'offheap http-authentication data-backup tsa-port tsa-group-port security' instead of 'dso' here in element server
    [5]: Line 50, column 9: Expected elements 'server mirror-group update-check garbage-collection restartable client-reconnect-window' instead of 'mirror-groups' here in element servers
    [6]: Line 63, column 9: Expected elements 'server mirror-group update-check garbage-collection restartable client-reconnect-window' instead of 'ha' here in element servers
    [7]: Line 86, column 5: Element not allowed: application in element tc-config@http://www.terracotta.org/config

谁能帮我找出问题所在?

这是我的配置:

tc客户端上的ehcache.xml:

<ehcache  name="Plugin_Ehcache"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="ehcache.xsd"
     updateCheck="false" monitoring="autodetect"
     dynamicConfig="false">

<diskStore path="java.io.tmpdir/shiro-ehcache"/>

<defaultCache
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="120"
        timeToLiveSeconds="120"
        overflowToDisk="false"
        diskPersistent="false"
        diskExpiryThreadIntervalSeconds="120">
    <terracotta/>
</defaultCache>
<cache name="shiro-activeSessionCache"
       maxElementsInMemory="10000"
       eternal="true"
       timeToLiveSeconds="0"
       timeToIdleSeconds="0"
       diskPersistent="false"
       overflowToDisk="false"
       diskExpiryThreadIntervalSeconds="600">
    <terracotta/>
</cache>    

<terracottaConfig url="localhost:9510"/>     
</ehcache> 

tc 服务器上的 tc-config.xml

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

<tc-properties>
<property name="l2.l1reconnect.enabled" value="true"/>
<property name="l2.l1reconnect.timeout.millis" value="5000"/>
<property name="sigar.enabled" value="false"/>
<property name="search.use.commit.thread" value="false"/>
<property name="search.lucene.use.ram.directory" value="true"/>
<property name="search.query.wait.for.txns" value="false"/>
<property name="logging.maxLogFileSize" value="100"/>
<property name="logging.maxBackups" value="10"/>
</tc-properties>

<system>
 <configuration-model>development</configuration-model>
</system> 

  <servers>
    <server host="localhost" name="Terracotta Server1">
      <!-- Specify the path where the server should store its data. -->
            <data>C:\Program Files\Terracotta\terracotta-3.7.5\server\server-data</data>
            <logs>C:\Program Files\Terracotta\terracotta-3.7.5\server\server-logs</logs>
            <index>C:\Program Files\Terracotta\terracotta-3.7.5\server\server-index</index>
            <statistics>C:\Program Files\Terracotta\terracotta-3.7.5\server\server-statistics</statistics>

       <!-- Specify the port where the server should listen for client 
       traffic. -->
         <dso-port bind="127.0.0.1">9510</dso-port>
         <jmx-port  bind="127.0.0.1">9520</jmx-port>
          <l2-group-port bind="localhost">9530</l2-group-port>
          <!--jmx-port bind="xxx.xxx.xxx.xxx">9520</jmx-port>
       <tsa-port>9510</tsa-port>

       <tsa-group-port>9530</tsa-group-port-->
       <!-- Enable BigMemory on the server. -->
       <!--offheap>
         <enabled>true</enabled>
         <maxDataSize>4g</maxDataSize>
       </offheap-->

     <authentication/> 

       <dso>
    <client-reconnect-window>120</client-reconnect-window>
    <persistence>
      <mode>permanent-store</mode>
           <!--mode>temporary-swap-only</mode-->
            <!--<offheap>
        <enabled>false</enabled>
        <maxDataSize>450m</maxDataSize>
      </offheap>-->
    </persistence>
    <garbage-collection>
      <enabled>true</enabled>
      <verbose>false</verbose>
      <interval>300</interval>
    </garbage-collection>
  </dso>

     </server>

      <mirror-groups>
   <mirror-group group-name="group1">
     <members>
       <member>Terracotta Server1</member>
     </members>
     <ha>
       <mode>networked-active-passive</mode>
       <networked-active-passive>
         <election-time>5</election-time>
       </networked-active-passive>
     </ha>
    </mirror-group>
 </mirror-groups>     
 <ha>
   <mode>networked-active-passive</mode>
   <networked-active-passive>
     <election-time>5</election-time>
   </networked-active-passive>
 </ha>

      <update-check>
  <enabled>false</enabled>
</update-check>

    <!-- Add the restartable element for Fast Restartability (optional). -->
    <!--restartable enabled="true"/-->
  </servers>
  <clients>
    <logs>logs-%i</logs>
  </clients>
</tc:tc-config>

【问题讨论】:

    标签: shiro terracotta


    【解决方案1】:

    您使用的是哪个版本的 Terracotta 库? tc-config.xml 在 4.x 版本以后有一些更新的标签。请确保 tc-config 和 ehcache xml 遵循架构。

    干杯, 里达夫

    【讨论】:

      【解决方案2】:

      我看到你试图在你的 tc 配置中使用 mirror-group 标记,但似乎你放错了位置。

      例如,这个配置应该可以工作:

      <?xml version="1.0" encoding="UTF-8" ?>
      <tc:tc-config xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-8.xsd"
                    xmlns:tc="http://www.terracotta.org/config"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      
        <tc-properties>
          <property name="l2.l1reconnect.enabled" value="true"/>
          <property name="l2.l1reconnect.timeout.millis" value="5000"/>
          <property name="sigar.enabled" value="false"/>
          <property name="search.use.commit.thread" value="false"/>
          <property name="search.lucene.use.ram.directory" value="true"/>
          <property name="search.query.wait.for.txns" value="false"/>
          <property name="logging.maxLogFileSize" value="100"/>
          <property name="logging.maxBackups" value="10"/>
        </tc-properties>
      
        <servers>
          <mirror-group group-name="group1">
            <server host="localhost" name="Terracotta Server1">
              <!-- Specify the path where the server should store its data. -->
              <data>C:\Program Files\Terracotta\terracotta-3.7.5\server\server-data</data>
              <logs>C:\Program Files\Terracotta\terracotta-3.7.5\server\server-logs</logs>
              <index>C:\Program Files\Terracotta\terracotta-3.7.5\server\server-index</index>
              <!--<statistics>C:\Program Files\Terracotta\terracotta-3.7.5\server\server-statistics</statistics>-->
      
              <!-- 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>
      
              <authentication/>
      
            </server>
          </mirror-group>
      
          <update-check>
            <enabled>false</enabled>
          </update-check>
      
          <!-- Add the restartable element for Fast Restartability (optional). -->
          <!--restartable enabled="true"/-->
        </servers>
        <clients>
          <logs>logs-%i</logs>
        </clients>
      </tc:tc-config>
      

      【讨论】:

        【解决方案3】:

        查看定义用于构建 xml 配置文件的架构的这一行:

        <tc:tc-config xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-8.xsd
        

        输入提供的地址,看看嵌套的xml元素和属性是如何被允许使用的。

        例如,在 terracotta-6.xsd 和 terracotta-7.xsd 中允许元素 dso-port,但在您声明的 terracotta-8.xsd 中不允许。

        顺便说一句,根据您使用的 terracotta 服务器版本,由于元素不兼容,应声明适当的 xml 架构。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-02-15
          • 2014-03-04
          • 1970-01-01
          • 2010-10-21
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多