HTTP HEAD request cause IllegalStateException

Vladimir Yusseem <[email protected]> Tue, 13 Sep 2005 18:58:52 -0700 (PDT)
Newsgroups gmane.comp.web.maverick.general
Message-ID <[email protected]>
Hi guys, I'm happily using Maverick for over 3 years now, and was really
surprised to discover this.
When HEAD http request comes to a view (in my case used by host uptime
monitor), I have following stacktrace:

2005-09-13 22:22:46,875 [http-9094-Processor23] ERROR
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[dispat=
cher]
 - Servlet.service() for servlet dispatcher threw exception
java.lang.IllegalStateException: The previous step never tried to write
anything.  Perhaps the document path is incorrect?
	at
org.infohazard.maverick.util.FakeHttpServletResponse.getOutputAsString(Fa=
keHttpServletResponse.java:99)
	at
org.infohazard.maverick.transform.StringTransformStep.done(StringTransfor=
mStep.java:87)
	at
org.infohazard.maverick.transform.DocumentTransform$Step.go(DocumentTrans=
form.java:114)
	at org.infohazard.maverick.view.DocumentView.go(DocumentView.java:96)
	at
org.infohazard.maverick.flow.ViewWithTransforms.go(ViewWithTransforms.jav=
a:57)
	at org.infohazard.maverick.flow.CommandBase.go(CommandBase.java:79)
	at org.infohazard.maverick.Dispatcher.service(Dispatcher.java:345)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicat=
ionFilterChain.java:252)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilte=
rChain.java:173)
	at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatch=
er.java:672)
	at
org.apache.catalina.core.ApplicationDispatcher.processRequest(Application=
Dispatcher.java:463)
	at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispa=
tcher.java:398)
	at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatc=
her.java:301)
	at
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:=
693)
	at
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:66=
0)
	at org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:45)
	at=20
.....

Here is debug log:
2005-09-13 22:22:46,861 [http-9094-Processor23] DEBUG
org.infohazard.maverick.Dispatcher  - Command servlet path is:  /home.m
2005-09-13 22:22:46,861 [http-9094-Processor23] DEBUG
org.infohazard.maverick.Dispatcher  - Command context path is: =20
2005-09-13 22:22:46,861 [http-9094-Processor23] DEBUG
org.infohazard.maverick.Dispatcher  - Servicing command:  home
2005-09-13 22:22:46,864 [http-9094-Processor23] DEBUG
org.infohazard.maverick.flow.CommandBase  - Switching to view:  success
2005-09-13 22:22:46,864 [http-9094-Processor23] DEBUG
org.infohazard.maverick.flow.MaverickContext  - Set 2 transform(s), of
which 2 will be executed
2005-09-13 22:22:46,864 [http-9094-Processor23] DEBUG
org.infohazard.maverick.flow.MaverickContext  - Creating transform step 0
2005-09-13 22:22:46,864 [http-9094-Processor23] DEBUG
org.infohazard.maverick.transform.DocumentTransform  - Wrapping text with
length 0
2005-09-13 22:22:46,865 [http-9094-Processor23] DEBUG
org.infohazard.maverick.flow.MaverickContext  - Creating transform step 1
2005-09-13 22:22:46,865 [http-9094-Processor23] DEBUG
org.infohazard.maverick.transform.DocumentTransform  - Transforming
(include) with document:  home.html
2005-09-13 22:22:46,865 [http-9094-Processor23] DEBUG
org.infohazard.maverick.transform.AbstractTransformStep  - Getting fake
response
2005-09-13 22:22:46,865 [http-9094-Processor23] DEBUG
org.infohazard.maverick.util.FakeHttpServletResponse  - Creating fake
response, original buffer size is 8192
2005-09-13 22:22:46,865 [http-9094-Processor23] DEBUG
org.infohazard.maverick.util.FakeHttpServletResponse  - Set header ETag t=
o
W/"896-1126216638000"
2005-09-13 22:22:46,865 [http-9094-Processor23] DEBUG
org.infohazard.maverick.util.FakeHttpServletResponse  - Set header
Last-Modified to Thu, 08 Sep 2005 21:57:18 GMT
2005-09-13 22:22:46,865 [http-9094-Processor23] DEBUG
org.infohazard.maverick.util.FakeHttpServletResponse  - Setting
contentType to text/html
2005-09-13 22:22:46,866 [http-9094-Processor23] DEBUG
org.infohazard.maverick.util.FakeHttpServletResponse  - Someone wanted to
set contentLength to 896
2005-09-13 22:22:46,866 [http-9094-Processor23] DEBUG
org.infohazard.maverick.transform.StringTransformStep  - Done being
written to
2005-09-13 22:22:46,866 [http-9094-Processor23] DEBUG
org.infohazard.maverick.util.FakeHttpServletResponse  - Getting output as
String
2005-09-13 22:22:46,875 [http-9094-Processor23] ERROR
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[dispat=
cher]
 - Servlet.service() for servlet dispatcher threw exception

And i makes sense because:
<quote from http://www.w3.org>
The HEAD method is identical to GET except that the server MUST NOT retur=
n
a message-body in the response. The metainformation contained in the HTTP
headers in response to a HEAD request SHOULD be identical to the
information sent in response to a GET request. This method can be used fo=
r
obtaining metainformation about the entity implied by the request without
transferring the entity-body itself. This method is often used for testin=
g
hypertext links for validity, accessibility, and recent modification.
</quote>

I made a test through "Rex Swain's HTTP Viewer":
http://www.rexswain.com/httpview.html

Can someone think of any workaround?

Vladimir Yusseem


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Downl=
oad
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
[INVALID FOOTER]