Announcement Announcement Module
Collapse
No announcement yet.
Spring Webservice with Jaxb Marshalling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Webservice with Jaxb Marshalling

    I am new to spring web services and currently trying to develop a contract first web service using spring ws 1.5.6. I want to use jaxb 2.0 marshaller to do all manipulation in form of java objects. But currently i am getting an exception in unmarshaling of incoming request. i have been fighting with it for last 2 days. Please help me in resolving this issue.

    Here is the log of the error. From the log you can see that end point is correctly mapped to incoming request but when it tries to unmarshal incoming object it gives the following exception.

    19:17:50,264DEBUG PayloadRootAnnotationMethodEndpointMapping:61 - Looking up endpoint for [{http://mycompany.com/hr/schemas}HolidayRequest]
    19:17:50,269DEBUG SoapMessageDispatcher:251 - Endpoint mapping [org.springframework.ws.server.endpoint.mapping.Pay loadRootAnnotationMethodEndpointMapping@162ba99] maps request to endpoint [public void com.mycompany.hr.ws.AnnotationEndpoint.handleCongr essRegistrationRequest(com.mycompany.hr.schema.Hol idayRequest)]
    19:17:50,274DEBUG SoapMessageDispatcher:273 - Testing endpoint adapter [org.springframework.ws.server.endpoint.adapter.Gen ericMarshallingMethodEndpointAdapter@89c116]
    19:17:50,339DEBUG MessageDispatcherServlet:588 - Could not complete request
    java.lang.NoSuchMethodError: com.sun.xml.bind.unmarshaller.DOMScanner.setConten tHandler(Lorg/xml/sax/ContentHandlerV
    at com.sun.xml.bind.v2.runtime.unmarshaller.Unmarshal lerImpl.unmarshal0(UnmarshallerImpl.java:311)
    at com.sun.xml.bind.v2.runtime.unmarshaller.Unmarshal lerImpl.unmarshal(UnmarshallerImpl.java:297)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.un marshal(AbstractUnmarshallerImpl.java:107)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmar shal(Jaxb2Marshaller.java:421)
    at org.springframework.ws.support.MarshallingUtils.un marshal(MarshallingUtils.java:62)
    at org.springframework.ws.server.endpoint.adapter.Mar shallingMethodEndpointAdapter.unmarshalRequest(Mar shallingMethodEndpointAdapter.java:143)
    at org.springframework.ws.server.endpoint.adapter.Mar shallingMethodEndpointAdapter.invokeInternal(Marsh allingMethodEndpointAdapter.java:134)
    at org.springframework.ws.server.endpoint.adapter.Abs tractMethodEndpointAdapter.invoke(AbstractMethodEn dpointAdapter.java:58)
    at org.springframework.ws.server.MessageDispatcher.di spatch(MessageDispatcher.java:221)
    at org.springframework.ws.server.MessageDispatcher.re ceive(MessageDispatcher.java:168)
    at org.springframework.ws.transport.support.WebServic eMessageReceiverObjectSupport.handleConnection(Web ServiceMessageReceiverObjectSupport.java:88)
    at org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter.handle(WebServiceMessa geReceiverHandlerAdapter.java:57)
    at org.springframework.ws.transport.http.MessageDispa tcherServlet.doService(MessageDispatcherServlet.ja va:230)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:511)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    Configurations

    <bean id="congressRegistrationEndpoint" class="com.mycompany.hr.ws.AnnotationEndpoint">
    <constructor-arg ref="hrService"/>
    </bean>

    <bean class="org.springframework.ws.server.endpoint.adap ter.GenericMarshallingMethodEndpointAdapter">
    <constructor-arg ref="marshaller"/>
    </bean>

    <bean class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootAnnotationMethodEndpointMapping"/>

    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">
    <property name="contextPath" value="com.mycompany.hr.schema"/>
    </bean>

    <bean id="hrService" class="com.mycompany.hr.service.StubHumanResourceS ervice"/>
    Annotation End point:

    Code:
    @Endpoint
    public class AnnotationEndpoint {
    
    	private HumanResourceService humanResourceService;
    	
    	public AnnotationEndpoint(HumanResourceService humanResourceService) {
    		this.humanResourceService = humanResourceService;
    	}
    
    
    	@PayloadRoot(localPart = "HolidayRequest", namespace = "http://mycompany.com/hr/schemas")
    	public void handleCongressRegistrationRequest(HolidayRequest holidayRequest) {
    System.out.println("**************"+holidayRequest.getFirstName());
    		return;
    	}
    }
    Please see if i am doing anything wrong.

    regards,
    Muein
    Last edited by mmuzamil; Apr 21st, 2009, 10:40 AM.

  • #2
    Hi all,

    i have fixed this issue, at the end it turned out to be conflict between different versions (1 and 2.1) of jaxb api. I have removed jar files of jaxb V1 from my project and web service is now up and running.

    Cheers,
    Muein

    Comment

    Working...
    X