I am running my servlet application within Jetty, and it sometimes outputs the below-shown stack trace. I think this means it is receiving an invalid URL request, but I can't actually see the request. Can I handle this exception somwehere so that my logs are not clogged up with this nasty stack trace? And if so can it handled in my code, or does this error occur before getting to my code and therefore needs to be handled with Jetty configuration?
EDIT So if I did move to Jeety 9 how could I configure it so the stacktrace goes and could I configure a suitable http response code
Alternaively, I've realized that jetty is receiving the request after it has been processed by http://tuckey.org/urlrewrite/, is there something sensible I should configure in UrlRewriteFilter to do something else if the generated url is invalid.
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)
EDIT It has been suggested that maybe this could be handled in my tuckey configuration so thsi is what it currently looks like
<?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>
Write a log4j filter for this exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With