Reputation: 103
I recently upgraded my jetty server to 9.4.8. After upgrade while i try to execute 'jettyRun' command on my application i get the following error:
12:27:58.464 [main] INFO org.eclipse.jetty.util.log - Logging initialized @3707ms to org.eclipse.jetty.util.log.Slf4jLog
12:28:01.854 [main] INFO org.eclipse.jetty.server.Server - jetty-9.4.8.v20171121, build timestamp: 2017-11-22T02:57:37+05:30, git hash: 82b8fb23f757335bb3329d540ce37a2a2615f0a8
12:28:01.948 [main] INFO org.akhikhl.gretty.JettyConfigurerImpl - Configuring /id-factory-collab with file:/H:/git/uprgade/fc-parent/fc-web/build/jetty-env.xml
12:28:01.995 [main] WARN org.eclipse.jetty.xml.XmlConfiguration - Config error at <Get name="sessionManager"><Set name="sessionCookie">FCTID</Set><Set name="sessionIdPathParameterName">none</Set><Set name="sessionIdManager">
<New class="org.eclipse.jetty.server.session.HashSessionIdManager"><Set name="workerName">%%name%%</Set></New>
</Set></Get>
12:28:02.011 [main] WARN org.eclipse.jetty.xml.XmlConfiguration - Config error at <Get name="sessionHandler"><Get name="sessionManager"><Set name="sessionCookie">FCTID</Set><Set name="sessionIdPathParameterName">none</Set><Set name="sessionIdManager">
<New class="org.eclipse.jetty.server.session.HashSessionIdManager"><Set name="workerName">%%name%%</Set></New>
</Set></Get></Get>
12:28:02.011 [main] WARN org.eclipse.jetty.webapp.WebAppContext - Failed startup of context o.a.g.JettyWebAppContext@486bc9a4{/fc,file:///H:/git/uprgade/fc-parent/fc-web/build/inplaceWebapp/,UNAVAILABLE}
java.lang.NoSuchMethodException: org.eclipse.jetty.server.session.SessionHandler.getSessionManager()
at java.lang.Class.getMethod(Class.java:1786) ~[na:1.8.0_162]
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.get(XmlConfiguration.java:740) ~[jetty-xml-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:471) ~[jetty-xml-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.get(XmlConfiguration.java:745) ~[jetty-xml-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:471) ~[jetty-xml-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:351) ~[jetty-xml-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:296) ~[jetty-xml-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.xml.XmlConfiguration$configure.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCajava:125) [groovy-2.4.11.jar:2.4.11]
at org.akhikhl.gretty.JettyConfigurerImpl.applyContextConfigFile(JettyConfigurerImpl.groovy:54) ~[gretty-runner-jetty94-2.0.0.jar:na]
at org.akhikhl.gretty.JettyConfigurer$applyContextConfigFile$10.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) [groovy-2.4.11.jar:2.4.11]
at org.akhikhl.gretty.JettyServerConfigurer.configureWithBaseResource(JettyServerConfigurer.groovy:33) ~[gretty-runner-jetty-2.0.0.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) [groovy-2.4.11.jar:2.4.11]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) [groovy-2.4.11.jar:2.4.11]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) [groovy-2.4.11.jar:2.4.11]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1080) [groovy-2.4.11.jar:2.4.11]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) [groovy-2.4.11.jar:2.4.11]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1087) [groovy-2.4.11.jar:2.4.11]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) [groovy-2.4.11.jar:2.4.11]
at groovy.lang.Closure.call(Closure.java:414) ~[groovy-2.4.11.jar:2.4.11]
at groovy.lang.Closure.call(Closure.java:430) ~[groovy-2.4.11.jar:2.4.11]
at groovy.lang.Closure$call$0.call(Unknown Source) ~[na:na]
at org.codehaus.groovy.runtisite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-2.4.11.jar:2.4.11]
at org.akhikhl.gretty.WebInfConfigurationEx.unpack(WebInfConfigurationEx.groovy:46) ~[gretty-runner-jetty94-2.0.0.jar:na]
at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure(WebInfConfiguration.java:154) ~[jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:506) ~[jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:544) ~[jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.akhikhl.gretty.JettyWebAppContext.super$10$doStart(JettyWebAppContext.groovy) [gretty-runner-jetty94-2.0.0.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) [groovy-2.4.11.jar:2.4.11]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) [groovy-2.4.11.jar:2.4.11]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:152) [groovy-2.4.11.jar:2.4.11]
at org.akhikhl.gretty.JettyWebAppContext.doStart(JettyWebAppContext.groovy:44) [gretty-runner-jetty94-2.0.0.jar:na]
at org.eclipse.jetty.util.compostractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.Server.start(Server.java:418) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.Server.doStart(Server.java:385) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.component.LifeCycle$start$0.call(Unknown Source) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSi:117) [groovy-2.4.11.jar:2.4.11]
at org.akhikhl.gretty.JettyServerManager.startServer(JettyServerManager.groovy:45) [gretty-runner-jetty-2.0.0.jar:na]
at org.akhikhl.gretty.ServerManager$startServer$0.call(Unknown Source) [gretty-runner-2.0.0.jar:na]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-2.4.11.jar:2.4.11]
at org.akhikhl.gretty.Runner.run(Runner.groovy:117) [gretty-runner-2.0.0.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.11.jar:2.4.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) [groovy-2.4.11.jar:2.4.11]
at org.akhikhl.gretty.Runner.main(Runner.groovy:44) [gretty-runner-2.0.0.jar:na]
This is the jetty-env.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/fc</Set>
<Set name="overrideDescriptor">build/override-web.xml</Set>
<Get name="sessionHandler">
<Get name="sessionManager">
<Set name="sessionCookie">FCTID</Set>
<Set name="sessionIdPathParameterName">none</Set>
<Set name="sessionIdManager">
<New class="org.eclipse.jetty.server.session.HashSessionIdManager">
<Set name="workerName">%%name%%</Set>
</New>
</Set>
</Get>
</Get>
</Configure>
Could someone please help with this
Upvotes: 1
Views: 3264
Reputation: 49462
Servlet 3.1 changed Session configuration.
As soon as you hit Jetty 9.x you should have changed to use javax.servlet.SessionCookieConfig.
Example: Lets take a look at these settings first ...
<Set name="sessionCookie">FCTID</Set>
<Set name="sessionIdPathParameterName">none</Set>
These set a cookie name and attempts to not use/disable the URL tracking mode (this technique does nothing in Servlet 3.1 btw)
in embedded-jetty
:
SessionHandler sessionHandler = webAppContext.getSessionHandler();
sessionHandler.getSessionCookieConfig().setName("FCTID");
sessionHandler.setSessionTrackingModes(EnumSet.of(SessionTrackingMode.COOKIE));
or used in a ServletContextListener
:
import java.util.EnumSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.SessionTrackingMode;
public class SesssionContextListener implements javax.servlet.ServletContextListener
{
@Override
public void contextInitialized(ServletContextEvent sce)
{
ServletContext context = sce.getServletContext();
context.getSessionCookieConfig().setName("FCTID");
context.setSessionTrackingModes(EnumSet.of(SessionTrackingMode.COOKIE));
}
@Override
public void contextDestroyed(ServletContextEvent sce)
{
}
}
or using WEB-INF/web.xml
:
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<session-config>
<cookie-config>
<name>FCTID</name>
</cookie-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
</web-app>
About HashSessionIdManager
:
The old HashSessionIdManager
was a "In Memory" session id manager designed for testing purposes, it wasn't meant to be used in a production sense.
There is only 1 Session Id Manager anymore, called DefaultSessionIdManager
.
It is also a Server component, not a WebApp specific component.
About workerName
:
You'll need to either set that workerName
on the server level, or use the JETTY_WORKER_INSTANCE
system environment variable to set the workerName suffix for that server on startup.
workerName
starts with "node"
and will take the JETTY_WORKER_INSTANCE
value and append it, resulting in workerName = "node" + JETTY_WORKER_INSTANCE;
.
Some things to take into account when assigning workerName
.
workerName
for all WebApp's on the server.Some other observations:
Your jetty-env.xml
is attempting to do things that the jetty-env.xml
cannot handle.
<Set name="contextPath">/fc</Set>
It is far too late in the WebApp lifecycle to change the context path in the jetty-env.xml
.
<Set name="overrideDescriptor">build/override-web.xml</Set>
The overrideDescriptor
has already been assigned, read, and used before the jetty-env.xml
has been looked at. This action causes no change as its far too late in the WebApp lifecycle to change this value in the jetty-env.xml
.
Both of those settings should be moved to the ${jetty.base}/webapps/<context>.xml
file.
Once you are done moving those 2 settings, and update to use the javax.servlet.SessionCookieConfig
, you'll no longer have a jetty-env.xml
.
Upvotes: 2