java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl

Spring JIRA | Mark LaFond | 9 years ago
  1. 0

    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)

    Spring JIRA | 9 years ago | Mark LaFond
    java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl
  2. 0

    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)

    Spring JIRA | 9 years ago | Mark LaFond
    java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl
  3. 0

    Problems with SoapMessage Handler in SJS AS 8.1

    Oracle Community | 1 decade ago | 843833
    java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Problems with SoapMessage Handler in SJS AS 8.1

    Oracle Community | 1 decade ago | 843833
    java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      com.sun.xml.messaging.saaj.soap.impl.TextImpl

      at org.springframework.ws.soap.saaj.SaajSoap11Header.examineHeaderElementsToProcess()
    2. Spring WS Core
      MessageDispatcherServlet.doService
      1. org.springframework.ws.soap.saaj.SaajSoap11Header.examineHeaderElementsToProcess(SaajSoap11Header.java:46)
      2. org.springframework.ws.soap.server.SoapMessageDispatcher.handleHeaders(SoapMessageDispatcher.java:108)
      3. org.springframework.ws.soap.server.SoapMessageDispatcher.handleRequest(SoapMessageDispatcher.java:92)
      4. org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:199)
      5. org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:162)
      6. org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:87)
      7. org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57)
      8. org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:197)
      8 frames
    3. Spring MVC
      FrameworkServlet.doPost
      1. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
      2. org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
      2 frames
    4. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
      2. javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      2 frames
    5. Atmosphere weblogic
      WebAppServletContext$ServletInvocationAction.run
      1. weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      2. weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
      3. weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
      4. weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
      5. weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3231)
      5 frames
    6. weblogic.security.acl
      AuthenticatedSubject.doAs
      1. weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      1 frame
    7. weblogic.security.service
      SecurityManager.runAs
      1. weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
      1 frame
    8. Atmosphere weblogic
      ServletRequestImpl.run
      1. weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2002)
      2. weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1908)
      3. weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1362)
      3 frames
    9. weblogic.work
      ExecuteThread.run
      1. weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
      2. weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
      2 frames