I am using mule with maven. I have used a xml to object converter. My model files are annotated with jaxb annotations. The JAXB context ref looks like this -:
mulexml:jaxb-context name="JAXB_Context" packageNames="com.xml.model" doc:name="JAXB Context"/>
I have created a jaxb.index file with the names of the JAXB annotated classes and placed in the com.xml.model folder.
But still it shows the following exception -:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_muleNotificationManager': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'JAXB_Context': Invocation of init method failed; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "com.xml.model" doesnt contain ObjectFactory.class or jaxb.index - with linked exception: [javax.xml.bind.JAXBException: "com.xml.model" doesnt contain ObjectFactory.class or jaxb.index]
This has worked for the mule project without maven.
I have found the solution for it. We need to keep the
jaxb.index
file in theresources
folder with the same package structure.I think when using Maven, it doesn't pick the file from the package. It uses its own build methods, but when used without Maven the build is done by Anypoint studio's own build methods and so it gets the jaxb file.