java.lang.ClassCastException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Soap headers that contain whitespace between xml elements result in ClassCastExceptions when using Sun's SAAJ 1.2 jar (I'm using Sun's 1.1 soap message factory "com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"). If you remove the whitespace between the xml elements on the Soap header on the request, the ClassCastException goes away. The error is caused by the following code that assumes all nodes returned back are SOAPHeaderElement instances but the whitespace nodes are returned back as com.sun.xml.messaging.saaj.soap.impl.TextImpl instances. org.springframework.ws.soap.saaj.SaajSoap11Header public Iterator examineHeaderElementsToProcess(String[] actors) { List result = new ArrayList(); Iterator iterator = getImplementation().examineAllHeaderElements(getSaajHeader()); while (iterator.hasNext()) { SOAPHeaderElement saajHeaderElement = (SOAPHeaderElement) iterator.next(); <- class cast happens here Here's the stack trace: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl at org.springframework.ws.soap.saaj.SaajSoap11Header.examineHeaderElementsToProcess(SaajSoap11Header.java:46) at org.springframework.ws.soap.server.SoapMessageDispatcher.handleHeaders(SoapMessageDispatcher.java:108) at org.springframework.ws.soap.server.SoapMessageDispatcher.handleRequest(SoapMessageDispatcher.java:92) at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:199) at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:162) at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:87) at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57) at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:197) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441) at javax.servlet.http.HttpServlet.service(HttpServlet.java:763) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3231) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    via by Mark LaFond,
  • Soap headers that contain whitespace between xml elements result in ClassCastExceptions when using Sun's SAAJ 1.2 jar (I'm using Sun's 1.1 soap message factory "com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"). If you remove the whitespace between the xml elements on the Soap header on the request, the ClassCastException goes away. The error is caused by the following code that assumes all nodes returned back are SOAPHeaderElement instances but the whitespace nodes are returned back as com.sun.xml.messaging.saaj.soap.impl.TextImpl instances. org.springframework.ws.soap.saaj.SaajSoap11Header public Iterator examineHeaderElementsToProcess(String[] actors) { List result = new ArrayList(); Iterator iterator = getImplementation().examineAllHeaderElements(getSaajHeader()); while (iterator.hasNext()) { SOAPHeaderElement saajHeaderElement = (SOAPHeaderElement) iterator.next(); <- class cast happens here Here's the stack trace: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl at org.springframework.ws.soap.saaj.SaajSoap11Header.examineHeaderElementsToProcess(SaajSoap11Header.java:46) at org.springframework.ws.soap.server.SoapMessageDispatcher.handleHeaders(SoapMessageDispatcher.java:108) at org.springframework.ws.soap.server.SoapMessageDispatcher.handleRequest(SoapMessageDispatcher.java:92) at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:199) at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:162) at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:87) at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57) at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:197) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441) at javax.servlet.http.HttpServlet.service(HttpServlet.java:763) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3231) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    via by Mark LaFond,
    • java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl at org.springframework.ws.soap.saaj.SaajSoap11Header.examineHeaderElementsToProcess(SaajSoap11Header.java:46) at org.springframework.ws.soap.server.SoapMessageDispatcher.handleHeaders(SoapMessageDispatcher.java:108) at org.springframework.ws.soap.server.SoapMessageDispatcher.handleRequest(SoapMessageDispatcher.java:92) at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:199) at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:162) at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:87) at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57) at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:197) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441) at javax.servlet.http.HttpServlet.service(HttpServlet.java:763) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3231) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    No Bugmate found.