简体   繁体   中英

Jetty session clustering ClassNotFoundException

I am implementing jetty session clustering using http://www.eclipse.org/jetty/documentation/current/session-clustering-jdbc.html

My jetty-jdbc-sessions.xml file looks like

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

</Configure>

Start.ini

# --------------------------------------- 
# Module: jdbc-sessions
--module=jdbc-sessions
## JDBC Session config

## Unique identifier for this node in the cluster
  jetty.jdbcSession.workerName=node1

## The interval in seconds between sweeps of the scavenger
# jetty.jdbcSession.scavenge=600

## Uncomment either the datasource name or driverClass and connectionURL
# jetty.jdbcSession.datasource=sessions
 jetty.jdbcSession.driverClass=com.mysql.jdbc.Driver
 jetty.jdbcSession.connectionURL=jdbc:mysql://127.0.0.1:3306/sessions;create=true

When I start jetty with java -jar start.jar I get the exception

2016-03-23 22:36:49.124:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.server.session.JDBCSessionIdManager
7591a3ed: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        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 java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.eclipse.jetty.server.session.JDBCSessionIdManager.initializeDatabase(JDBCSessionIdManager.java:1496)
        at org.eclipse.jetty.server.session.JDBCSessionIdManager.doStart(JDBCSessionIdManager.java:985)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
        at org.eclipse.jetty.server.Server.start(Server.java:387)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
        at org.eclipse.jetty.server.Server.doStart(Server.java:354)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:321)
        at org.eclipse.jetty.start.Main.start(Main.java:817)

I have my mysql jdbc driver jar file in $JETTY_HOME/lib directory and $JAVA_HOME/lib directory too, so I am not sure why I am still getting the error

将MySQL JDBC驱动程序jar放在$JETTY_HOME/lib/ext目录中。

我必须在start.init中添加--module = ext,以使码头处理来自lib / ext目录的jar。

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