简体   繁体   English

!从Jetty 7切换到Jetty 9时出现asyncSupported异常

[英]!asyncSupported exception when switch from Jetty 7 to Jetty 9

we recently upgraded our jetty version. 我们最近升级了我们的码头版本。 when we did this both of our legacy gui war files, which no one has modified in some time, stopped working correctly. 当我们这样做时,我们的两个遗留的gui war文件,在一段时间内没有人修改过,停止正常工作。 I believe I hunted the root cause to the proxy (used to proxy to a restful interface on another port), any call to the proxy throws the exception: 我相信我找到了代理的根本原因(用于代理另一个端口上的restful接口),对代理的任何调用都会抛出异常:

 IllegalStateException: !asyncSupported

I'm not sure why this would occure with 1.9 but not with the old jetty. 我不知道为什么会出现这种情况,而不是旧码头。 I can't build the war file currently, it was a mess that only one developer could ever build, but I trid unzipping it with jetty -x and ading to the servlet section of the web.xml file this: 我目前无法构建war文件,只有一个开发人员可以构建它是一个混乱,但是我使用jetty -x解压缩它并且对web.xml文件的servlet部分进行解压缩:

<async-supported>true</async-supported>

and then rezipping it with jar c command. 然后使用jar c命令重新解压缩。 that didn't seem to help, though now i get exceptions in my jetty log fhile while before they would only show in the browser. 这似乎没有帮助,虽然现在我在我的码头日志中得到例外情况,而他们只会在浏览器中显示。

can anyone tell me what to do to activate async support and/or why the switch in jetty would cause this? 任何人都可以告诉我如何激活异步支持和/或为什么jetty中的切换会导致这种情况?

Ah, the evolution of the spec ... 啊,规范的演变......

  • Jetty 7 was Servlet 2.5 (no async there) Jetty 7是Servlet 2.5(没有异步)
  • Jetty 8 was Servlet 3.0 (async introduced) - spec was vague on what was default, so Jetty defaulted to async-supported == true Jetty 8是Servlet 3.0(异步介绍) - 规范对于什么是默认值是模糊的,所以Jetty默认为async-supported == true
  • Jetty 9 is Servlet 3.1 (even more async) - the spec was clarified, and jetty chose its default poorly. Jetty 9是Servlet 3.1(甚至更加异步) - 规范已经澄清,而jetty选择了它的默认值。 The default according to the spec is async-supported == false 根据规范的默认值是async-supported == false

That's why you didn't have to specify async-supported in the past, but now you do. 这就是为什么你不必在过去指定异步支持,但现在你做了。

Bug about this bugs.eclipse.org/410893 关于这个bugs.eclipse.org/410893的bug

Commit: 9bf7870c7c8a209f2660f63c14dd4acb62b07533 提交: 9bf7870c7c8a209f2660f63c14dd4acb62b07533

My exception is the same to you. 我的例外与您相同。 then I put " <async-supported>true</async-supported> " append to every servlet and filter. 然后我将“ <async-supported>true</async-supported> ”附加到每个servlet和过滤器。 it work well. 它运作良好。 For excample 例如

<filter>
    <filter-name>continuation</filter-name>
    <filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
    <async-supported>true</async-supported>
</filter>

<servlet>
    <servlet-name>cometd</servlet-name>
    <servlet-class>org.cometd.annotation.AnnotationCometdServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
</servlet>

the other hand. 另一方面。 if you used jetty9.x. 如果你使用jetty9.x you'd better update your comet jar to version 3.0.x or later. 你最好将你的彗星jar更新到3.0.x或更高版本。 I hope it will help you. 我希望它会对你有所帮助。

我不能(还)将其作为评论,但我想补充一点:如果您遇到此问题并且已根据需要添加了异步支持的标记(或正在使用Jetty 8),请确保您的过滤器也是支持异步或不与有问题的servlet一起使用。

对于基于Java的配置,您可以使用

@javax.servlet.annotation.WebServlet(name = "HelloWorld",urlPatterns = { "/MyServlet" },asyncSupported =true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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