<?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/"
	>

<channel>
	<title>The World Of Gavin &#187; rome</title>
	<atom:link href="http://www.gavinwillingham.com/tag/rome/feed" rel="self" type="application/rss+xml" />
	<link>http://www.gavinwillingham.com</link>
	<description>My opinions on things I have opinions on</description>
	<lastBuildDate>Fri, 28 Jan 2011 17:08:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Classloading in Rome</title>
		<link>http://www.gavinwillingham.com/classloading-in-rome.html</link>
		<comments>http://www.gavinwillingham.com/classloading-in-rome.html#comments</comments>
		<pubDate>Wed, 18 Nov 2009 15:58:25 +0000</pubDate>
		<dc:creator>gavin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[classloader]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[rome]]></category>

		<guid isPermaLink="false">http://www.gavinwillingham.com/?p=440</guid>
		<description><![CDATA[As a side-project at work, I&#8217;ve been working on an ant task to generate an atom feed of something. The something&#8217;s not really important. Rather than re-invent the wheel, I did a quick search on google for a Java library to take care of the feed processing for me. Sure enough, Rome seemed to fit [...]]]></description>
			<content:encoded><![CDATA[<p>As a side-project at work, I&#8217;ve been working on an <a title="Apache Ant" href="http://ant.apache.org">ant</a> task to generate an atom feed of something. The something&#8217;s not really important.</p>
<p>Rather than re-invent the wheel, I did a quick search on google for a Java library to take care of the feed processing for me. Sure enough, <a title="Rome" href="http://wiki.java.net/bin/view/Javawsxml/Rome">Rome</a> seemed to fit the bill.</p>
<p>Merrily testing away in my Eclipse workbench, I quickly wrote the code to generate my atom feed. All was good with the world. The planets may or may not have aligned. And then I came to run it through ant.</p>
<p>Unfortunately, that&#8217;s where the problems started&#8230;</p>
<p><span id="more-440"></span></p>
<pre>BUILD FAILED
C:\testAnt.xml:6: java.lang.ExceptionInInitializerError
 at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:115)
 at org.apache.tools.ant.Task.perform(Task.java:348)
...
Caused by: java.lang.ExceptionInInitializerError
 at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
 at com.sun.syndication.io.SyndFeedInput.build(SyndFeedInput.java:110)
...
Caused by: java.lang.NullPointerException
 at java.util.Properties.load(Properties.java:267)
 at com.sun.syndication.io.impl.PropertiesLoader.&lt;init&gt;(PropertiesLoader.java:74)
 at com.sun.syndication.io.impl.PropertiesLoader.getPropertiesLoader(PropertiesLoader.java:46)
 at com.sun.syndication.io.impl.PluginManager.&lt;init&gt;(PluginManager.java:54)
 at com.sun.syndication.io.impl.PluginManager.&lt;init&gt;(PluginManager.java:46)
 at com.sun.syndication.feed.synd.impl.Converters.&lt;init&gt;(Converters.java:40)
 at com.sun.syndication.feed.synd.SyndFeedImpl.&lt;clinit&gt;(SyndFeedImpl.java:59)</pre>
<p>Bugger.</p>
<p>A quick google only turns up 2 useful hits: <a title="Spring forum" href="http://forum.springsource.org/showthread.php?t=74020">here</a> and <a title="MarkMail" href="markmail.org/message/dh2u7cibw7dbh5hy">here</a>. Both links seem to suggest that Rome can run into problems with the way it loads its classes. After much hacking around, I found that a (somewhat hacky) way to solve this was by over-riding the Thread&#8217;s ClassLoader in my main class; e.g.</p>
<pre>public class Test extends Task{

    public void execute(){

        ClassLoader cl = Test.class.getClassLoader();
        Thread.currentThread().setClassLoader(cl);

        // now do Rome stuff
        ...
    }
}</pre>
<p>It&#8217;s not pretty, but it works. For now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gavinwillingham.com/classloading-in-rome.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

