我在 Jetty 中运行我的 servlet 应用程序,它有时会输出如下所示的堆栈跟踪。我认为这意味着它正在接收无效的 URL 请求,但我实际上看不到该请求。我可以在这里处理这个异常,以便我的日志不会被这个讨厌的堆栈跟踪堵塞吗?如果可以,它可以在我的代码中处理,还是在获取我的代码之前发生此错误,因此需要使用 Jetty 配置来处理?
编辑 因此,如果我确实移至 Jeety 9,我该如何配置它以便堆栈跟踪继续运行,我是否可以配置合适的 http 响应代码
或者,我意识到码头在http://tukey.org/urlrewrite/处理后正在接收请求,如果生成的 url 无效,我应该在 UrlRewriteFilter 中配置什么来做其他事情。
2013-01-11 23:48:10.939:WARN:oeju.UrlEncoded:org.eclipse.jetty.util.Utf8Appendable$NotUtf8Exception: Not valid UTF8! byte B0 in state 0
2013-01-11 23:48:10.939:WARN:oejs.ServletHandler:/ws/2/release/
org.eclipse.jetty.util.Utf8Appendable$NotUtf8Exception: Not valid UTF8! byte B0 in state 0
at org.eclipse.jetty.util.Utf8Appendable.appendByte(Utf8Appendable.java:174)
at org.eclipse.jetty.util.Utf8Appendable.append(Utf8Appendable.java:99)
at org.eclipse.jetty.util.UrlEncoded.decodeString(UrlEncoded.java:709)
at org.eclipse.jetty.util.UrlEncoded.decodeTo(UrlEncoded.java:251)
at org.eclipse.jetty.util.UrlEncoded.decodeTo(UrlEncoded.java:187)
at org.eclipse.jetty.server.Request.mergeQueryString(Request.java:2045)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:244)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:559)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
编辑 有人建议,也许这可以在我的 tukey 配置中处理,所以这就是它目前的样子
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.1//EN"
"http://tuckey.org/res/dtds/urlrewrite3.1.dtd">
<!--
Configuration file for UrlRewriteFilter
http://tuckey.org/urlrewrite/
-->
<urlrewrite use-query-string="true">
<rule>
<note>
Matches urls like http://localhost:8080/ws/1/artist/?query=blur&fmt=xml
and converts to http://localhost:8080/?type=artist&query=blur&fmt=xml&version=1
</note>
<from>^/ws/(\d)/(.*)/\?(.*)$</from>
<to>/?version=$1&type=$2&$3</to>
</rule>
<rule>
<note>
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
</note>
<from>/test/status/</from>
<to type="redirect">%{context-path}/rewrite-status</to>
</rule>
<outbound-rule>
<note>
The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
the url /rewrite-status will be rewritten to /test/status/.
The above rule and this outbound-rule means that end users should never see the
url /rewrite-status only /test/status/ both in their location bar and in hyperlinks
in your pages.
</note>
<from>/rewrite-status</from>
<to>/test/status/</to>
</outbound-rule>
</urlrewrite>