title: Mixing and extending Spring XML configuration
body: <p>I have a Spring MVC project using XML for the main config, including registering JAXB classes.  I'm now making this into a multi-module app, and have a separate project that creates an optional JAR file.  The JAR file adds things like @Controller and @Service classes to the main MVC project, but the main project does not depend on that JAR, and I want to keep it that way, so I don't want to have to customise the application context xml in the main project in order to add in support for the optional JAR; I just want to add that JAR to the classpath.  </p>
  
  <p>In that optional JAR, I'm successfully using a class with a @Configuration annotation to create new beans in my application context, but I now need to extend an existing bean, to add in new JAXB annotated classes and packages containing ObjectFactory classes, etc.</p>
  
  <p>I can't see how to do this...</p>
  
  <p>I've tried to wildcard the marshaller packages like this:</p>
  
  <pre><code>&lt;bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"&gt;
     &lt;property name="packagesToScan" value="com.app.xml.**"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>but that doesn't seem to be working, since I get:</p>
  
  <pre><code>javax.servlet.ServletException: Unable to locate object to be marshalled in model
  </code></pre>
  
  <p>Is there another approach I can take?  Ideally, I'd like to have a method in my @Configuration class that just adds in new classes to an existing Jaxb2Marshaller bean...</p>
  
  <p>Or even better, find a way to get Spring to detect all classes with JAXB annotations on startup...</p>
  
  <p>I'm using Spring 3.2.1 and JAXB2 via Spring OXM</p>