Results 1 to 3 of 3

Thread: Weird Unmarshalling error from marshalSendAndReceive

  1. #1
    Join Date
    Jan 2010
    Posts
    14

    Default Weird Unmarshalling error from marshalSendAndReceive

    I used xjc to generate my JAXB classes and I have a very frustrating weird problem when marshalSendAndReceive tries to unmarshall the response object. I saw the response XML in my logs and it looks fine. When I save the XML response locally and use the same unmarshaller that is defined in applicationContext.xml it works fine but not when I connect to the webservice. Most responses are unmarshalled fine only some run into the error but even those responses get unmarshalled fine if I save the response XML locally and do unmarshalling.

    Here is my code that uses marshalSendAndReceive to unmarshall and runs into error:
    Code:
    response = (GetMyResponseType) ((JAXBElement<?>) myWebServiceTemplate.marshalSendAndReceive(request)).getValue();
    With Tracing I see the response XML comes through fine and looks fine too but the above call throws exception.

    I save the response XML and used the following code which unmarshall's the response fine.
    Code:
        private GetMyResponseType localXMLResponse() {
            GetMyResponseType getResponseType = new GetResponseType();
            org.springframework.oxm.Unmarshaller unMarshaller;
            FileInputStream is = null;
            try {
                is = new FileInputStream("/getDataItemResponse.xml");
                unMarshaller = myWebServiceTemplate.getUnmarshaller();
                getResponseType = (GetMyResponseType) ((JAXBElement<?>) unMarshaller.unmarshal(new StreamSource(is))).getValue();
            } catch (Exception e) {
                LOGGER.error("failed to load local data response file", e);
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (Exception e2) {
                    }
                }
            }
            return getDataItemResponseType;
        }
    The following is the Error details I get on marshalSendAndReceive.
    Code:
    org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: null; nested exception is javax.xml.bind.UnmarshalException
    
     - with linked exception:
    
    [java.lang.NullPointerException]
    
          at org.springframework.oxm.jaxb.JaxbUtils.convertJaxbException(JaxbUtils.java:92)
    
          at org.springframework.oxm.jaxb.AbstractJaxbMarshaller.convertJaxbException(AbstractJaxbMarshaller.java:143)
    
          at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:425)
    
          at org.springframework.ws.support.MarshallingUtils.unmarshal(MarshallingUtils.java:62)
    
          at org.springframework.ws.client.core.WebServiceTemplate$3.extractData(WebServiceTemplate.java:374)
    
          at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:560)
    
          at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:502)
    
          at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:351)
    
          at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:345)
    
          at gov.dhs.ice.oi.lecad.search_ui.springws.integration.wsclient.impl.GetDataItemDetailsTemplate.getDataItemRequest(GetDataItemDetailsTemplate.java:55)
    
          at gov.dhs.ice.oi.lecad.search_ui.springws.services.impl.GetDataItemImpl.getDataItemRequest(GetDataItemImpl.java:26)
    
         at gov.dhs.ice.oi.lecad.search_ui.mvc.action.SearchAction.execute(SearchAction.java:110)
    
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    
          at java.lang.reflect.Method.invoke(Method.java:592)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
    
          at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
    
          at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at org.apache.struts2.interceptor.validation.JSONValidationInterceptor.doIntercept(JSONValidationInterceptor.java:116)
    
          at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
    
          at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    
          at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)

  2. #2
    Join Date
    Jan 2010
    Posts
    14

    Default Error message continuation

    more error message ..
    Code:
          at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    
          at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    
          at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
    
          at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    
          at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    
          at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    
          at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
    
          at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    
          at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
    
          at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    
          at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
          at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
          at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
          at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
          at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
          at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
          at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
          at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
          at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
          at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
    
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    
         at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
    
          at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    
          at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    
          at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
    
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    
          at java.lang.Thread.run(Thread.java:595)
    
    Caused by: javax.xml.bind.UnmarshalException
    
     - with linked exception:
    
    [java.lang.NullPointerException]
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:395)
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:334)
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:304)
    
          at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshalStaxSource(Jaxb2Marshaller.java:432)
    
          at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:418)
    
          ... 92 more
    
    Caused by: java.lang.NullPointerException
    
          at org.apache.xml.utils.DOMBuilder.startElement(DOMBuilder.java:354)
    
          at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1042)
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader.startElement(DomLoader.java:82)
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:369)
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:347)
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:35)
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:200)
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:134)
    
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:332)
    
          ... 95 more
    
    Caused by: java.lang.NullPointerException
    
          at org.apache.xml.utils.DOMBuilder.startElement(DOMBuilder.java:326)
    
          ... 103 more

  3. #3
    Join Date
    Jan 2010
    Posts
    14

    Default

    Well, downloaded source code for several libraries and finally traced the problem to be in Axiom 1.2.2 I was using as it was getting NPE while trying to get attribute type (namespace specified at beginning) for an element(nested namespace). I update the Axiom library to 1.2.8 and the problem is resolved.

    I didn't spend time to investigate how it got resolved but I think either the fix WSCOMMONS-415, or it could be one of the several others related to reading XML stream. If I get time I will investigate what change in the new version fixed it. Axiom 1.2.8.

    The line of code that caused the NPE is in :
    org.apache.xml.utils.DOMBuilder.startElement at this line
    Code:
     //System.out.println("type " + atts.getType(i) + " name " + atts.getLocalName(i) );
              // First handle a possible ID attribute
              if (atts.getType(i).equalsIgnoreCase("ID"))
    atts.getType(i) is null here for some reason with 1.2.2
    Last edited by kitsVA; Apr 20th, 2010 at 05:56 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •