升级到 9.4.8 后无法启动码头服务器
Unable to start jetty server after upgrade to 9.4.8
我最近将我的码头服务器升级到 9.4.8。升级后,当我尝试在我的应用程序上执行 'jettyRun' 命令时,出现以下错误:
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.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[=10=].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$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[=10=].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[=10=].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]
这里是码头-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>
有人可以帮忙吗
Servlet 3.1 更改了会话配置。
你一点击 Jetty 9.x 你就应该改用 javax.servlet.SessionCookieConfig.
示例:让我们先看一下这些设置...
<Set name="sessionCookie">FCTID</Set>
<Set name="sessionIdPathParameterName">none</Set>
这些设置 cookie 名称并尝试不 use/disable URL 跟踪模式(顺便说一句,此技术在 Servlet 3.1 中不起作用)
在embedded-jetty
:
SessionHandler sessionHandler = webAppContext.getSessionHandler();
sessionHandler.getSessionCookieConfig().setName("FCTID");
sessionHandler.setSessionTrackingModes(EnumSet.of(SessionTrackingMode.COOKIE));
或用于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)
{
}
}
或使用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>
关于HashSessionIdManager
:
旧的 HashSessionIdManager
是一个 "In Memory" 会话 ID 管理器,专为测试目的而设计,并不打算用于生产。
只有 1 个 Session Id Manager,名为 DefaultSessionIdManager
。
它也是一个服务器组件,而不是特定于 WebApp 的组件。
关于workerName
:
您需要在服务器级别设置 workerName
,或者使用 JETTY_WORKER_INSTANCE
系统环境变量在启动时为该服务器设置 workerName 后缀。
workerName
以 "node"
开头,将取 JETTY_WORKER_INSTANCE
值并附加它,结果是 workerName = "node" + JETTY_WORKER_INSTANCE;
.
分配workerName
时需要考虑的一些事项。
- 这是服务器级别的配置。
- 服务器上的所有 WebApp 都相同
workerName
。
- 名称中只能包含字母或数字。 (没有空格,没有标点符号,不允许有其他字符)
- 根据 WebApp 选择的会话数据存储或数据缓存,它可以使用来自这些配置的集群名称作为前缀。
其他一些观察:
您的 jetty-env.xml
正在尝试做 jetty-env.xml
无法处理的事情。
<Set name="contextPath">/fc</Set>
在 WebApp 生命周期中更改 jetty-env.xml
中的上下文路径已经太晚了。
<Set name="overrideDescriptor">build/override-web.xml</Set>
在查看 jetty-env.xml
之前,已经分配、读取和使用了 overrideDescriptor
。此操作不会导致任何更改,因为它在 WebApp 生命周期中为时已晚,无法在 jetty-env.xml
.
中更改此值
这两个设置都应移至 ${jetty.base}/webapps/<context>.xml
文件。
完成这 2 个设置的移动并更新为使用 javax.servlet.SessionCookieConfig
后,您将不再拥有 jetty-env.xml
。
我最近将我的码头服务器升级到 9.4.8。升级后,当我尝试在我的应用程序上执行 'jettyRun' 命令时,出现以下错误:
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.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[=10=].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$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[=10=].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[=10=].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]
这里是码头-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>
有人可以帮忙吗
Servlet 3.1 更改了会话配置。
你一点击 Jetty 9.x 你就应该改用 javax.servlet.SessionCookieConfig.
示例:让我们先看一下这些设置...
<Set name="sessionCookie">FCTID</Set>
<Set name="sessionIdPathParameterName">none</Set>
这些设置 cookie 名称并尝试不 use/disable URL 跟踪模式(顺便说一句,此技术在 Servlet 3.1 中不起作用)
在embedded-jetty
:
SessionHandler sessionHandler = webAppContext.getSessionHandler();
sessionHandler.getSessionCookieConfig().setName("FCTID");
sessionHandler.setSessionTrackingModes(EnumSet.of(SessionTrackingMode.COOKIE));
或用于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)
{
}
}
或使用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>
关于HashSessionIdManager
:
旧的 HashSessionIdManager
是一个 "In Memory" 会话 ID 管理器,专为测试目的而设计,并不打算用于生产。
只有 1 个 Session Id Manager,名为 DefaultSessionIdManager
。
它也是一个服务器组件,而不是特定于 WebApp 的组件。
关于workerName
:
您需要在服务器级别设置 workerName
,或者使用 JETTY_WORKER_INSTANCE
系统环境变量在启动时为该服务器设置 workerName 后缀。
workerName
以 "node"
开头,将取 JETTY_WORKER_INSTANCE
值并附加它,结果是 workerName = "node" + JETTY_WORKER_INSTANCE;
.
分配workerName
时需要考虑的一些事项。
- 这是服务器级别的配置。
- 服务器上的所有 WebApp 都相同
workerName
。 - 名称中只能包含字母或数字。 (没有空格,没有标点符号,不允许有其他字符)
- 根据 WebApp 选择的会话数据存储或数据缓存,它可以使用来自这些配置的集群名称作为前缀。
其他一些观察:
您的 jetty-env.xml
正在尝试做 jetty-env.xml
无法处理的事情。
<Set name="contextPath">/fc</Set>
在 WebApp 生命周期中更改 jetty-env.xml
中的上下文路径已经太晚了。
<Set name="overrideDescriptor">build/override-web.xml</Set>
在查看 jetty-env.xml
之前,已经分配、读取和使用了 overrideDescriptor
。此操作不会导致任何更改,因为它在 WebApp 生命周期中为时已晚,无法在 jetty-env.xml
.
这两个设置都应移至 ${jetty.base}/webapps/<context>.xml
文件。
完成这 2 个设置的移动并更新为使用 javax.servlet.SessionCookieConfig
后,您将不再拥有 jetty-env.xml
。