1

I am trying to set up persistent sessions on Jetty 9.2.3 on a linux machine running Java8. I have added jetty-web.xml file to my app under ${jetty.home}/webapps/app/WEB-INF/ with the following content:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="sessionHandler">
    <New class="org.eclipse.jetty.servlet.SessionHandler">
      <Arg>
        <New class="org.eclipse.jetty.servlet.HashSessionManager">
          <Set name="storeDirectory">/var/sessions</Set>
        </New>
      </Arg>
    </New>
  </Set>
</Configure>

but when I try to start Jetty, I get the following error:

2014-09-29 13:08:12.989:WARN:oejw.JettyWebXmlConfiguration:main: Unable to process jetty-web.xml
java.lang.ClassNotFoundException: org.eclipse.jetty.servlet.SessionHandler
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:450)
    ...

Any help would be greatly appreciated.

Kęstutis
  • 505
  • 1
  • 6
  • 16

1 Answers1

2

Well, it seems like the classpaths in Jetty9 documentation explaining how to setup persistent sessions is simply incorrect. As soon as I changed paths from org.eclipse.jetty.servlet.* to org.eclipse.jetty.server.session.* everything worked like a charm.

The final config looked like this:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="sessionHandler">
    <New class="org.eclipse.jetty.server.session.SessionHandler">
      <Arg>
        <New class="org.eclipse.jetty.server.session.HashSessionManager">
          <Set name="storeDirectory">/var/sessions</Set>
        </New>
      </Arg>
    </New>
  </Set>
</Configure>
Kęstutis
  • 505
  • 1
  • 6
  • 16