Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JAXB runtime ClassNotFoundException

843834Dec 12 2009 — edited Dec 14 2009
I'm trying to set up some really basic build stuff using ant and JAXB to handle the transforming of some XML data, but I'm having some trouble getting it to not throw exceptions at runtime. I've successfully got an XJC task running in ant that is definitely outputting all the correct java classes, and they compile without an issue.

The problems occur when I either try to unmarshall or marshall any data using a JAXBContext. basically, my code looks something like this:
public class Deserializer<T>
{
	private JAXBContext m_context;
	private Unmarshaller m_unmarshaller;

	public Deserializer(String contextPath)
	{
		try
		{
			JAXBContext m_context = JAXBContext.newInstance(contextPath);
			Unmarshaller m_unmarshaller = m_context.createUnmarshaller();
		}

		catch (JAXBException e)
		{
			System.out.println(e);
		}
	}

	public T deserialize(File xml)
	{
		try
		{
			return (T)m_unmarshaller.unmarshal(new FileInputStream(xml));
		}

		catch (FileNotFoundException e)
		{
			System.out.println(e);
		}

		catch (IOException e)
		{
			System.out.println(e);
		}

		catch (JAXBException e)
		{
			System.out.println(e);
		}

		return null;
	}
}
and the exception that I am seeing when the unmarshal function is called is this:
[java] Caused by: javax.xml.datatype.DatatypeConfigurationException: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not found
     [java] 	at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:137)
     [java] 	at com.sun.xml.bind.DatatypeConverterImpl.<clinit>(DatatypeConverterImpl.java:740)
     [java] 	... 39 more
     [java] Caused by: java.lang.ClassNotFoundException: org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl
     [java] 	at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1400)
     [java] 	at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1341)
     [java] 	at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1094)
     [java] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
     [java] 	at javax.xml.datatype.FactoryFinder.getProviderClass(FactoryFinder.java:115)
     [java] 	at javax.xml.datatype.FactoryFinder.newInstance(FactoryFinder.java:146)
     [java] 	at javax.xml.datatype.FactoryFinder.findJarServiceProvider(FactoryFinder.java:298)
     [java] 	at javax.xml.datatype.FactoryFinder.find(FactoryFinder.java:223)
     [java] 	at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:131)
     [java] 	... 40 more
which looks like maybe my classpath might be wrong? im really not sure. Ive tried downloading xerces .jar's and pointing the classpath at that, with identical results. For reference, I'm not using any IDE's, just good old vim on a fresh mac running snow leopard.

Any help at all would be greatly appreciated.
Thanks,
s.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 11 2010
Added on Dec 12 2009
4 comments
3,934 views