Announcement Announcement Module
Collapse
No announcement yet.
Jaxb2Marshaller with contextPaths not using ObjectFactory? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X