javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory n
Hi,
I am having a problem with Jaxb. I am using Jaxb1.0.4 and the dependecy list in my pom looks like this.
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-impl</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-libs</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>relaxngDatatype</groupId>
<artifactId>relaxngDatatype</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-api</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jax-qname</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>namespace</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>xsdlib</groupId>
<artifactId>xsdlib</artifactId>
<version>1.0</version>
</dependency>
Testcase
public static String asXML(Object jaxbObject, String contextPath) throws JAXBException {
JAXBContext context = JAXBContext.newInstance(contextPath);
Validator v = context.createValidator();
v.validate(jaxbObject);
ByteArrayOutputStream out = new ByteArrayOutputStream();
context.createMarshaller().marshal(jaxbObject,out);
return out.toString();
}
When I run my test class to marshall a Jaxb object I get the following exception.
javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory not found
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:151)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:299)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
at za.co.rmb.calypso.binding.utils.ObjectBinder.asXML(ObjectBinder.java:33)
There is no Jaxb 2.0 jar in my repository. Please suggest if anyone have an idea / workaournd to getrid of this error..
Thanks

