title: Inject JAXBContext into spring
body: <p>I am trying to inject a <code>JAXBContext</code> into spring application context, by:</p>
  
  <pre><code>&lt;bean id="jaxbContext" class="javax.xml.bind.JAXBContext" factory-method="newInstance"&gt;
    &lt;constructor-arg type="java.lang.Class" value="com.package.MyClassName"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>It throws an exception:</p>
  
  <blockquote>
    <p>No matching factory method found: factory method 'newInstance'</p>
  </blockquote>
  
  <p>And I also try :</p>
  
  <pre><code>&lt;bean id="jaxbContext" class="javax.xml.bind.JAXBContext" factory-method="newInstance"&gt;
    &lt;constructor-arg type="java.lang.String" value="com.package"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>And It throws an an exception:</p>
  
  <blockquote>
    <p>javax.xml.bind.JAXBException: "com.package" doesnt contain ObjectFactory.class or jaxb.index
    I did put a jaxb.index file inside the package "com.package" and has a single line "MyClassName" in the file.</p>
  </blockquote>