Reputation: 1032
This one is baffling me. Working away as normal and all of a sudden when I try and run the servlet as part of a project I get endless looping errors in the output logs;
03-Jul-2016 18:43:59.464 SEVERE [http-apr-8080-exec-72] org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for servlet xyz threw exception
java.lang.StackOverflowError
at javax.servlet.ServletRequestWrapper.getCharacterEncoding(ServletRequestWrapper.java:96)
And more;
at org.tuckey.web.filters.urlrewrite.UrlRewriter.decodeRequestString(UrlRewriter.java:142)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.getPathWithinApplication(UrlRewriter.java:104)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.getNewChain(UrlRewriter.java:171)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:721)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
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)
The errors go on for some time. They only stop when I stop Tomcat running.
Strangely, the servlet that is being listed no longer exists. After the error was first being thrown, I deleted it, then the error still exists. It seems that the servlet file, xyz, has got stuck somewhere in Tomcat and it isn't updating.
Anyone any ideas how to go about debugging an issue like this? I seem to have tried everything.
IDE: Netbeans 8.0.2
Regards, Michael
Upvotes: 2
Views: 2059
Reputation: 1032
Ok, this is the strangest problem I've ever seen. Had to reinstall Tomcat to get this working again. Looks like Tomcat got its knickers in a twist. Well, that was a well spent few hours... debugging and reinstalling
If anyone knows what causes random things like this, would be interesting to know for myself and I'm sure for others too who experience anything like this in the future.
Edit
Finally got to the bottom of this, the rewrite rule as part of the URLRewriteFilter
's urlrewrite.xml
file uses regular expressions for the From URL.
Tip, make sure you add starting ^
and ending $
characters to the end of the URLs and make sure that the URLs are significantly different. I had a rule for from "/abc/123/"
to "/xyz/abc/?p=$"
which causes a redirect loop and Tomcat gets into an endless loop which you cannot exit from - at all - without reinstalling. The from should have been "^/abc/123/$"
to make sure that it doesn't match.
Upvotes: 1
Reputation: 1
100% you have to reinstall Tomcat. I spent 2 hours debugging to find this solution and I am less than impressed.
Here is a good tutorial on how to reinstall for those wondering. After that, you have to right click on your project and resolve the missing webserver.
Upvotes: 0