Results 1 to 2 of 2

Thread: Jaxb2Marshaller with contextPaths not using ObjectFactory?

  1. #1
    Join Date
    May 2011
    Posts
    13

    Question Jaxb2Marshaller with contextPaths not using ObjectFactory?

    Currently I have my Web Service Endpoint methods defined like so:

    Code:
    public @ResponsePayload SomeResponseObject getFoo(@RequestPayload SomeRequestObject request) {
      //...
    }
    My (partial) configuration looks like this:
    Code:
        @Bean
        public Jaxb2Marshaller marshaller() {
            Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
            marshaller.setContextPaths("com.mycompany.package1", "com.mycompany.package2", "com.mycompany.package3");
            marshaller.setSchemas(schemaLocations());
            return marshaller;
        }
    
        @Bean
        public MessageDispatcher messageDispatcher() {
            SoapMessageDispatcher dispatcher = new SoapMessageDispatcher();
            dispatcher.setEndpointAdapters(Collections.<EndpointAdapter>singletonList(endpointAdapter()));
            return dispatcher;
        }
    
    
        @Bean
        public EndpointAdapter endpointAdapter() {
            DefaultMethodEndpointAdapter adapter = new DefaultMethodEndpointAdapter();
            MarshallingPayloadMethodProcessor processor = new MarshallingPayloadMethodProcessor(marshaller());
            adapter.setMethodArgumentResolvers(Collections.<MethodArgumentResolver>singletonList(processor));
            adapter.setMethodReturnValueHandlers(Collections.<MethodReturnValueHandler>singletonList(processor));
            return adapter;
        }
    I thought that since I'm defining my Marshaller with contextPaths, the ObjectFactory classes located in those packages would be used for object creation. However, when I place breakpoints there it doesn't seem to be the case. Why is that, and is there a way to ensure that ObjectFactory is used? I need to do this so that I can force instantiation of some custom extension classes instead of the base generated classes.

  2. #2
    Join Date
    May 2011
    Posts
    13

    Default

    I ended up setting the unmarshaller properties to set the ObjectFactories directly, taking the answer from the thread:
    http://forum.springsource.org/showth...-ObjectFactory

    The only difference is that I used the "com.sun.xml.internal.bind.ObjectFactory" instead of "com.sun.xml.bind.ObjectFactory" since I'm using Java's internal JAXB implementation.

Tags for this Thread

Posting Permissions

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