OpenSAML-sample-code icon indicating copy to clipboard operation
OpenSAML-sample-code copied to clipboard

Class cast exception

Open Moorthy70 opened this issue 3 years ago • 7 comments

java.lang.ClassCastException: class org.opensaml.saml.saml2.core.impl.ResponseImpl cannot be cast to class org.opensaml.saml.saml2.core.AuthnRequest (org.opensaml.saml.saml2.core.impl.ResponseImpl and org.opensaml.saml.saml2.core.AuthnRequest are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @12aeb4f4) at ReceiverServlet.doPost(ReceiverServlet.java:36) at javax.servlet.http.HttpServlet.service(HttpServlet.java:652) at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:833)

Moorthy70 avatar Jul 26 '22 05:07 Moorthy70

i am also getting this exception what may be the reason

gtiwari2015 avatar Nov 18 '22 11:11 gtiwari2015

@Moorthy70 did you find a solution ?

davidsielert avatar Jun 30 '23 01:06 davidsielert

Hi @Moorthy70, wondering if you could resolve this issue?. I am having the same error!

irinadiaz avatar Nov 19 '24 17:11 irinadiaz

@irinadiaz Last emails on this ended up in a folder I didnt look into. I will look into this. What specific sample are you trying to run? What JDK version are you on?

rasmusson avatar Nov 20 '24 08:11 rasmusson

I'm seeing this same issue, @rasmusson I'm trying to run the OpenSAML Signing and Verification sample project, getting this error from line 59 of the ReceiverServlet. JDK 1.8.0_172 opensaml version 3.1.1

-e I ended up getting around this issue by simply not using the AuthnRequest cast. The main use of the AuthnRequest object was the call to getSignature() which is also accessible if you cast to ResponseImpl, I just cast to that instead. The other use was passing the authnRequest into the logSAMLObject method which also works with the a ResponseImpl object.

MrJGentry avatar Nov 22 '24 22:11 MrJGentry

Im trying to reproduce it but am not able to. @MrJGentry You say above that you are using 3.1.1. Is that correct? The version used in my code is 4.1.1

rasmusson avatar Dec 13 '24 18:12 rasmusson

Tried to recreate this from a fresh VM. Using jkd 11 which is needed for opensaml 4. I get no error. Did you all just checkout and run mvn tomct:run or did you do any changes to the code?

rasmusson avatar Dec 13 '24 18:12 rasmusson