You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Martin Grigorov <mg...@apache.org> on 2017/01/06 13:23:54 UTC

Wrong type of the value of javax.servlet.error.exception_type

Hi,

I've just upgraded my local/development Tomcat to 8.5.10 and I've hit a
problem in Apache Wicket:

java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Class
at
org.apache.wicket.protocol.http.servlet.ErrorAttributes.of(ErrorAttributes.java:152)


line 152 is:
Class<? extends Throwable> type = (Class<? extends
Throwable>)request.getAttribute("javax.servlet.error.exception_type");

In a debugger I see that the value is the class name, not the class itself.

According to
http://download.oracle.com/otn-pub/jcp/servlet-3.0-fr-eval-oth-JSpec/servlet-3_0-final-spec.pdf,
p.10.9.1, table 10-1 the type of the value should be:

Request Attributes                      Type
javax.servlet.error.status_code java.lang.Integer
javax.servlet.error.exception_type java.lang.Class       <<< a Class
javax.servlet.error.message java.lang.String
javax.servlet.error.exception java.lang.Throwable
javax.servlet.error.request_uri java.lang.String
javax.servlet.error.servlet_name java.lang.String


I didn't see any change related to this between 8.5.8 and 8.5.10 so I'm not
sure whether this should be a stopper for the release of 8.5.10.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

Re: Wrong type of the value of javax.servlet.error.exception_type

Posted by Martin Grigorov <mg...@apache.org>.
Hi Chris,

On Fri, Jan 6, 2017 at 9:49 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> Martin,
>
> On 1/6/17 8:23 AM, Martin Grigorov wrote:
> > I've just upgraded my local/development Tomcat to 8.5.10 and I've hit a
> > problem in Apache Wicket:
> >
> > java.lang.ClassCastException: java.lang.String cannot be cast to
> > java.lang.Class
> > at
> > org.apache.wicket.protocol.http.servlet.ErrorAttributes.
> of(ErrorAttributes.java:152)
> >
> >
> > line 152 is:
> > Class<? extends Throwable> type = (Class<? extends
> > Throwable>)request.getAttribute("javax.servlet.error.exception_type");
> >
> > In a debugger I see that the value is the class name, not the class
> itself.
> >
> > According to
> > http://download.oracle.com/otn-pub/jcp/servlet-3.0-fr-
> eval-oth-JSpec/servlet-3_0-final-spec.pdf,
> > p.10.9.1, table 10-1 the type of the value should be:
> >
> > Request Attributes                      Type
> > javax.servlet.error.status_code java.lang.Integer
> > javax.servlet.error.exception_type java.lang.Class       <<< a Class
> > javax.servlet.error.message java.lang.String
> > javax.servlet.error.exception java.lang.Throwable
> > javax.servlet.error.request_uri java.lang.String
> > javax.servlet.error.servlet_name java.lang.String
> >
> >
> > I didn't see any change related to this between 8.5.8 and 8.5.10 so I'm
> not
> > sure whether this should be a stopper for the release of 8.5.10.
>
> I only see a single instance of javax.servlet.error.exception_type in
> 8.5 trunk (in javax/servlet/RequestDispatcher.ERROR_EXCEPTION_TYPE) and
> a single use of ERROR_EXCEPTION_TYPE itself (in
> o.a.c.core.StandardHostValve) and the code is fairly straightforward:
>
> // line 330:
> request.setAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE,
>                                   realError.getClass());
>
> The reference "realError" is a java.lang.Throwable, and, presumably,
> realError.getClass will always return a java.lang.Class object.
>
> Can you see where that request attribute is being set in your test? I
> wonder if either Wicket or the application itself is abusing that
> request attribute.
>

Thanks for your answer!
Since Tomcat is not guilty here it must be the middleware! I've found it
easily:
https://github.com/spring-projects/spring-boot/search?utf8=%E2%9C%93&q=ERROR_EXCEPTION_TYPE
I'll log an issue at Spring Boot!



>
> -chris
>
>

Re: Wrong type of the value of javax.servlet.error.exception_type

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Martin,

On 1/6/17 8:23 AM, Martin Grigorov wrote:
> I've just upgraded my local/development Tomcat to 8.5.10 and I've hit a
> problem in Apache Wicket:
> 
> java.lang.ClassCastException: java.lang.String cannot be cast to
> java.lang.Class
> at
> org.apache.wicket.protocol.http.servlet.ErrorAttributes.of(ErrorAttributes.java:152)
> 
> 
> line 152 is:
> Class<? extends Throwable> type = (Class<? extends
> Throwable>)request.getAttribute("javax.servlet.error.exception_type");
> 
> In a debugger I see that the value is the class name, not the class itself.
> 
> According to
> http://download.oracle.com/otn-pub/jcp/servlet-3.0-fr-eval-oth-JSpec/servlet-3_0-final-spec.pdf,
> p.10.9.1, table 10-1 the type of the value should be:
> 
> Request Attributes                      Type
> javax.servlet.error.status_code java.lang.Integer
> javax.servlet.error.exception_type java.lang.Class       <<< a Class
> javax.servlet.error.message java.lang.String
> javax.servlet.error.exception java.lang.Throwable
> javax.servlet.error.request_uri java.lang.String
> javax.servlet.error.servlet_name java.lang.String
> 
> 
> I didn't see any change related to this between 8.5.8 and 8.5.10 so I'm not
> sure whether this should be a stopper for the release of 8.5.10.

I only see a single instance of javax.servlet.error.exception_type in
8.5 trunk (in javax/servlet/RequestDispatcher.ERROR_EXCEPTION_TYPE) and
a single use of ERROR_EXCEPTION_TYPE itself (in
o.a.c.core.StandardHostValve) and the code is fairly straightforward:

// line 330:
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE,
                                  realError.getClass());

The reference "realError" is a java.lang.Throwable, and, presumably,
realError.getClass will always return a java.lang.Class object.

Can you see where that request attribute is being set in your test? I
wonder if either Wicket or the application itself is abusing that
request attribute.

-chris