1

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.

Xstian
  • 8,184
  • 10
  • 42
  • 72
Arup Mishra
  • 189
  • 2
  • 14

3 Answers3

2

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.

Yuri
  • 4,254
  • 1
  • 29
  • 46
Arup Mishra
  • 189
  • 2
  • 14
  • Yes, the `jaxb.index` file has to be placed in `Maven`'s resource folder in order to get exported into a deployable package correctly. – Yuri Nov 07 '18 at 12:01
0

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.

Ralph Rimorin
  • 329
  • 2
  • 10
  • 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. – Arup Mishra Feb 12 '16 at 07:11
  • We normally use a plugin in maven to generate the jaxb.index and the ObjectFactory automatically. Maven will also put that in the target directory/ inside the generated zip file. Check this link: http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/example_xjc_basic.html – Ralph Rimorin Feb 12 '16 at 07:28
0

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

  1. 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"/>

  2. 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! :)

Striker
  • 331
  • 3
  • 6