You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christian Aschoff <ch...@uni-ulm.de> on 2007/12/07 17:54:45 UTC

rare occurrence of an Exception in Filter.doFilter()

Hello tomcat-users,

i have written a filter for my webapplication that checks the called  
url for special patterns and sends an error 404 when matching the  
pattern. This works most of the time great. But every ca. 4000  
requests, an exception occurs in the filter. I looked around with  
google & co., but found only errors of this type appearing every  
request - or not. A second filter works great.

I wonder if this could be a problem with threads?

Any help (direct or by giving a hint of how to debug this problem)  
would be appreciated.

Regards,
Christian Aschoff

A normal url is: http://www.retrobibliothek.de/retrobib/index.html   
(everything is fine)
http://www.retrobibliothek.de/retrobib/index.jsp  shows 404 not  
found  (as it should)
http://www.polonius.bibliothek.uni-ulm.de/retrobib/index.html  shows  
404 not found  ([same host] - as it should)

The used tomcat is 5.5.12, Java is
java version "1.4.2_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_16-b05)
Java HotSpot(TM) Client VM (build 1.4.2_16-b05, mixed mode),
running on Linux (2.6.13-15.18-smp #1 SMP Tue Oct 2 17:36:20 UTC 2007  
x86_64 x86_64 x86_64 GNU/Linux).

The filter-configuration is:

[...]
     <filter>
         <filter-name>SecurityFilter</filter-name>
         <filter-class>de.retrobib.filter.SecurityFilter</filter-class>
     </filter>
     <filter>
         <filter-name>URLFilter</filter-name>
         <filter-class>de.retrobib.filter.URLFilter</filter-class>
     </filter>

     <filter-mapping>
         <filter-name>URLFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>

     <filter-mapping>
         <filter-name>SecurityFilter</filter-name>
         <url-pattern>/secure/*</url-pattern>
     </filter-mapping>
     <filter-mapping>
         <filter-name>SecurityFilter</filter-name>
         <url-pattern>*.zipped</url-pattern>
     </filter-mapping>
[...]

The filter-code is:

[...]
     public void doFilter(ServletRequest request, ServletResponse  
response, FilterChain chain)
     throws IOException, ServletException {
         doBeforeProcessing(request, response);

         HttpServletRequest req = (HttpServletRequest) request;

         try {
             if (req.getRequestURL().toString().toLowerCase().indexOf 
(".jsp") != -1) {
                 logger.warn("Direkter Aufruf von *.jsp, sende 404  
[ip="+req.getRemoteAddr()+"; url="+req.getRequestURL()+",  
query="+req.getQueryString()+"]");
                 ((HttpServletResponse) response).sendError(404);
             } else if (req.getRequestURL().toString().toLowerCase 
().indexOf("uni-ulm") != -1) {
                 logger.info("uni-ulm in der URL, sende 404  
[ip="+req.getRemoteAddr()+"; url="+req.getRequestURL()+",  
query="+req.getQueryString()+"]");
                 ((HttpServletResponse) response).sendError(404);
             } else {
                 chain.doFilter(request, response);
             }
         } catch(Throwable ex) {
             logger.debug("[ip="+req.getRemoteAddr()+";  
url="+req.getRequestURL()+", query="+req.getQueryString()+"]");
             logger.fatal("Exception im URLFilter!", ex);
             // Mail Error & Request...
             String mailContent = "StackTrace: 
\n"+DebugUtil.getStackTrace(ex)+"\nRequest: 
\n"+DebugUtil.getRequestAsString(req);
             try {
                 new Mailer().send("Fehler in der retro-bib:  
"+ex.getMessage(), mailContent, MiscConstants.adminMail, null);
             } catch (Exception badEx) {
                 logger.fatal("Exception im URLFilter  
(eMailversand)!", ex);
             }
         }

         doAfterProcessing(request, response);
     }
[...]

Other methods are basically empty.

The exceptions occurs in the line 'chain.doFilter(request,  
response);', examples are:

StackTrace:
java.lang.IllegalStateException: Cannot create a session after the  
response has been committed
	at org.apache.catalina.connector.Request.doGetSession(Request.java: 
2206)
	at org.apache.catalina.connector.Request.getSession(Request.java:2024)
	at org.apache.catalina.connector.RequestFacade.getSession 
(RequestFacade.java:831)
	at org.apache.catalina.connector.RequestFacade.getSession 
(RequestFacade.java:842)
	at org.apache.struts.action.RequestProcessor.processLocale 
(RequestProcessor.java:621)
	at org.apache.struts.action.RequestProcessor.process 
(RequestProcessor.java:177)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java: 
1196)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter 
(ApplicationFilterChain.java:252)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter 
(ApplicationFilterChain.java:173)
*	at de.retrobib.filter.URLFilter.doFilter(URLFilter.java:100)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter 
(ApplicationFilterChain.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter 
(ApplicationFilterChain.java:173)
	at org.apache.catalina.core.StandardWrapperValve.invoke 
(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke 
(StandardContextValve.java:178)
	at org.apache.catalina.core.StandardHostValve.invoke 
(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke 
(ErrorReportValve.java:105)
	at org.apache.catalina.core.StandardEngineValve.invoke 
(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service 
(CoyoteAdapter.java:148)
	at org.apache.coyote.http11.Http11Processor.process 
(Http11Processor.java:868)
	at org.apache.coyote.http11.Http11BaseProtocol 
$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket 
(PoolTcpEndpoint.java:527)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt 
(LeaderFollowerWorkerThread.java:80)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run 
(ThreadPool.java:684)
	at java.lang.Thread.run(Thread.java:595)

Request:

---------------- Start Dump --------------------------------------
Information(s) about the request:

AuthType = null
CharacterEncoding = null
ContentType = null
ContextPath = /retrobib
Method = GET
PathInfo = null
PathTranslated = null
Protocol = HTTP/1.1
QueryString = oldid=1185368073558
RemoteAddr = 66.249.65.1
RemoteHost = 66.249.65.1
RemotePort = 36965
RemoteUser = null
RequestURI = /retrobib/seite.html
RequestURL = http://www.retrobibliothek.de/retrobib/seite.html
RequestedSessionId = null

No session for this request.

Parameter(s):
oldid = 1185368073558

Attribute(s):
org.apache.struts.action.MESSAGE =  
org.apache.struts.util.PropertyMessageResources@587a55
org.apache.struts.action.MODULE =  
org.apache.struts.config.impl.ModuleConfigImpl@c790c9

Header(s):
host = www.retrobibliothek.de
connection = Keep-alive
accept = */*
from = googlebot(at)googlebot.com
user-agent = Mozilla/5.0 (compatible; Googlebot/2.1; +http:// 
www.google.com/bot.html)
accept-encoding = gzip
---------------- Ende Dump ---------------------------------------

