java.lang.ClassCastException: io.undertow.servlet.spec.HttpServletRequestImpl cannot be cast to com.example.api.rest.security.api.DemoServletRequestWrapper


Solutions on the web

Solution icon of stackoverflow
io.undertow.servlet.spec.HttpServletRequestImpl cannot be cast to com.example.api.rest.security.api.DemoServletRequestWrapper

Stack trace

java.lang.ClassCastException: io.undertow.servlet.spec.HttpServletRequestImpl cannot be cast to com.example.api.rest.security.api.DemoServletRequestWrapper
	at com.example.api.filters.XSSFilter.doFilter(XSSFilter.java:30)[classes!/:na]
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)[spring-web-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[spring-web-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)[spring-web-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[spring-web-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)[spring-web-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[spring-web-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)[spring-web-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[spring-web-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)[undertow-core-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)[undertow-core-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)[undertow-core-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)[undertow-core-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)[undertow-core-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)[undertow-core-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:285)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:264)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:175)[undertow-servlet-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:207)[undertow-core-1.3.25.Final.jar!/:1.3.25.Final]
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:802)[undertow-core-1.3.25.Final.jar!/:1.3.25.Final]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)[na:1.8.0_112]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)[na:1.8.0_112]
	at java.lang.Thread.run(Unknown Source)[na:1.8.0_112]

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

You are the first who have seen this exception. Write a tip to help other users and build your expert profile.