karlmdavis / rps-tourney

An online multi-player Rock-Paper-Scissors game. Just because.
https://rpstourney.com/
1 stars 2 forks source link

Web service throws 500 errors at AuthenticationFilter:137 if a 404 is encountered #108

Closed karlmdavis closed 8 years ago

karlmdavis commented 8 years ago

If the web service encounters an issue like this:

2015-12-13 20:49:33,503 [http-bio-60127-exec-6] WARN  o.apache.cxf.jaxrs.utils.JAXRSUtils - No operation matching request path "/rps-tourney-service-app/players/player" is found, Relative Path: /player, HTTP Method: GET, ContentType: */*, Accept: text/xml,. Please enable FINE/TRACE log level for more details.
2015-12-13 20:49:33,503 [http-bio-60127-exec-6] WARN  o.a.c.j.i.WebApplicationExceptionMapper - javax.ws.rs.ClientErrorException: HTTP 404 Not Found
    at org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:117)
    at org.apache.cxf.jaxrs.utils.ExceptionUtils.toHttpException(ExceptionUtils.java:166)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:529)
    ...

It will then go kaboom like this:

2015-12-13 20:49:33,505 [http-bio-60127-exec-6] WARN  o.a.cxf.phase.PhaseInterceptorChain - Interceptor for {http://app.service.rpstourney.karl.justdavis.com/}ServiceStatusResourceImpl has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: org.apache.cxf.jaxrs.impl.SecurityContextImpl cannot be cast to com.justdavis.karl.rpstourney.service.app.auth.AccountSecurityContext
    at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleWriteException(JAXRSOutInterceptor.java:363) ~[cxf-rt-frontend-jaxrs-3.0.4.jar:3.0.4]
    at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:188) ~[cxf-rt-frontend-jaxrs-3.0.4.jar:3.0.4]
    ...
Caused by: java.lang.ClassCastException: org.apache.cxf.jaxrs.impl.SecurityContextImpl cannot be cast to com.justdavis.karl.rpstourney.service.app.auth.AccountSecurityContext
    at com.justdavis.karl.rpstourney.service.app.auth.AuthenticationFilter.filter(AuthenticationFilter.java:137) ~[classes/:na]
    at com.justdavis.karl.rpstourney.service.app.auth.AuthenticationFilter$$FastClassBySpringCGLIB$$c7781151.invoke(<generated>) ~[spring-core-4.1.2.RELEASE.jar:na]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.1.2.RELEASE.jar:4.1.2.RELEASE]
    ...

I think the 404 is pre-empting the portion of the filter that sets up the security context on the request side, so that when it tries to use the security context on the response side, it can't.

This is all really just a guess, though: an IT will be needed to confirm.