or

StackTrace:
java.lang.IllegalStateException: Cannot forward after response has  
been committed
	at org.apache.catalina.core.ApplicationDispatcher.doForward 
(ApplicationDispatcher.java:313)
	at org.apache.catalina.core.ApplicationDispatcher.forward 
(ApplicationDispatcher.java:301)
	at org.apache.struts.action.RequestProcessor.doForward 
(RequestProcessor.java:1085)
	at org.apache.struts.action.RequestProcessor.processForwardConfig 
(RequestProcessor.java:398)
	at org.apache.struts.action.RequestProcessor.process 
(RequestProcessor.java:241)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java: 
1196)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter 
(ApplicationFilterChain.java:252)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter 
(ApplicationFilterChain.java:173)
*	at de.retrobib.filter.URLFilter.doFilter(URLFilter.java:100)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter 
(ApplicationFilterChain.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter 
(ApplicationFilterChain.java:173)
	at org.apache.catalina.core.StandardWrapperValve.invoke 
(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke 
(StandardContextValve.java:178)
	at org.apache.catalina.core.StandardHostValve.invoke 
(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke 
(ErrorReportValve.java:105)
	at org.apache.catalina.core.StandardEngineValve.invoke 
(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service 
(CoyoteAdapter.java:148)
	at org.apache.coyote.http11.Http11Processor.process 
(Http11Processor.java:868)
	at org.apache.coyote.http11.Http11BaseProtocol 
$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket 
(PoolTcpEndpoint.java:527)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt 
(LeaderFollowerWorkerThread.java:80)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run 
(ThreadPool.java:684)
	at java.lang.Thread.run(Thread.java:595)

Request:

---------------- Start Dump --------------------------------------
Information(s) about the request:

AuthType = null
CharacterEncoding = UTF-8
ContentType = null
ContextPath = /retrobib
Method = GET
PathInfo = null
PathTranslated = null
Protocol = HTTP/1.1
QueryString = bandid=100156
RemoteAddr = 87.188.120.209
RemoteHost = 87.188.120.209
RemotePort = 4414
RemoteUser = null
RequestURI = /retrobib/stoebern.html
RequestURL = http://www.retrobibliothek.de/retrobib/stoebern.html
RequestedSessionId = B286AFDDE41B6E58B5349A2FFB93C4ED

Sessionvalue(s):
org.apache.struts.action.LOCALE = de_DE

Parameter(s):
bandid = 100156

Attribute(s):
org.apache.struts.action.MESSAGE =  
org.apache.struts.util.PropertyMessageResources@587a55
globalKorrektorMessages = []
korrektorCount = 189
org.apache.struts.action.mapping.instance = ActionConfig[path=/ 
stoebern,scope=session,type=de.retrobib.actions.StoebernAction,validate= 
true,cancellable=false
globalMessages = []
teileMitSeiten = [de.retrobib.webelements.TeilMitSeiten@e88b84]
band = de.retrobib.dbmodel.Band[id = 100156; oldid = 1043602798323;  
timestamp = 1191594863750; deleted = false; visible = true; sort =  
0010; number = 2; name = 2. Band: Atlantis - Blatthornkäfer;  
publisher = ; author = ; issued = ; description = ]
author = Christian Aschoff
werk = de.retrobib.dbmodel.Werk[id = 100149; oldid = 1034149743511;  
timestamp = 1189669728066; deleted = false; sort = 000; name = Meyers  
Konversationslexikon; shortname = Meyers; publisher = Verlag des  
Bibliographischen Instituts, Leipzig und Wien; author =  
Autorenkollektiv; issued = Vierte Auflage, 1885-1892; description = ]
messages = []
org.apache.struts.action.MODULE =  
org.apache.struts.config.impl.ModuleConfigImpl@c790c9

Header(s):
host = www.retrobibliothek.de
user-agent = Mozilla/5.0 (Windows; U; Windows NT 5.0; de; rv: 
1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
accept = text/xml,application/xml,application/xhtml+xml,text/ 
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
accept-language = de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
accept-encoding = gzip,deflate
accept-charset = ISO-8859-1,utf-8;q=0.7,*;q=0.7
keep-alive = 300
connection = keep-alive
referer = http://www.retrobibliothek.de/retrobib/stoebern.html? 
werkid=100149
cookie = JSESSIONID=B286AFDDE41B6E58B5349A2FFB93C4ED;  
__utma=180525476.323824295.1196968319.1196968319.1196968319.1;  
__utmb=180525476; __utmc=180525476;  
__utmz=180525476.1196968319.1.1.utmccn=(direct)|utmcsr=(direct)| 
utmcmd=(none)
---------------- Ende Dump ---------------------------------------




---
Dipl. Ing. (FH) Christian Aschoff

Büro:
Universität Ulm
Kommunikations- und Informationszentrum
Abt. Informationssysteme
Raum O26/5403
Albert-Einstein-Allee 11
89081 Ulm

Tel. 0731 50-22432
Fax. 0731 50-22471
christian.aschoff@uni-ulm.de

Privat:
Fabristr. 13
89075 Ulm
Deutschland/Old Europe

Tel. 0731 602 803 60
Fax. 0731 602 803 61
Mob. 0171 272 03 04
caschoff@mac.com

Helfen Sie mit: http://www.retrobibliothek.de





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: rare occurrence of an Exception in Filter.doFilter() (solved)

Posted by Christian Aschoff <ch...@uni-ulm.de>.
Dear list,

it was in fact the 'bug' described below. (ImageOutputWriter not  
closed).

Many thanks for the hints!

Regards,
Christian Aschoff


Am 07.12.2007 um 22:51 schrieb Konstantin Kolinko:

> E.g., I have found http://issues.apache.org/bugzilla/show_bug.cgi? 
> id=41772

---
Dipl. Ing. (FH) Christian Aschoff

Büro:
Universität Ulm
Kommunikations- und Informationszentrum
Abt. Informationssysteme
Raum O26/5403
Albert-Einstein-Allee 11
89081 Ulm

Tel. 0731 50-22432
Fax. 0731 50-22471
christian.aschoff@uni-ulm.de

Privat:
Fabristr. 13
89075 Ulm
Deutschland/Old Europe

Tel. 0731 602 803 60
Fax. 0731 602 803 61
Mob. 0171 272 03 04
caschoff@mac.com

Helfen Sie mit: http://www.retrobibliothek.de





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: rare occurrence of an Exception in Filter.doFilter()

Posted by Konstantin Kolinko <kn...@gmail.com>.
Also, you may want to search Bugzilla (http://issues.apache.org/) or
user/dev list archives for those strings,

"Cannot create a session after the response has been committed",
"Cannot forward after response has been committed"

E.g., I have found http://issues.apache.org/bugzilla/show_bug.cgi?id=41772



2007/12/7, Tim Funk <fu...@joedog.org>:
> http://wiki.apache.org/tomcat/FAQ/Miscellaneous
>
> Look for "Why do I get java.lang.IllegalStateException ?"
>
> The filter is not the problem - its  something farther down the stack
> trace.
>
> -Tim

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: rare occurrence of an Exception in Filter.doFilter()

Posted by Tim Funk <fu...@joedog.org>.
http://wiki.apache.org/tomcat/FAQ/Miscellaneous

Look for "Why do I get java.lang.IllegalStateException ?"

The filter is not the problem - its  something farther down the stack 
trace.

-Tim

Christian Aschoff wrote:
> i have written a filter for my webapplication that checks the called url 
> for special patterns and sends an error 404 when matching the pattern. 
> This works most of the time great. But every ca. 4000 requests, an 
> exception occurs in the filter. I looked around with google & co., but 
> found only errors of this type appearing every request - or not. A 
> second filter works great.
> 
> I wonder if this could be a problem with threads?
> 
> Any help (direct or by giving a hint of how to debug this problem) would 
> be appreciated.
> 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org