问题
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.
回答1:
I have found the solution for it. We need to keep the jaxb.index
file in the resources
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.
回答2:
Arup, can you check whether the zip file or the jar file containing the package/classes com.xml.model.* exist. That means that the project wasn't able to see those in the generated compressed file by maven.
回答3:
Here is how I got it to work with jaxb.index
Say, all you marshalling classes like Order, Customer, Merchant are located in package com.common.beans
Your flow xml Jaxb-Context will be configured pointing to that package: <mulexml:jaxb-context name="JAXB_Context" packageNames="com.common.beans" doc:name="JAXB Context"/>
Inside com.common.beans package create a file jaxb.index with content of your marshalling classes as follows on each line:
Order
Customer
Merchant
The Error should go away.
Enjoy! :)
来源:https://stackoverflow.com/questions/35285223/mule-jaxb-binding-error-package-doesnt-contain-objectfactory-class-or-jaxb-i