使用XML

时间:2016-06-28 09:40:53

标签: java database session jetty-9

我尝试使用数据库配置jetty会话群集。有没有办法更改数据库名称。我不想使用默认名称" session"。此外,我想更改sessionidtable和sessiontable的表名,但我在使用xml设置配置时遇到问题。这是我的代码:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">


  <!-- ===================================================================== -->
  <!-- Configure a SessionIdManager                                          -->
  <!-- ===================================================================== -->
  <Set name="sessionIdManager">
    <New id="idMgr" class="org.eclipse.jetty.server.session.JDBCSessionIdManager">
      <Arg>
        <Ref refid="Server"/>
      </Arg>
      <Set name="workerName"><Property name="jetty.jdbcSession.workerName" default="node1"/></Set>
      <Set name="scavengeInterval"><Property name="jetty.jdbcSession.scavenge" default="1800"/></Set>

      <!-- ===================================================================== -->
      <!-- Uncomment either the datasource or driver setup and configure         -->
      <!-- ===================================================================== -->

      <!--
          <Set name="DatasourceName"><Property name="jetty.jdbcSession.datasource" default="javax.sql.DataSource/default"/></Set>
          <Call name="setDriverInfo">
          <Arg><Property name="jetty.jdbcSession.driverClass"/></Arg>
          <Arg><Property name="jetty.jdbcSession.connectionURL"/></Arg>
        </Call>
      -->

    </New>
  </Set>

  <New id="idTableSchema " class="org.eclipse.jetty.server.session.SessionTableSchema">
    <Set name="setTableName">mysession</Set>
  </New>

</Configure>

但在日志中它说:

引起:java.lang.ClassNotFoundException:org.eclipse.jetty.server.session.SessionTableSchema         在java.net.URLClassLoader $ 1.run(未知来源)         在java.net.URLClassLoader $ 1.run(未知来源)         at java.security.AccessController.doPrivileged(Native Method)         at java.net.URLClassLoader.findClass(Unknown Source)         at java.lang.ClassLoader.loadClass(Unknown Source)         at java.lang.ClassLoader.loadClass(Unknown Source)         在org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)         at org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.nodeClass(XmlConfiguration.java:364)         在org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.newObj(XmlConfiguration.java:754)         at org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.configure(XmlConfiguration.java:423)         at org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.configure(XmlConfiguration.java:354)         在org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:262)         在org.eclipse.jetty.xml.XmlConfiguration $ 1.run(XmlConfiguration.java:1243)         at java.security.AccessController.doPrivileged(Native Method)         在org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)         ......还有7个

1 个答案:

答案 0 :(得分:0)

尝试

<Set name="sessionTableSchema">
  <New id="tableSchema" class="org.eclipse.jetty.server.session.JDBCSessionIdManager$SessionTableSchema">
    <Set name="tableName">mysession</Set>
  </New>
</set>

它确实在jetty文档中说org.eclipse.jetty.server.session.SessionTableSchema但是链接被破坏了。上面的代码是我可以使用它并匹配API文档的唯一方法。 id表的处理方式非常相似。

http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/server/session/JDBCSessionIdManager.html