Skip to main content

[webtier] Re: java.lang.ClassCastException: javax.servlet.http.NoBodyResponse

1 reply [Last post]
Anonymous

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jan Luehe

On 02/10/09 19:03, 清秋 wrote:
> Hello
> I encountered a similar problem you do not know you have not been
> resolved. Can you help me solve it? Thank you
> Exception :
> ####<2009-2-10 下午08时05分07秒 CST>
> <[ACTIVE] ExecuteThread: '5' for queue:
> 'weblogic.kernel.Default (self-tuning)'> <> <> <>
> <1234267507609>
> <[weblogic.servlet.internal.WebAppServletContext@1126d91 - name:
> 'data', context-path: ''] Servlet failed with Exception
> java.lang.ClassCastException: javax.servlet.http.NoBodyResponse
> at
> weblogic.servlet.internal.ServletResponseImpl.getOriginalResponse(ServletResponseImpl.java:1299)
> at
> weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:95)
> at lhm.hcy.guge.IndexServlet.doGet(IndexServlet.java:57)
> at javax.servlet.http.HttpServlet.doHead(HttpServlet.java:316)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
> at
> weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
> at
> weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
> at
> weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
> at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
> at
> weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
> at
> lhm.hcy.guge.frameset.filter.CHEncodeFilter.doFilter(CHEncodeFilter.java:22)
> at
> weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
> at
> weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3151)
> at
> weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
> at
> weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
> at
> weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1973)
> at
> weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1880)
> at
> weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1310)
> at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
> at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
> >
> Code :
> public void doGet(HttpServletRequest req, HttpServletResponse res) throws
> ServletException, IOException {
> res.setContentType(CONTENT_TYPE);
> req.setCharacterEncoding("gb2312");
> req.getRequestDispatcher("index.jsp").forward(req, res); //Exception(
> Multi-user access will have the above error,,
> Other will not
> )
> }

This may be just speculation, but what you are seeing may be a result of:

https://glassfish.dev.java.net/issues/show_bug.cgi?id=2212
("Implementation issues with javax.servlet.http.HttpServlet")

See HttpServlet.java.diffs in the "Attachments" section of this issue
for the changes that were approved by the Servlet EG and committed
in the Servlet 2.5 timeframe.

One of the changes was to turn javax.servlet.http.NoBodyResponse from
an javax.servlet.http.HttpServletResponse to an
javax.servlet.http.HttpServletResponseWrapper,
according to these diffs:

-class NoBodyResponse implements HttpServletResponse {
- private HttpServletResponse resp;
+class NoBodyResponse extends HttpServletResponseWrapper {

This is relevant to your case, because you are dealing with a HEAD
request that is forward-dispatched.

Notice the impl of javax.servlet.http.HttpServlet#doHead, which wraps
the response inside a javax.servlet.http.NoBodyResponse, before calling
doGet:

NoBodyResponse response = new NoBodyResponse(resp);
doGet(req, response);
response.setContentLength();

>From your exception stack trace, it looks like weblogic's
RequestDispatcher impl unwraps the passed in response object (by
repeatedly calling getResponse() on it) until it has reached the
"bottom" response.

The bottom response object used to be an instance of
javax.servlet.http.NoBodyResponse, but now that NoBodyResponse
has been changed to be a response wrapper itself, this assumption
made by weblogic's RequestDispatcher impl is no longer true.

Jan

>
> ------------------------------------------------------------------------
> 好玩贺卡等你发,邮箱贺卡全新上线!
>

[att1.html]