<?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>GridPulse &#187; Java</title>
	<atom:link href="http://www.gridpulse.com/category/development/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gridpulse.com</link>
	<description>as stimulating as black coffee and just as hard to sleep after.</description>
	<lastBuildDate>Fri, 14 May 2010 19:19:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to solve BindException: Address already in use: JVM_Bind in JBoss on Windows</title>
		<link>http://www.gridpulse.com/2009/10/28/how-to-solve-bindexception-address-already-in-use-jvm_bind-in-jboss-on-windows/</link>
		<comments>http://www.gridpulse.com/2009/10/28/how-to-solve-bindexception-address-already-in-use-jvm_bind-in-jboss-on-windows/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 13:09:35 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[BindException]]></category>
		<category><![CDATA[JBoss]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/2009/10/28/how-to-solve-bindexception-address-already-in-use-jvm_bind-in-jboss-on-windows/</guid>
		<description><![CDATA[&#160; Sometimes, you&#8217;re just having a wonderful day and suddenly the worst just happens: [ServiceController] Problem starting service jboss:service=Naming java.rmi.server.ExportException: Port already in use: 1198; nested exception is: java.net.BindException: Address already in use: JVM_Bind at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:243) ............ The regular solution is to check if the port is actually used. So fire up a command prompt [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Sometimes, you&#8217;re just having a wonderful day and suddenly the worst just happens:</p>
<pre class="prettyprint">[ServiceController] Problem starting service jboss:service=Naming
    java.rmi.server.ExportException: Port already in use: 1198; nested exception is:
    java.net.BindException: Address already in use: JVM_Bind
    at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:243)
    ............</pre>
<p>The regular solution is to check if the port is actually used. So fire up a command prompt and <strong>netstat –aon</strong>.<strong> </strong></p>
<p>If you find the port, see what process is using it and kill it <img src='http://www.gridpulse.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . </p>
<p>If you don’t see the port you can reserve it by following the information in <strong>KB812873 &#8211; <a title="http://support.microsoft.com/kb/812873" href="http://support.microsoft.com/kb/812873">http://support.microsoft.com/kb/812873</a>.</strong></p>
<p>My <strong>ReservedPorts</strong> entry contains:</p>
<blockquote>
<p>1433-1434<br />
    	<br />1097-1200<br />
    	<br />4543-4545</p>
</blockquote>
<p><strong></strong></p>
<p><strong>That should fix it. The bad thing is that it requires a restart.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2009/10/28/how-to-solve-bindexception-address-already-in-use-jvm_bind-in-jboss-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transactional unit tests that support scopes using JUnit and Spring</title>
		<link>http://www.gridpulse.com/2009/08/21/transactional-unit-tests-that-support-scopes-using-junit-and-spring/</link>
		<comments>http://www.gridpulse.com/2009/08/21/transactional-unit-tests-that-support-scopes-using-junit-and-spring/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 16:45:31 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/?p=225</guid>
		<description><![CDATA[Most of the unit tests that you write don&#8217;t need support for transactions and scopes, but if you ever want to test your web frontend code properly you&#8217;ll hit into this one. Writing transactional unit test with JUnit, Spring and Hibernate is easy, what you want to do is: - Add a transaction management bean [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the unit tests that you write don&#8217;t need support for transactions and scopes, but if you ever want to test  your web frontend code properly you&#8217;ll hit into this one. </p>
<p>Writing transactional unit test with JUnit, Spring and Hibernate is easy, what you want to do is:</p>
<p>- Add a transaction management bean in your test context:<br />
<code class="prettyprint"><br />
    &lt;bean id="transactionManager"<br />
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;<br />
        &lt;property name="sessionFactory" ref="sessionFactory"/&gt;<br />
    &lt;/bean&gt;<br />
</code></p>
<p>- Make your test extend <a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.html">AbstractTransactionalJUnit4SpringContextTests</a><br />
- Annotate you test class with <a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/test/context/transaction/TransactionConfiguration.html">@TransactionConfiguration</a> and <a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/transaction/annotation/Transactional.html">@Transactional</a></p>
<p>If your transaction demarcation is correct( surrounding your dao or service ) you should be done. This is the cleanest way that I found.</p>
<p>Everything until now is fine and dandy. The problem arises when one of the injected beans is bound to a scope. It can be any scope but for this example I&#8217;ll take the simplest scope &#8211; the &#8216;session&#8217; scope.</p>
<p>In a non-transactional situation this should be pretty straight forward, just implement <a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/beans/factory/config/Scope.html">Scope</a> and using a <a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/beans/factory/config/ConfigurableBeanFactory.html">ConfigurableBeanFactory</a> register it. The fact that we are extending <a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.html"AbstractTransactionalJUnit4SpringContextTests</a> and that our context is automatically created really kills the simple path. </p>
<p>You&#8217;ll get a <a href="http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/beans/factory/BeanCreationException.html">org.springframework.beans.factory.BeanCreationException</a> with a nested &#8220;java.lang.IllegalStateException: No Scope registered for scope &#8216;session&#8217;&#8221;.</p>
<p>But do not despair, there is simple solution available and it&#8217;s called <a href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/beans/factory/config/CustomScopeConfigurer.html">CustomScopeConfigurer</a>.</p>
<p>The fastest and cleanest way to use it is:<br />
- Create a simple class that will be used as our scope manager. Let&#8217;s call it <a href="http://code.google.com/p/alexandria-umbrella/source/browse/trunk/code/xandria-tooling/xandria-translator/xandria-translator-core/src/test/java/com/gridpulse/xandria/translator/MockSessionScope.java">MockSessionScope</a>.</p>
<p><img src="http://www.gridpulse.com/wp-content/uploads/2009/08/code.jpg" alt="code" title="code" width="630" height="378" class="aligncenter size-full wp-image-238" /></p>
<p>- In your test context, create a <a href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/beans/factory/config/CustomScopeConfigurer.html">CustomScopeConfigurer</a> that will automatically register your scope on context creation:<br />
<code class="prettyprint"><br />
    &lt;bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"&gt;<br />
        &lt;property name="scopes"&gt;<br />
            &lt;map&gt;<br />
                &lt;entry key="session"&gt;<br />
                    &lt;bean class="com.gridpulse.xandria.translator.MockSessionScope"/&gt;<br />
                &lt;/entry&gt;<br />
            &lt;/map&gt;<br />
        &lt;/property&gt;<br />
    &lt;/bean&gt;<br />
</code></p>
<p><b>Run your tests and you&#8217;re done!</b></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2009/08/21/transactional-unit-tests-that-support-scopes-using-junit-and-spring/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>On refactoring and code reuse</title>
		<link>http://www.gridpulse.com/2009/06/22/on-refactoring-and-code-reuse/</link>
		<comments>http://www.gridpulse.com/2009/06/22/on-refactoring-and-code-reuse/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 18:30:47 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/?p=205</guid>
		<description><![CDATA[Strolling through Google Reader, diagonally reading blog posts from the almost 1 hundred blogs that I tend to follow(1000+ unread ) a phrase jump started my brain. Not ever line of code can be reused. A lot of web development is about crafting a very specific solution. Localization, error handling, and coding conventions introduce challenges. [...]]]></description>
			<content:encoded><![CDATA[<p>Strolling through Google Reader, diagonally reading blog posts from the almost 1 hundred blogs that I tend to follow(1000+ unread <img src='http://www.gridpulse.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ) a phrase jump started my brain.</p>
<blockquote><p>
Not ever line of code can be reused. A lot of web development is about crafting a very specific solution. Localization, error handling, and coding conventions introduce challenges.
</p></blockquote>
<p>This is part of a post from one of the Mozilla blogs that I&#8217;m following, namely the blog of <a href="http://ozten.com/psto/">Austin King</a>.</p>
<p>Now, this is as straight forward and clear as it is correct, <b>not ever line of code can be reused</b>. Putting it out of its initial context (web development that is) and bringing it into to context of enterprise applications it becomes pure evil, used as an excuse to re-invent a perfectly good wheel.</p>
<div style="border: 1px solid rgb(204, 204, 204); margin: 7px; padding: 5px; float: right;">
<img src="http://www.gridpulse.com/wp-content/uploads/2009/06/puzzle.gif" alt="Puzzle" title="Puzzle" class="aligncenter size-full wp-image-168" width="499" height="271"><br />
<span style="font-size: 8px;">Photo by <a href="http://www.flickr.com/photos/tcp909/132665279/">tcp909</a></span>
</div>
<p>Some advice:</p>
<ul>
<li> Reuse as much as you can, extracting recurring pieces of code as methods</li>
<li> If common code spawns between projects, always extract it in a common library</li>
<li> Run a copy-paste detector such as <a href="http://pmd.sourceforge.net/cpd.html">CPD</a>. Extract the code to methods.</li>
<li> Try to keep your methods under a fixed number of lines, let&#8217;s say 20. Doing this will force you to extract consistent pieces of code in separate methods, making them more re-usable</li>
<li>Try to maintain low cyclomatic complexity. Use a metrics package such as <a href="http://pmd.sourceforge.net/">PMD</a> or <a href="http://www.panopticode.org/">Panopticode</a>. Refactor complex methods to smaller, less complex chunks of reusable code.</li>
<li>If you have the feeling that it&#8217;s the second time you&#8217;ve written a piece of code, search for the first one, because it&#8217;s usually true.</li>
</ul>
<p>Now go and read a good book about this kind of stuff. I recommend <a href="http://oreilly.com/catalog/9780596519780/">The Productive Programmer</a> by <em>Neal Ford</em>. It&#8217;s an excellent book for beginners but don&#8217;t fear &#8211; it&#8217;s superb even if you&#8217;re an experienced developer, I caught some  nice Groovy tips that made the reading worth while, maybe you&#8217;ll find something interesting too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2009/06/22/on-refactoring-and-code-reuse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some tips on porting Spring web applications to OC4J</title>
		<link>http://www.gridpulse.com/2008/06/17/some-tips-on-porting-spring-web-applications-to-oc4j/</link>
		<comments>http://www.gridpulse.com/2008/06/17/some-tips-on-porting-spring-web-applications-to-oc4j/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 19:51:20 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/2008/06/17/some-tips-on-porting-spring-web-applications-to-oc4j/</guid>
		<description><![CDATA[As OC4J has some drawbacks, here are some tips on porting Spring Framework 2+ web applications. 1. Forget about XML Schema, use DTD&#8217;s As I was about to touch the first base, after throwing my exploded WAR in j2ee applications, OC4J started complaining about XML issues. This is what I mean: javax.xml.parsers.ParserConfigurationException: Unable to validate [...]]]></description>
			<content:encoded><![CDATA[<p>As OC4J has some drawbacks, here are some tips on porting Spring Framework 2+ web applications.</p>
<h4>1. Forget about XML Schema, use DTD&#8217;s </h4>
<p>As I was about to touch the first base, after throwing my exploded WAR in j2ee applications, OC4J started complaining about XML issues. This is what I mean:</p>
<p><code class="prettyprint"><br />
javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [oracle.xml.jaxp.JXDocumentBuilderFactory@1571dff] does not support XML Schema. Are you running on Java 1.4 or below with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.<br />
</code></p>
<p>Yea, &#8230;nasty. As you don&#8217;t want to place Xerces and Xalan in your JRE/JDK lib, all you must do is strip the XML Schema related information and use Spring DTD&#8217;s.</p>
<h4>2. Use ContextLoaderServlet, bootstrap listeners are for smart containers!</h4>
<div style="border: 1px solid rgb(204, 204, 204); margin: 7px; padding: 5px; float: right;">
<img src='http://www.gridpulse.com/wp-content/uploads/2008/06/oracle_9i_internet_bevel_logo.gif' alt='Oracle IAS Logo' />
</div>
<p>Don&#8217;t use <em>ContextLoaderListener</em>. It won&#8217;t work, as OC4J is Servlet 2.3 compliant and does not enforce loading of Listeners before load-on-startup Servlets. So, to escape the bean not found hell, use <em>ContextLoaderServlet</em>.</p>
<p><code class="prettyprint"><br />
    &lt;servlet&gt;<br />
        &lt;servlet-name&gt;context&lt;/servlet-name&gt;<br />
            &lt;servlet-class&gt;<br />
                org.springframework.web.context.ContextLoaderServlet<br />
            &lt;/servlet-class&gt;<br />
        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;<br />
    &lt;/servlet&gt;<br />
</code></p>
<p>Read more about it in the  <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/web/context/ContextLoaderServlet.html"> Spring Framework ContextLoaderServlet javadoc</a>.</p>
<h4>3. Specify UTF-8 encoding</h4>
<p>No encoding filters needed, as oposed to the Tomcat crowd. All you need to do is edit <em>global-web-application.xml</em> and make sure that you specify <em>default-charset</em>. Read more about it in the<a href="http://download.oracle.com/docs/cd/B32110_01/web.1013/b28959/xmlfiles.htm#CJAHFGDH"> web module configuration files documentation at Oracle</a>.</p>
<p>Example:<br />
<code class="prettyprint"><br />
&lt;orion-web-app<br />
        jsp-cache-directory="./persistence"<br />
        servlet-webdir="/servlet"<br />
        development="false" jsp-timeout="0"<br />
        default-charset="UTF-8" &gt;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2008/06/17/some-tips-on-porting-spring-web-applications-to-oc4j/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The importance of reliable, reproducible and independent build process</title>
		<link>http://www.gridpulse.com/2008/02/28/the-importance-of-reliable-reproducible-and-independent-build-process/</link>
		<comments>http://www.gridpulse.com/2008/02/28/the-importance-of-reliable-reproducible-and-independent-build-process/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 08:59:23 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/2008/02/28/the-importance-of-reliable-reproducible-and-independent-build-process/</guid>
		<description><![CDATA[It&#8217;s a known fact: I like maven. It improves some aspects of the development process but it also has a lot of drawbacks. One of these drawbacks comes directly from maven&#8217;s online distributed repository architecture and can make your build process unbearable and worst of all non-reproducible. The usage of maven assumes the presence of [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a known fact: I like <a href="http://maven.apache.org/">maven</a>.<br />
It improves some aspects of the development process but it also has a lot of drawbacks.<br />
One of these drawbacks comes directly from maven&#8217;s online distributed repository architecture and can make your build process unbearable and worst of all non-reproducible.</p>
<p>The usage of maven assumes the presence of all required repositories and most of all the presence of a reliable Internet connection.<br />
What happens when you need artifacts that are temporarily unreachable or you are bound behind an unreliable connection? In the worst case you get build failures but more frequently you get build times that are measured by the tens of minutes.<br />
This would be ok if it happened once a week but it&#8217;s not ok when it happens daily to you and a dozen other team members working on the same project.</p>
<p>The solution we used in the past to fix this problem was a maven repository proxy called Proximity.<br />
Proximity introduces other small problems and latencies and has proven a little unstable, requiring weekly restarts. Plus it included some settings.xml modifications in our previously hands-off newbie development setup. If you want to read a little more about Proximity you can take a look at <a href="http://proximity.abstracthorizon.org/px1/">the project website</a>.</p>
<p>Proximity 1 has been deprecated and until the new <a href="http://blogs.sonatype.com/jvanzyl/2007/11/21.html">Nexus</a> will be out I decided to look for something different.</p>
<p><strong>Introducing Artifactory</strong><br />
<a href="http://www.jfrog.org/sites/artifactory/1.2/">Artifactory</a> is not (exactly) a caching proxy, like Proximity, it works by simulating and acting as a maven repository. </p>
<p>Every artifact cached is available as part of the local Artifactory repository and when offline, the build process is exactly the same.<br />
It is installed in a copy/unzip and run process and works right out of the box. Some customization is needed only if you use exotic repositories that are not included in the defaults.</p>
<p>Artifactory also returned the development setup to its hands-off svn checkout, mvn eclipse:eclipse or idea:idea nature. It contains a good graphical interface with artifact cache invalidation, which really helps sometimes.</p>
<p>Take a look at <a href="http://www.jfrog.org/sites/artifactory/1.2/demo.html">the live demo</a>, it&#8217;s worth the 5 minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2008/02/28/the-importance-of-reliable-reproducible-and-independent-build-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get java thread stack traces for a Windows service with jstack</title>
		<link>http://www.gridpulse.com/2007/12/06/how-to-get-java-thread-stack-traces-for-a-windows-service-with-jstack/</link>
		<comments>http://www.gridpulse.com/2007/12/06/how-to-get-java-thread-stack-traces-for-a-windows-service-with-jstack/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 13:39:26 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/2007/12/06/how-to-get-java-thread-stack-traces-for-a-windows-service-with-jstack/</guid>
		<description><![CDATA[When running in a console window, pressing CTRL+Break signals the JVM to print out all stack traces of currently running threads. If your application runs as a service (or linux/unix dæmon) you can&#8217;t press CTRL+Break, so you have to signal the JVM yourself to produce the stack trace. You can do that on linux by [...]]]></description>
			<content:encoded><![CDATA[<p>When running in a console window, pressing CTRL+Break signals the JVM to print out all stack traces of currently running threads.</p>
<p>If your application runs as a service (or linux/unix dæmon) you can&#8217;t press CTRL+Break, so you have to signal the JVM yourself to produce the stack trace. You can do that on linux by signaling a QUIT to the process, or by using  <strong><a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstack.html" title="jstack - Stack Trace">jstack</a></strong> and the PID.<br />
Good news, Java SE 6 on Windows comes with <strong>jstack</strong>. Yupee! <img src='http://www.gridpulse.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>So next time you need a thread dump from a java application running as a service just get the pid, fire up a cmd and run <strong>jstack</strong> &lt;pid&gt;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2007/12/06/how-to-get-java-thread-stack-traces-for-a-windows-service-with-jstack/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Generating your model from a schema definition using Maven and JAXB</title>
		<link>http://www.gridpulse.com/2007/10/28/generating-you-model-from-an-xsd-using-maven-and-jaxb/</link>
		<comments>http://www.gridpulse.com/2007/10/28/generating-you-model-from-an-xsd-using-maven-and-jaxb/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 10:21:01 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/2007/10/28/generating-you-model-from-an-xsd-using-maven-and-jaxb/</guid>
		<description><![CDATA[If your project requires quite a large data model and it so happens that you have a xml schema definition on hand, you can easily transform that XSD into Java classes using Maven 2, JAXB and some manual labor. Things you might want to know: * doesn&#8217;t work out of the box on JSE6. It [...]]]></description>
			<content:encoded><![CDATA[<p>If your project requires quite a large data model and it so happens that you have a xml schema definition on hand, you can easily transform that <strong>XSD </strong>into Java classes using <strong>Maven 2</strong>, <strong>JAXB </strong>and some manual labor.</p>
<p>Things you might want to know:<br />
* doesn&#8217;t work out of the box on <strong>JSE6</strong>. It actually needs a lot of work, so avoid using for now;<br />
* you need a maven project<br />
* you actually need a valid XSD <img src='http://www.gridpulse.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The classes are generated by <strong>JAXB</strong> <strong>xjc</strong>. You can do this by hand, but using maven and <a href="https://maven-jaxb2-plugin.dev.java.net/" target="_blank">maven-jaxb2-plugin</a> makes it a breeze.</p>
<p>So, this is what you must do:<br />
* Place your schema definition in your <strong>src/main/resources </strong>directory<br />
* Open you pom.xml and add the following(no worries, you will remove them later):</p>
<p><code class="prettyprint"><br />
&lt;repositories&gt;<br />
    &lt;repository&gt;<br />
        &lt;id&gt;maven2-repository.dev.java.net&lt;/id&gt;<br />
        &lt;name&gt;Java.net Maven 2 Repository&lt;/name&gt;<br />
        &lt;url&gt;http://download.java.net/maven/2&lt;/url&gt;<br />
    &lt;/repository&gt;<br />
    &lt;repository&gt;<br />
        &lt;id&gt;maven-repository.dev.java.net&lt;/id&gt;<br />
        &lt;name&gt;Java.net Maven 1 Repository (legacy)&lt;/name&gt;<br />
        &lt;url&gt;http://download.java.net/maven/1&lt;/url&gt;<br />
        &lt;layout&gt;legacy&lt;/layout&gt;<br />
    &lt;/repository&gt;<br />
&lt;/repositories&gt;<br />
&lt;pluginRepositories&gt;<br />
    &lt;pluginRepository&gt;<br />
        &lt;id&gt;maven2-repository.dev.java.net&lt;/id&gt;<br />
        &lt;name&gt;Java.net Maven 2 Repository&lt;/name&gt;<br />
        &lt;url&gt;http://download.java.net/maven/2&lt;/url&gt;<br />
    &lt;/pluginRepository&gt;<br />
    &lt;pluginRepository&gt;<br />
        &lt;id&gt;maven-repository.dev.java.net&lt;/id&gt;<br />
        &lt;name&gt;Java.net Maven 1 Repository (legacy)&lt;/name&gt;<br />
        &lt;url&gt;http://download.java.net/maven/1&lt;/url&gt;<br />
        &lt;layout&gt;legacy&lt;/layout&gt;<br />
    &lt;/pluginRepository&gt;<br />
&lt;/pluginRepositories&gt;<br />
&lt;dependencies&gt;<br />
    &lt;dependency&gt;<br />
        &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;<br />
        &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;<br />
        &lt;version&gt;2.0&lt;/version&gt;<br />
    &lt;/dependency&gt;<br />
&lt;/dependencies&gt;</code><br />
* In your build section configure the jaxb2 plugin:<br />
<code class="prettyprint"><br />
&lt;plugin&gt;<br />
    &lt;groupid&gt;org.jvnet.jaxb2.maven2&lt;/groupid&gt;<br />
    &lt;artifactid&gt;maven-jaxb2-plugin&lt;/artifactid&gt;<br />
    &lt;executions&gt;<br />
        &lt;execution&gt;<br />
            &lt;goals&gt;<br />
                &lt;goal&gt;generate&lt;/goal&gt;<br />
            &lt;/goals&gt;<br />
        &lt;/execution&gt;<br />
    &lt;/executions&gt;<br />
    &lt;configuration&gt;<br />
     &lt;includeschema&gt;**/*.xsd&lt;/includeschema&gt;<br />
        &lt;generatepackage&gt;com.gridpulse.project.model&lt;/generatepackage&gt;<br />
    &lt;/configuration&gt;<br />
&lt;/plugin&gt;<br />
</code><br />
As you can see, you have 2 configuration settings:<br />
* <em>includeSchema </em>- schema file mask to include<br />
* <em>generatePackage </em>- the package that you would like to hold the classes</p>
<p>After setting this up, just fire up a <strong>mvn install. </strong>This will<strong> </strong>produce the model classes in the <strong>target/generated-sources/xjc/ </strong>directory.<br />
You can now copy them to your <strong>src</strong> directory and clean them up.<br />
Remember to remove the JAXB2 settings from your pom.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2007/10/28/generating-you-model-from-an-xsd-using-maven-and-jaxb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JiBX, Maven JiBX plugin, using collections with flexible settings</title>
		<link>http://www.gridpulse.com/2007/10/17/jibx-maven-jibx-plugin-using-collections-with-flexible-settings/</link>
		<comments>http://www.gridpulse.com/2007/10/17/jibx-maven-jibx-plugin-using-collections-with-flexible-settings/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 14:04:41 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/2007/10/17/jibx-maven-jibx-plugin-using-collections-with-flexible-settings/</guid>
		<description><![CDATA[Before JiBX 1.1.5, names on collections were optional. That changed Now, although the docs say that the name attribute is optional on collections, it&#8217;s actually required in the real world. Some flexible setups, like mine, get really confused if the name attribute is specified, and, because it is required I can&#8217;t even bind it without [...]]]></description>
			<content:encoded><![CDATA[<p>Before JiBX 1.1.5, <em>names</em> on <em>collection</em>s were optional. That changed <img src='http://www.gridpulse.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now, although the docs say that the <em>name </em>attribute is optional on collections, it&#8217;s actually required in the real world.</p>
<p>Some flexible setups, like mine, get really confused if the <em>name</em> attribute is specified, and, because it is required I can&#8217;t even bind it without setting <em>validate</em> to false, and if I set validate to false, the <em>JiBX_MungeAdapter </em>appears in my module root (<em>${basedir}</em>) instead of the required package.</p>
<p>The only solution I found for this problem is to downgrade to JiBX 1.1.3 and maven-jibx-plugin 1.1.3. I know it isn&#8217;t a real solution but what can I say, half a day is too long to loose working on something that can be fixed by a minor-version downgrade.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2007/10/17/jibx-maven-jibx-plugin-using-collections-with-flexible-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to deploy an artifact that uses classifiers and profiles with Maven</title>
		<link>http://www.gridpulse.com/2007/10/12/how-to-deploy-artifact-that-uses-classifiers-and-profiles-with-maven/</link>
		<comments>http://www.gridpulse.com/2007/10/12/how-to-deploy-artifact-that-uses-classifiers-and-profiles-with-maven/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 16:18:36 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/2007/10/12/how-to-deploy-artifact-that-uses-classifiers-and-profiles-with-maven/</guid>
		<description><![CDATA[Sometimes, when one of your modules is used by different applications, but requires slight changes, you want to create different artifacts, that can be direct dependencies of those applications. You can do this by using profiles and classifiers. You can create your pom, the usual way, with profiles&#8230;more here, then apply classifiers to the package [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, when one of your modules is used by different applications, but requires slight changes, you want to create different artifacts, that can be direct dependencies of those applications.</p>
<p>You can do this by using profiles and classifiers.</p>
<p>You can create your pom, the usual way, with profiles&#8230;more <a href="http://maven.apache.org/guides/introduction/introduction-to-profiles.html" title="Maven Profile Reference">here</a>, then apply classifiers to the package plugin inside your profile, like this:<br />
<code class="prettyprint"><br />
&lt;plugin&gt;<br />
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
&lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;<br />
&lt;version&gt;2.0&lt;/version&gt;<br />
&lt;executions&gt;<br />
&lt;execution&gt;<br />
&lt;phase&gt;package&lt;/phase&gt;<br />
&lt;goals&gt;<br />
&lt;goal&gt;war&lt;/goal&gt;<br />
&lt;/goals&gt;<br />
&lt;configuration&gt;<br />
&lt;classifier&gt;standalone&lt;/classifier&gt;<br />
&lt;/configuration&gt;<br />
&lt;/execution&gt;<br />
&lt;/executions&gt;<br />
&lt;/plugin&gt;</code></p>
<p>This will produce an artifact with <em>finalName</em></p>
<p>${artifactId}-${version}-${clasifier}</p>
<p>that will be accessible by specifying the classifier in your dependency.</p>
<p>Just remember to use <em>executions</em> because it will not work otherwise. It will build the artifacts, but will not deploy them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2007/10/12/how-to-deploy-artifact-that-uses-classifiers-and-profiles-with-maven/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Improve your build system using Maven</title>
		<link>http://www.gridpulse.com/2007/10/12/improve-your-build-system-using-maven/</link>
		<comments>http://www.gridpulse.com/2007/10/12/improve-your-build-system-using-maven/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 11:52:05 +0000</pubDate>
		<dc:creator>Bogdan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.gridpulse.com/2007/10/12/improve-your-build-system-using-maven/</guid>
		<description><![CDATA[Really! I&#8217;ve been a Maven user since 2005, but only as a &#8220;user&#8221;, never creating build files, never really understanding the full picture. I used to be a skeptic, but now I am fully converted. For the past 3 days I&#8217;ve been migrating the build process for a 15 module project from ant to Maven [...]]]></description>
			<content:encoded><![CDATA[<p>Really!</p>
<p>I&#8217;ve been a Maven user since 2005, but only as a &#8220;user&#8221;, never creating build  files, never really understanding the full picture.</p>
<p>I used to be a skeptic, but now I am fully converted. For the past 3 days  I&#8217;ve been migrating the build process for a 15 module  project from ant to Maven  2 and I have to admin that once you get past the dependency configuration,  everything else is a breeze.</p>
<p>The build file size, maintaining every functionality, has decreased by two  thirds, and is now more readable.</p>
<p>Everything from  JiBX binding to build versioning is almost out of the box by  using the plugin system. Plus, the Surefire plugin just <em>works</em>, no hassle  there, running all tests with testng, although it&#8217;s slower than the direct  testing I used to do with ant.</p>
<p>Anyway, it&#8217;s worth loosing two or three days, the benefits are huge.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gridpulse.com/2007/10/12/improve-your-build-system-using-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
