title: Spring Web service throws com.sun.xml.internal.messaging.saaj.soap.ver1_1.BodyElement1_1Impl cannot be cast to org.jdom.Element
body: <p>I am totally new to Spring and started self studying from the begining as I want to develop as Spring-WS based web service.
   I have created <code>schemas.xsd, spring-ws-servlet.xml</code> and <code>web.xml</code> files in <code>WEB-INF</code> folder.
  Also implemented the endpoint annotated with <code>@Endpoint</code>. 
  In my <code>scehmas.xsd</code> I have below element</p>
  
  <pre><code>&lt;xsd:element name="SimpleRequest"&gt;
          &lt;xsd:complexType&gt;
              &lt;xsd:sequence&gt;
                  &lt;xsd:element name="reName" type="xsd:string" /&gt;                       
              &lt;/xsd:sequence&gt;
          &lt;/xsd:complexType&gt;
      &lt;/xsd:element&gt;
  </code></pre>
  
  <p>and in <code>web.xml</code> I specify the spring-ws message dispatcher servlet as below.</p>
  
  <pre><code>&lt;servlet&gt;
          &lt;servlet-name&gt;spring-ws&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.ws.transport.http.MessageDispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring-ws-servlet.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;transformWsdlLocations&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;spring-ws&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>In <code>spring-ws-servlet.xml</code> I define the endpoint</p>
  
  <pre><code>    &lt;context:component-scan base-package="com.test" /&gt;
  
  &lt;sws:annotation-driven /&gt;
  
  &lt;sws:dynamic-wsdl id="form" portTypeName="GUIForm"
      locationUri="/forms/"&gt;
      &lt;sws:xsd location="/WEB-INF/schemas.xsd" /&gt;
  &lt;/sws:dynamic-wsdl&gt;
  
  &lt;bean id="formsEndpoint" class="com.test.FormsEndpoint"  /&gt;
  
  &lt;bean
      class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"&gt;
      &lt;property name="defaultEndpoint" ref="formsEndpoint" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>In my <code>FormsEndpoint</code> class I have the below method,</p>
  
  <pre><code>@PayloadRoot(namespace = NAMESPACE_URI, localPart = "SimpleRequest")
      @ResponsePayload
      public Element handleFormsRequest(@RequestPayload Element simpleRequest) throws  JDOMException, ParserConfigurationException
              {
  
          System.out.println("================ Hit on Endpoint ========================");
          String formId = formIdExpression.valueOf(simpleRequest);
  
        }
  </code></pre>
  
  <p>At the line <code>formIdExpression.valueOf(simpleRequest);</code> it always throws </p>
  
  <pre><code>java.lang.ClassCastException: com.sun.xml.internal.messaging.saaj.soap.ver1_1.BodyElement1_1Impl cannot be cast to org.jdom.Element
      at org.jaxen.jdom.DocumentNavigator.getDocumentNode(DocumentNavigator.java:396)
      at org.jaxen.expr.DefaultAbsoluteLocationPath.evaluate(DefaultAbsoluteLocationPath.java:102)
      at org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:102)
      at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:674)
      at org.jaxen.BaseXPath.selectSingleNodeForContext(BaseXPath.java:698)
      at org.jaxen.BaseXPath.stringValueOf(BaseXPath.java:279)
      at org.jdom.xpath.JaxenXPath.valueOf(JaxenXPath.java:182)
      at com.neurotec.mmafis.FormsEndpoint.handleFormsRequest(FormsEndpoint.java:53)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.springframework.ws.server.endpoint.MethodEndpoint.invoke(MethodEndpoint.java:134)
      at org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter.invokeInternal(DefaultMethodEndpointAdapter.java:240)
      at org.springframework.ws.server.endpoint.adapter.AbstractMethodEndpointAdapter.invoke(AbstractMethodEndpointAdapter.java:53)
      at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:233)
      at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:173)
      at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
      at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:59)
      at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:292)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:744)
  </code></pre>
  
  <p>I have tested a request using soapUI plugin in eclipse. Any ideas on why this occurs will highly appreciated.</p>