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

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to