简体   繁体   中英

Jetty Session Clustering Using XML

Im trying to configure jetty session clustering using database. Is there a way to change the database name. I dont want to use the default name "session". Also i want to change the table name for both sessionidtable and sessiontable but I am having trouble setting up the configuration using xml. Here my code :

<?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>

But in the logs it says that :

Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.session.SessionTableSchema at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) 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) at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86) at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.nodeClass(XmlConfiguration.java:364) at 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) at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:262) at org.eclipse.jetty.xml.XmlConfiguration$1.run(X mlConfiguration.java:1243) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174) ... 7 more

Try

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

It does say org.eclipse.jetty.server.session.SessionTableSchema in the jetty documentation but the links are broken. The above code is the only way I could get it to work and matches the API documentation. The id table is handled very similarly.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM