<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" >

<channel>
	<title>seidbereit.de &#187; Java</title>
	<atom:link href="http://seidbereit.de/tags/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://seidbereit.de</link>
	<description>ideas.each { &#124;x&#124;  post x }</description>
	<lastBuildDate>Wed, 11 Nov 2009 20:23:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Wasting time with JAXB, ANT and APT</title>
		<link>http://seidbereit.de/2008/07/03/wasting-time-with-jaxb-ant-and-apt/</link>
		<comments>http://seidbereit.de/2008/07/03/wasting-time-with-jaxb-ant-and-apt/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 16:56:02 +0000</pubDate>
		<dc:creator>Ullrich</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Diploma]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://seidbereit.de/2008/07/03/wasting-time-with-jaxb-ant-and-apt/</guid>
		<description><![CDATA[Hello,
I just wasted 2 days finding a damn problem with the mentioned combination. What i tried to do ist: Using JAXB from within a APT AnnotationProcessor from within ANT.
Now to the problem:
From within my processor i could access the classes in the jaxb jar files (jaxb-api.jar and jaxb-impl.jar) but when i tried to unmarshal some [...]]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>I just wasted 2 days finding a damn problem with the mentioned combination. What i tried to do ist: Using <a href="http://jaxb.dev.java.net/" class="liexternal">JAXB</a> from within a <a href="http://java.sun.com/j2se/1.5.0/docs/guide/apt/index.html" class="liexternal">APT</a> AnnotationProcessor from within <a href="http://ant.apache.org" class="liexternal">ANT</a>.</p>
<p>Now to the problem:</p>
<p>From within my processor i could access the classes in the jaxb jar files (jaxb-api.jar and jaxb-impl.jar) but when i tried to <em>unmarshal</em> some XML file, i got a ClassNotFoundException. See <a href="http://pastie.org/227136" class="liexternal">http://pastie.org/227136</a></p>
<p>I tried thousands of things to fix this. Passing the classpath in multiple ways. Even passing a new bootstrap classpath, but non worked.</p>
<p>After lots of try and error, some conversations on <a href="irc://irc.freenode.net/java" class="liinternal">#java@freenode</a> (<a href="http://pastie.org/227143" class="liexternal">http://pastie.org/227143</a>) and a look at the JAXB sources i found the solution in passing the classloader of the calling class when instantiating the context:</p>
<pre lang="java" xml:lang="java">
String contextPath = ObjectFactory.class.getPackage().getName();
JAXBContext c = JAXBContext.newInstance(contextPath, MyClass.class.getClassLoader());
</pre>
<p>Hope this could help someone and save some time <img src='http://seidbereit.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://seidbereit.de/2008/07/03/wasting-time-with-jaxb-ant-and-apt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

