<?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>Andy Gibson &#187; Maven</title>
	<atom:link href="http://www.andygibson.net/blog/tag/maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andygibson.net/blog</link>
	<description>Open Source Projects &#38; Technical Writings</description>
	<lastBuildDate>Thu, 02 Feb 2012 14:33:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JBoss Java EE 6 spec dependency in Maven</title>
		<link>http://www.andygibson.net/blog/quickbyte/jboss-java-ee-6-spec-dependency-in-maven/</link>
		<comments>http://www.andygibson.net/blog/quickbyte/jboss-java-ee-6-spec-dependency-in-maven/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 13:52:47 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[QuickBytes]]></category>
		<category><![CDATA[CDI]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[Knappsack]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Weld]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=1733</guid>
		<description><![CDATA[Adam Bien wrote about the Troubled with the crippled Java EE 6 APIs in Maven and a solution for them. Another solution has presented itself now that JBoss has finalized the Java EE 6 spec pom and added it to their public repositories as of early January 2011. You can include the spec in your [...]]]></description>
			<content:encoded><![CDATA[<p>Adam Bien wrote about the <a href="http://www.adam-bien.com/roller/abien/entry/trouble_with_crippled_java_ee">Troubled with the crippled Java EE 6 APIs in Maven</a> and a solution for them. Another solution has presented itself now that JBoss has finalized the Java EE 6 spec pom and added it to their public repositories as of early January 2011.</p>
<p>You can include the spec in your own project by adding the following to your <code>pom.xml</code> :</p>
<pre class="brush: xml;">
&lt;dependency&gt;
	&lt;groupId&gt;org.jboss.spec&lt;/groupId&gt;
	&lt;artifactId&gt;jboss-javaee-6.0&lt;/artifactId&gt;
	&lt;version&gt;1.0.0.Final&lt;/version&gt;
	&lt;type&gt;pom&lt;/type&gt;
&lt;/dependency&gt;
</pre>
<p>You may also need to add the JBoss repository to your <code>pom.xml</code> which is defined as :</p>
<pre class="brush: xml;">
&lt;repositories&gt;
	&lt;repository&gt;
		&lt;id&gt;repository.jboss.org&lt;/id&gt;
		&lt;name&gt;JBoss Repository&lt;/name&gt;
		&lt;url&gt;http://repository.jboss.org/nexus/content/groups/public-jboss/&lt;/url&gt;
	&lt;/repository&gt;
&lt;/repositories&gt;
</pre>
<p>I&#8217;ll be adding this pom to the Knappsack archetypes to resolve some of the issues people have been facing with the broken spec dependency.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/quickbyte/jboss-java-ee-6-spec-dependency-in-maven/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Releasing Maven Projects with Git(Hub) in Windows</title>
		<link>http://www.andygibson.net/blog/tutorial/releasing-maven-projects-with-github-in-windows/</link>
		<comments>http://www.andygibson.net/blog/tutorial/releasing-maven-projects-with-github-in-windows/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 12:38:12 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Journeyman]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=1563</guid>
		<description><![CDATA[In the process of moving some new and existing projects to GitHub and releasing them using Maven under Windows, I discovered a number of issues that can be tricky to get around. This post is for anyone else with the same problems, and for my own future reference. First off, most of these issues are [...]]]></description>
			<content:encoded><![CDATA[<p>In the process of moving some new and existing projects to GitHub and releasing them using Maven under Windows, I discovered a number of issues that can be tricky to get around. This post is for anyone else with the same problems, and for my own future reference. </p>
<p>First off, most of these issues are Windows related and while I would love to move to Linux and be rid of these problems, its impractical at the moment. Also, if you are a non-Windows user you can still get an idea of what is needed to deploy GitHub projects with Maven.</p>
<p>To avoid a disappointing end to the post, the one problem I couldn&#8217;t resolve was releasing multi-module projects with maven. I am still getting the <a href="http://jira.codehaus.org/browse/SCM-547?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel">StringIndexOutOfBounds error with msysgit</a>. These instructions are still good for single module deployments though. If anyone has a solution to the string index issue, feel free to post in the comments or <a href="http://www.andygibson.net/blog/contact-me/">drop me a line</a>.</p>
<p>My go to page for remembering how to do release a project with Maven is the <a href="https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide">Sonatype instructions</a> which covers setting up a Sonatype account and tells you what you need to put in your <code>pom.xml</code> file for it to be released automatically.</p>
<p>If you have done maven releases before with subversion, you will know how easy it is. Once the SCM information is in your pom file, Maven will download the source, tag it to the version you select, commit the tag, build it, and deploy it which is really quite nice as well as updating your development code to the new snapshot version.<br />
If you haven&#8217;t done a Maven release before, you will need to set up a PGP key on your machine and post it on a key server (see the Sonatype instructions for more info and links that help).</p>
<p>So at this point, lets assume you have a project ready for release in GitHub (or any other Git repository I guess). You have a PGP key set up on your local machine and added to a public key server. Windows users should also have mSysGit set up, which you probably have if you are developing with Git. Your project should also have the release and deployment information set up as defined in the Sonatype document.</p>
<p>I&#8217;ve seen a  number of different ways of putting the SCM information in the pom file. Here&#8217;s what I used that worked for me. Obviously you&#8217;ll need to change the account name.</p>
<pre class="brush: xml;">
&lt;scm&gt;
   &lt;connection&gt;scm:git:git://github.com/andygibson/${project.artifactId}.git&lt;/connection&gt;
   &lt;url&gt;http://github.com/andygibson/${project.artifactId}&lt;/url&gt;   &lt;developerConnection&gt;scm:git:git@github.com:andygibson/${project.artifactId}.git&lt;/developerConnection&gt;
 &lt;/scm&gt;
</pre>
<p>Interestingly enough, when I was looking to see what other people were using, there are plenty of projects that still have subversion repositories in their scm information. I guess they probably haven&#8217;t changed it over yet because they haven&#8217;t done a release.</p>
<h1>Roadblocks</h1>
<p>There are two main problems that you will hit when releasing with Maven under Windows. The first is that when Maven tries to push the changes back to the Git repository it hangs waiting for the pass phrase for your GitHub SSH key. However, since it never displays a prompt for it, you are stuck waiting for it.</p>
<p>The second problem is exposing your pgp keys to your Git Bash shell. The shell expects the keys to be in a particular folder which doesn&#8217;t exist by default (<code>/c/.gnugp</code>). </p>
<h1>Setting up SSH-Agent</h1>
<p>Start up the Git Bash session (or as OSX and Linux users call it, a shell) and go to your project directory.<br />
Windows users, you need to start up an SSH agent to provide your passkey when needed by the release process.</p>
<p>To do this, in your Git Shell type  :</p>
<pre class="brush: plain;">
eval `ssh-agent`  //pay attention to the back tick quotes here
</pre>
<p>which should return a piece of text like <code>Agent pid xyz</code>. This command starts the agent and sets up a couple of environment variables relating to the SSH agent. If you type <code>env | grep SSH</code> you will see the environment variables :</p>
<pre class="brush: plain;">
$ env | grep SSH
SSH_AGENT_PID=1234
SSH_AUTH_SOCK=/tmp/ssh-abcdef1234/agent.5678
</pre>
<p>Windows users will need to manually create the directory <code>c:/tmp/ssh-abcdef1234/agent.5678</code> otherwise you get and error saying <code>could not open a connection to your authentication agent</code>.<br />
Create the new directory and then add your key to the agent using the following syntax which assumes your Github RSA key is in the <code>c:\.ssh\</code> directory. If it isn&#8217;t then just substitute the directory for your key.</p>
<pre class="brush: plain;">
$ssh-add &quot;/c/.ssh/id_rsa&quot;
enter passphrase :
</pre>
<p> Once you enter the pass phrase, it will be stored for that particular key for the rest of the session. When Git requires the phrase as part of the release it will automatically receive it from the agent.</p>
<p>Note that this set up is only good for the current session. If you open another session and want to do a release in that session, you will need to repeat these steps. I also think it would be a bad idea (or at least pointless) to set up the SSH_AGENT_PID or the SSH_AUTH_SOCK environment variables in any global variables.</p>
<p>So now we have that set up, you should be able to run the <code>mvn release:prepare</code> part of the release. This will grab the source code, update the pom version  and push the changes back to the repository. </p>
<h1>Exposing your PGP keys</h1>
<p>For the next step, (<code>mvn release:perform</code>) we need to do the actual release which involves building the artifacts, signing them and uploading them. I&#8217;m assuming that you already have a project and environment that is correctly configured for release (including the release servers in <code>settings.xml</code>). If not, again, take a look at the Sonatype instructions for info on this. </p>
<p>The problem we&#8217;ll encounter here is that when signing the artifacts, the maven gpg signing plugin can&#8217;t find the keys from the Git Shell. It is looking in the <code>/c/..gnupg</code> directory while the windows version of gpg puts it in the users Application Data folder in their profile. There are two ways to solve this problem, and both involve locating the directory containing the Gnugpg keys. This folder is likely to be <code>My Documents\Application Data\</code> which happens to be a hidden folder for many and varies in location depending on the version of windows. However, in that folder is the <code>gnupg</code> folder that contains your keys. The other piece of the puzzle is the GNUPGHOME environment variable in both Windows and Bash which points to the folder containing the keys.  </p>
<p>You can either move the windows folder to where the Bash shell expects it, and set the Windows environment variable to point to it which means that if you fix it now, it will be fixed for every session. Windows GPG will find the folder through the GNUPGHOME environment variable and Bash will find it because that is the default place it looks for it.</p>
<p>Alternatively, you can leave the folder alone and set the environment variable in the Git shell to point to the key folder where it is. The only problem with this is that the environment variable will need to be set up each time. However, it leaves the rest of your environment alone.</p>
<p>I guess the third option is if you don&#8217;t have a GPG key already set up and are using the Git shell to generate one, you might have to manually create the <code>/c/.gnupg</code> folder manually.</p>
<p>I wanted to move the folder anyway so I went for option one. The choice is up to you, but if you get a message like :</p>
<pre class="brush: plain;">
gpg: no default secret key:secret key not available
pgp: signing failed: secret key not available
</pre>
<p>Its because Gnupg can&#8217;t locate the keys you (should have) already set up.</p>
<p>Once I got that these two problems fixed things went fairly smoothly, well, very smoothly in fact, it just worked. Now, hopefully you won&#8217;t have the same problems I had!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/tutorial/releasing-maven-projects-with-github-in-windows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Try Java EE 6 without the commitment</title>
		<link>http://www.andygibson.net/blog/news/try-java-ee-6-without-the-commitment/</link>
		<comments>http://www.andygibson.net/blog/news/try-java-ee-6-without-the-commitment/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 15:24:22 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Archetypes]]></category>
		<category><![CDATA[CDI]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Knappsack]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=1343</guid>
		<description><![CDATA[The latest version of the Knappsack Maven Archetypes now supports creating Java EE 6 applications for servlet containers. These projects includes configuration for core Java EE 6 technologies such as JSF, CDI, JPA and Bean Validation and can be run from the command line using the embedded Jetty and Tomcat servlet containers. Also with this [...]]]></description>
			<content:encoded><![CDATA[<p>The latest version of the Knappsack Maven Archetypes now supports creating Java EE 6 applications for servlet containers. These projects includes configuration for core Java EE 6 technologies such as JSF, CDI, JPA and Bean Validation and can be run from the command line using the embedded Jetty and Tomcat servlet containers.</p>
<p>Also with this latest release, all the archetypes are available in the Central Maven Repository which means you can dive straight in and create a new Maven project using these archetypes :<br />
<span id="more-1343"></span></p>
<ol>
<li>In the command line, or in a script file, issue the following :
<pre class="brush: plain;">
mvn archetype:generate -DarchetypeGroupId=org.fluttercode.knappsack -DarchetypeArtifactId=jee6-servlet-minimal-archetype -DinteractiveMode=false -DarchetypeVersion=1.0.4 -DgroupId=org.application -DartifactId=servletminimal -Dpackage=org.application
</pre>
<p>This will create the new project based on the java ee 6 minimal servlet archetype.
</li>
<li>Go into the directory using <code>cd servletminimal</code></li>
<li>In the project directory, issue the command <code>mvn clean jetty:run</code></li>
<li>Navigate to <a href="http://localhost:8080/servletminimal/">http://localhost:8080/servletminimal/</a> </li>
<li>Tinker away with it</li>
</ol>
<div class="contentBox alignCenter">
<a href="http://www.andygibson.net/blog/wp-content/uploads/2010/08/screenshot.png" target="_blank"><img src="http://www.andygibson.net/blog/wp-content/uploads/2010/08/screenshot-300x188.png" alt="Servlet Minimal Screenshot" title="Servlet Minimal Screenshot" width="300" height="188" class="alignnone size-medium wp-image-1349" /></a><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/news/try-java-ee-6-without-the-commitment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Knappsack Archetypes Part 2</title>
		<link>http://www.andygibson.net/blog/article/knappsack-archetypes-part-2/</link>
		<comments>http://www.andygibson.net/blog/article/knappsack-archetypes-part-2/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 15:03:07 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Apprentice]]></category>
		<category><![CDATA[Archetypes]]></category>
		<category><![CDATA[CDI]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Knappsack]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=1097</guid>
		<description><![CDATA[In part 1, we looked at the basic structure and configuration of the project that is common in all the archetypes. This time we&#8217;ll look at the minimal archetype that contains some more functionality and a number of different classes used to implement that functionality. The Java EE 6 Minimal Archetype While there is still [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.andygibson.net/blog/article/knappsack-archetypes-part-1/">part 1</a>, we looked at the basic structure and configuration of the project that is common in all the archetypes. This time we&#8217;ll look at the minimal archetype that contains some more functionality and a number of different classes used to implement that functionality. <span id="more-1097"></span></p>
<h1>The Java EE 6 Minimal Archetype</h1>
<p>While there is still only one web page in the project, there are now a few more classes provided. These have been grouped into packages off the main package folder.</p>
<table>
<tr>
<th>Package</th>
<th>Description</th>
</tr>
<tr>
<td><code>bean</code></td>
<td>The <code>bean</code> package contains the <code>EntityManager</code> producer and also a dao object for fetching and persisting <code>Person</code> objects as a stateless EJB (and a local interface).</td>
</tr>
<tr>
<td><code>model</code></td>
<td>Contains the JPA model for ther application which in this case is just one <code>Person</code> class</td>
</tr>
<tr>
<td><code>qualifier</code></td>
<td>Contains the qualifier used to specify injection points for	the <code>EntityManager</code></td>
</tr>
<tr>
<td><code>view</code></td>
<td>Contains the backing beans for the JSF view. These beans provide server side logic for the JSF pages, usually by invoking functions on the service beans in the <code>bean</code> package. The <code>HelloBean</code> accepts a user entered name and returns a message. The <code>PersonBean</code> has a person entity that can be modified by a JSF page and then persisted to the database. There is also a method to return the list of previously saved people from the database.</td>
</tr>
</table>
<div class="sidenote_right">
<h1>Layered code</h1>
<p>We have a fairly clear separation of concerns with the different packages. The EJBs in the <code>bean</code> and <code>qualifier</code> packages don&#8217;t have any dependency on JSF while the beans in the <code>view</code> package are for JSF support only. Such organization means that you could put the contents of the bean and qualifier packages into a separate jar and re-use them with a different view framework. Technically, because they are also POJOs you could use them in a non-EJB environment.</div>
<h2>Producing Entity Managers</h2>
<p>The <code>EntityManager</code> is produced in the <code>DataRepositoryProducer</code> bean by returning the persistence context that was injected into the stateless bean by the container. When an entity manager needs to be injected into an injection point, this method is used to produce one. It is marked as <code>@ConversationScoped</code> so it can participate in CDI conversations. The <code>@DataRepository</code> annotation is a qualifier annotation used to mark what kind of entity manager you are producing and therefore can only be injected into injection points with the same annotation. This is useful if there are multiple databases used to distinguish between different entity managers produced.</p>
<h2>Service Beans</h2>
<p>In the <code>PersonDao</code> we inject the <code>EntityManager</code> that is then used in the other methods to save and fetch objects. In EJB 3.1 the default transaction attribute is <code>Required</code> for EJB methods so we don&#8217;t need to specify any transaction handling on the methods.</p>
<p />
The <code>PersonDao</code> is injected into the <code>view/PersonBean</code> class so as the view needs to fetch or update data, the dao can be used to provide those functions.</p>
<p />
If there was a mechanism that we could use to provide transactions on CDI (non-EJB) beans, then we wouldn&#8217;t really need EJBs, but as it is, we do. Nothing is stopping us from later changing the EJBs to CDI Managed beans with sufficient transaction support.</p>
<p />
<h2>JPA Model</h2>
<p>The only model class we use is the <code>Person</code> class that has properties for first name, last name and an integer Id value. On the name fields, we have specified a number of validators as well as the column size using annotations. These validators check that the field is not empty, or null and does not have a length greater than 25 characters.</p>
<p>Now we&#8217;ve covered the server side code, let&#8217;s take a look at the JSF page that uses these beans in <code>home.xhtml</code>. </p>
<h2>JSF Content</h2>
<p>The single page in this archetype is split into three different sections that test different parts of the environment.</p>
<p>The first part is producing the hello message from the <code>helloBean</code> class. The class is annotated with <code>@Named("helloBean")</code> which lets us reference this bean from the JSF page. The method <code>getHelloMessage()</code> returns a fixed string which is displayed in the page by using the EL expression <code>#{helloBean.helloMessage}</code>. This tells JSF to	get the <code>helloMessage</code> property from the bean called <code>helloBean</code>. The bean name is resolved using an EL expression resolver that looks up	the bean name in the beans registered with CDI using the <code>@Named</code> annotation.</p>
<p />
If you are using JBoss Developer Tools and have enabled CDI for this application (right click on project, click <i>Configure->Add CDI Support</i>, you can go into the JSF page and ctrl+click on the expression (either the bean name or the property name) and the IDE will go to the point in the code that the expression is defined.</p>
<p />
You can interact with the CDI hello bean by entering your name and clicking the submit button which posts your name back to the backing bean and when the page is re-rendered, your name appears in the message below the submit button. Again, the control is bound to the <code>name</code>	property of the <code>helloBean</code> bean which is then used to return the correct message to the user when the page is re-rendered.</p>
<p/>
The final section uses JSF and CDI to edit an instance of a <code>Person</code> object on the CDI backing bean, with JPA persisting the object and Bean Validation providing validation for the JSF page. JPA also returns a list of the people previously saved. The <code>PersonBean</code> class has the <code>@Named</code> annotation which gives it the name <code>personBean</code> and it is marked with a <code>@RequestScoped</code> annotation. The bean has a person instance that is used as the model for the JSF page input boxes. The text boxes are defined for the first and last names and bound to the person entity on the <code>personBean</code> bean. Each input has a <code>h:message</code> JSF tag that reports errors for that input value. This will report errors on the person bean based on the validators we specified on the model.  In the JSF page, the Add button calls the <code>savePerson</code> method on the <code>personBean</code> backing bean which uses the person dao implementation to persist the <code>person</code> entity in the backing bean. JSF automatically includes validation specified on the JPA model and will report errors back to the user for invalid input.</p>
<p/>Underneath the person data entry, there is a list of names that have already been entered. Just enter a new name and click add to see the new name appear.This is fetched from the backing bean using the dao that is injected into it.</p>
<h1>Using the app for yourself</h1>
<p>If you want to create a new application from this archetype, you will probably want to delete the following items.</p>
<pre>
/bean/PersonDao.java
/bean/PersonDaoLocal.java
/model/Person.java
/view/HelloBean.java
/view/PersonBean.java
</pre>
<p>While you may want to re-use the template, or a modified version of it, you won&#8217;t need the content in the <code>home.xhtml</code> file. You can remove the content surrounded by the <code>&lt;ui:define name="content"&gt;</code> tags.  Alternatively, you can just create a new project using the jee6-basic-archetype which has none of this additional code.</p>
<p>In the next section we&#8217;ll start looking at the JPA model and pre-defined data in the sandbox archetype.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/article/knappsack-archetypes-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Knappsack Archetypes are now in the Maven Central Repository</title>
		<link>http://www.andygibson.net/blog/news/knappsack-archetypes-are-now-in-the-maven-central-repository/</link>
		<comments>http://www.andygibson.net/blog/news/knappsack-archetypes-are-now-in-the-maven-central-repository/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 14:48:20 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Archetypes]]></category>
		<category><![CDATA[CDI]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Weld]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=1329</guid>
		<description><![CDATA[I have finally got around to putting the Mavan Java EE 6 Archetypes into the Maven Central Repository. This means you no longer have to manually download and install the Archetypes, they should be available for you to use out of the box. In some cases, depending on how you are creating your projects, you [...]]]></description>
			<content:encoded><![CDATA[<p>I have finally got around to putting the Mavan Java EE 6 Archetypes into the Maven Central Repository. This means you no longer have to manually download and install the Archetypes, they should be available for you to use out of the box. In some cases, depending on how you are creating your projects, you may need to refresh or update your Repository indexes in the IDE before they are visible. </p>
<p>In Eclipse (with m2Eclipse installed), you open the Maven Repositories view, locate the Central Repository in the global repositories, and right click and select update index to make the archetypes available.</p>
<p>To create a new project from the command line, you can copy the following command into a script or batch file and edit it to setup your own group and archetype values.</p>
<pre class="brush: plain;">
mvn archetype:generate -DarchetypeGroupId=org.fluttercode.knappsack -DarchetypeArtifactId=jee6-sandbox-demo-archetype -DinteractiveMode=false -DarchetypeVersion=1.0.4 -DgroupId=org.application -DartifactId=sandboxdemo -Dpackage=org.application
</pre>
<p>The new version includes the archetypes for creating Java EE 6 applications in servlet containers which lets you play around with CDI, JSF, JPA, validation and other JEE 6 technologies using an embedded servlet container from the command line.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/news/knappsack-archetypes-are-now-in-the-maven-central-repository/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Create A New Project With Maven Archetypes</title>
		<link>http://www.andygibson.net/blog/tutorial/getting-started-with-maven-archetypes/</link>
		<comments>http://www.andygibson.net/blog/tutorial/getting-started-with-maven-archetypes/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 16:50:12 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Apprentice]]></category>
		<category><![CDATA[Archetypes]]></category>
		<category><![CDATA[eclips]]></category>
		<category><![CDATA[Knappsack]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Netbeans]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=1076</guid>
		<description><![CDATA[Prerequisites Install Maven In this tutorial, we will create a new project using the Knappsack Archetypes and compile and deploy it. For this example, we will use the jee6-basic-archetype. Before you begin, you will need to have installed Maven, but you no longer need to manually install the Knappsack Archetypes as they are in the [...]]]></description>
			<content:encoded><![CDATA[<div class="prereq">
<ul>
<lh>Prerequisites</lh></p>
<li>Install Maven</li>
</ul>
</div>
<p>In this tutorial, we will create a new project using the Knappsack Archetypes and compile and deploy it. For this example, we will use the <code>jee6-basic-archetype</code>.  Before you begin, you will need to have installed Maven, but you no longer need to manually install the Knappsack Archetypes as they are in the Central Maven Repository now, so you just need to make sure your index is up to date.  These instructions will work for any Maven Archetype you have installed and creating new maven projects in general.<br />
<span id="more-1076"></span><br />
Maven archetypes can be thought of as templates that are installed into the Maven environment and can be used to generate new applications from scratch that are pre-configured for certain environments, whether it is Java EE 6, Wicket or Spring. We can create our project using either the command line or an IDE and both Eclipse and Netbeans both have support for Maven. Netbeans has it out of the box while Eclipse requires m2Eclipse to be installed. This tutorial covers all three methods of creating projects from Maven.</p>
<h1>New project from the Command Line</h1>
<ol>
<li>Start by opening up a command prompt and navigating to the directory your project will reside in</li>
<li>The easy way to create a project on the command line is to just type
<pre class="brush: plain;">
mvn archetype:generate
</pre>
<p>We will use the easier version where we don&#8217;t have to specify long command lines that include the group and archetype Ids and versions.
</li>
<li> You will be greeted with a long list of possible archetypes with a number next to them and a prompt at the bottom to enter the number of the archetype you want to use.
<pre class="brush: plain;">
4: local -&gt; jee6-minimal-archetype (Minimal Java EE application with a single page demo of CDI, JSF, JPA and Validation to ...
5: local -&gt; jee6-basic-archetype (Basic Java EE application with just configuration for CDI, JSF, JPA and a sample empty page.)
6: local -&gt; jee6-sandbox-archetype (Sandbox project for Java EE 6 with CDI, JSF, JPA and a sample model and test data to play ....
7: local -&gt; jee6-sandbox-demo-archetype (Complete demo example using CDI, JSF, JPA and validation showcasing a number of ...
8: remote -&gt; docbkx-quickstart-archetype (null)
9: remote -&gt; j2me-simple (Maven 2 Archetype for midlet application using j2me-maven-plugin)
10: remote -&gt; vaadin-archetype-clean (This archetype generates a simple Vaadin application as a Maven project...
...
...
...
...
Choose a number: 65:
</pre>
<p>Hint : Your locally installed ones should be near the start of the list. The default number (in this case 65) is the quickstart archetype to produce and empty maven project.
</li>
<li>Enter the number of the Knappsack archetype you want to use and press enter.</li>
<li>You will then be asked to enter a number of different properties for the project :
<pre class="brush: plain;">
Define value for property 'groupId': : com.yourcompany
Define value for property 'artifactId': : yourprojectname
Define value for property 'version': 1.0-SNAPSHOT:
Define value for property 'package': com.yourcompany:
Confirm properties configuration:
groupId: com.yourcompany
artifactId: yourprojectname
version: 1.0-SNAPSHOT
package: com.yourcompany
Y:
</pre>
<p>Here we assumed the version is the default SNAPSHOT version and that the default package is the same as the groupId value.
</li>
<li>Once complete, if you look in the directory you will see a new directory called <code>yourprojectname</code>. Move into this directory and if you have <code>JBOSS_HOME</code> set up you can deploy the project straight away.
<pre class="brush: plain;">
mvn clean package jboss:hard-deploy
</pre>
<p>Start up JBoss if it isn&#8217;t already and go to <a href="http://localhost:8080/yourprojectname/home.jsf">http://localhost:8080/yourprojectname/home.jsf</a>.
</li>
<li>You can now import this project into an IDE such as Eclipse or Netbeans as these IDEs recognize Maven projects</li>
</ol>
<p>Alternatively, you can use the command line to enter one long command, or as I do, put it in a script or batch file that I can edit in a text editor and run it from there. Here&#8217;s an example to get you started which you can copy and paste:</p>
<pre class="brush: plain;">
mvn archetype:generate -DarchetypeGroupId=org.fluttercode.knappsack -DarchetypeArtifactId=jee6-sandbox-demo-archetype -DinteractiveMode=false -DarchetypeVersion=1.0.4 -DgroupId=org.application -DartifactId=sandboxdemo -Dpackage=org.application
</pre>
<h1>Creating a project in an IDE</h1>
<p>Creating a Maven project in an IDE is much easier, although sometimes not by much. Typically, you choose to create a new project in the IDE and select maven as the type of project you want to create. </p>
<h2>Netbeans</h2>
<ol>
<li>Select <em>File->New Project</em> and in the first list, select <em>Maven</em> and on the right hand side, select <em>Maven Project</em> (<b>not</b> <em>Maven Web Application</em>). Click Next.</li>
<li>Here we will pick our archetype to create our application from. In the list, expand the <em>Archetypes from Local Repository</em> item in the list. If you don&#8217;t see the archetypes there, you might need to refresh the index in the IDE. Close the new project window to do this.
<ol>
<li>Select <em>Window->Other->Maven Repository Browser</em> to open the repository browser. </li>
<li>In the repository browser window, right click on the repository and select <em>Update Index</em>.</li>
</ol>
<p>Now you should be able to start the new project from scratch and see the missing archetypes.</p>
<div class="contentBox alignCenter">
<a href="http://www.andygibson.net/blog/wp-content/uploads/2010/07/netbeans_select_archetype.png" target="_blank"><img src="http://www.andygibson.net/blog/wp-content/uploads/2010/07/netbeans_select_archetype-300x182.png" alt="Netbeans Select Archetype Screenshot" title="Netbeans Select Archetype" width="300" height="182" /></a>
</div>
<p>Once you have selected the archetype, click finish to setup the project properties.
</li>
<li>The project properties are the group and archetype Id for the new project as well as the optional default package name.
<div class="contentBox alignCenter">
<a href="http://www.andygibson.net/blog/wp-content/uploads/2010/07/netbeans_project_properties.png"><img src="http://www.andygibson.net/blog/wp-content/uploads/2010/07/netbeans_project_properties-300x156.png" alt="netbeans project properties screenshot" title="netbeans project properties screenshots" width="300" height="156" /></a>
</div>
<p>You will also configure the project location here and click <em>Finish</em> when done.
</li>
<li>Once complete, Netbeans will create your project and open it up.  To run it, click <em>Run->Run Main Project</em> and it will prompt you for a Java EE 6 server to use. Select one and click ok. Remember that you need to change the datasource name in <code>persistence.xml</code> so it is not looking for the JBoss default datasource name. </li>
</ol>
<h2>Eclipse</h2>
<p>First make sure you have m2Eclipse installed and are running Eclipse under a JDK instead of a JRE. For more details see this  <a href="http://www.andygibson.net/tutorial/installing-and-configuring-eclipse/">Installing and configuring Eclipse tutorial</a>.</p>
<ol>
<li>In Eclipse, click on <em>File->New->Other..</em> to bring up the dialog for new projects and start typing &#8220;maven&#8221; in the search box</p>
<div class="contentBox alignCenter">
<a href="http://www.andygibson.net/blog/wp-content/uploads/2010/07/eclipse_new_maven_project.png"><img src="http://www.andygibson.net/blog/wp-content/uploads/2010/07/eclipse_new_maven_project-300x186.png" alt="Eclipse New Maven Project Screenshot" title="Eclipse New Maven Project Screenshot" width="300" height="186" /></a>
</div>
<p>Select the maven project item from the list and click <em>Next</em>.
</li>
<li> This page lets you determine where the project will reside. Leave the defaults, but make sure the &#8220;Create simple project&#8221; option is <b>un</b>checked and click <em>Next</em>.</li>
<li>Here we will pick our archetype which in this case is our Knappsack jee6 minimal archetype. Start typing &#8220;knappsack&#8221; in the list and you will see the list of available Knappsack archetypes. Again, it is possible that the IDE&#8217;s index of the local repository is not up to date and needs a refresh. You will need to cancel the project creation window to do this.
<ol>
<li>Select <em>Window->Show View->Other</em> and in the view selection , start typing &#8220;Maven&#8221; until you see the window &#8220;Maven Repositories&#8221;. Select this to open up the view.</li>
<li>In the Maven Repositories view, expand the <em>Local Repositories</em> item and right click click on the <em>Local Repository (pathname)</em> item and select <em>Rebuild Index</em>. Confirm that you want to rebuild the index and wait a few moments.</li>
<li>Restart the project creation and this time you should see the archetypes you are looking for.</li>
</ol>
<div class="contentBox alignCenter">
<a href="http://www.andygibson.net/blog/wp-content/uploads/2010/07/eclipse_select_knappsack.png"><img src="http://www.andygibson.net/blog/wp-content/uploads/2010/07/eclipse_select_knappsack-300x268.png" alt="Eclipse Select Archetype" title="Eclipse Select Archetype" width="300" height="268" /></a>
</div>
<p>Select the archetype you want to create and click <em>Next</em>.
</li>
<li>Now we need to enter the project configuration information, what our project is called, give it a group id, version and default package.
<div class="contentBox alignCenter">
<a href="http://www.andygibson.net/blog/wp-content/uploads/2010/07/eclipse_project_properties.png"><img src="http://www.andygibson.net/blog/wp-content/uploads/2010/07/eclipse_project_properties-300x268.png" alt="Eclipse new Maven Project Properties" title="Eclipse new Maven Project Properties" width="300" height="268" /></a>
</div>
<p>Once the above information is entered you can click <em>Finish</em> and Eclipse will work away at creating your project
</li>
<li>To run the project, the easiest way is to install a server in Eclipse (see <a href="http://www.fluttercode.com/tutorial/installing-servers-into-eclipse/">Tutorial on adding servers in Eclipse</a>) and add the new project to the server. Start the server and navigate to your main page to see it in action.
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/tutorial/getting-started-with-maven-archetypes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing the Knappsack Archetypes</title>
		<link>http://www.andygibson.net/blog/tutorial/installing-the-knappsack-archetypes/</link>
		<comments>http://www.andygibson.net/blog/tutorial/installing-the-knappsack-archetypes/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 16:43:42 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Archetypes]]></category>
		<category><![CDATA[Knappsack]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=1253</guid>
		<description><![CDATA[This is a brief guide to downloading and installing the Knappsack Maven Archetypes for Java EE 6. Updated &#8211; 12th August 2010 The archetypes are now in the Central Maven Repository so there is no need to manually install them. Download the Knappsack Maven Archetypes from here Unzip the downloaded file into a temporary directory [...]]]></description>
			<content:encoded><![CDATA[<p>This is a brief guide to downloading and installing the Knappsack Maven Archetypes for Java EE 6.<span id="more-1253"></span></p>
<h1>Updated &#8211; 12th August 2010</h1>
<p> The archetypes are now in the Central Maven Repository so there is no need to manually install them. </p>
<ol>
<li>Download the Knappsack Maven Archetypes from <a href="https://github.com/andygibson/knappsack/">here</a> </li>
<li>Unzip the downloaded file into a temporary directory</li>
<li>Open a command prompt and navigate to the directory you unzipped the archetypes to.</li>
<li>In the directory, type the command :
<pre class="brush: plain;">
mvn clean install
</pre>
<p>The archetypes will then be installed and ready for creating new projects.
</li>
<p>To learn more about the archetypes read <a href="http://www.andygibson.net/blog/articles/knappsack-archetypes-part-1/ ">this guide</a>. To see all Knappsack related content, click <a href="http://www.andygibson.net/blog/tag/knappsack/">here</a>.
</ol>
<p>Once you have installed the Knappsack Maven Archetypes you can delete the original source since they have been compiled and installed into your Maven repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/tutorial/installing-the-knappsack-archetypes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing libraries into Maven from source</title>
		<link>http://www.andygibson.net/blog/tutorial/installing-libraries-into-maven-from-source/</link>
		<comments>http://www.andygibson.net/blog/tutorial/installing-libraries-into-maven-from-source/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 14:18:39 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=1119</guid>
		<description><![CDATA[This article describes how to install artifacts into Maven from the source code. To start with you should have installed Maven and downloaded the source code you want to install. This same mechanism can be used for library jar files to archetypes that you want to install. Open a command prompt and navigate to the [...]]]></description>
			<content:encoded><![CDATA[<p>This article describes how to install artifacts into Maven from the source code. To start with you should have installed Maven and downloaded the source code you want to install.  This same mechanism can be used for library jar files to archetypes that you want to install.<span id="more-1119"></span></p>
<ol>
<li>Open a command prompt and navigate to the directory where the Maven source code is. This is usually indicated by the presence of a <code>pom.xml</code> file in that directory.
<pre class="brush: plain;">

&gt; cd dev\projects\myproject
</pre>
</li>
<li>Once in the maven project folder, there are a number of different commands you can use to install the project depending on what you need. The simplest form will compile, test, and install the artifacts into Maven.
<pre class="brush: plain;">

&gt;mvn install
</pre>
</li>
</ol>
<p>In some cases, you want to install the source and java doc files as well as the main jar file. This can be done by adding it onto the command line.</p>
<pre class="brush: plain;">

&gt;mvn javadoc:jar source:jar install
</pre>
<p>There may be times you want to make sure your build is completely clean before you start.  You can do this by adding the <code>clean</code> target onto the command. This deletes any current compiled sources so they will be regenerated from scratch. </p>
<pre class="brush: plain;">

&gt;mvn clean javadoc:jar source:jar install
</pre>
<p>While we added it at the start of the command, you don&#8217;t need to, you can put it at the end and it will still be executed first.</p>
<h2>Skipping Tests</h2>
<p>If you need to skip tests, you can do so by setting a command line parameter on the command line depending on how you want to skip the tests. While skipping tests is not advised, there are many cases where you might need to do so.</p>
<pre class="brush: plain;">
-Dmaven.test.skip=true
</pre>
<p>This will skip the compilation and execution of the tests.</p>
<pre class="brush: plain;">
-DskipTests=true
</pre>
<p>This will compile the tests, but skip the execution of them.</p>
<p>See <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/skipping-test.html"> here</a> for more information on controlling test skipping in the <code>pom.xml</code> file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/tutorial/installing-libraries-into-maven-from-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install DataValve into Maven</title>
		<link>http://www.andygibson.net/blog/tutorial/install-datavalve-into-maven/</link>
		<comments>http://www.andygibson.net/blog/tutorial/install-datavalve-into-maven/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 14:16:56 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[DataValve]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=1122</guid>
		<description><![CDATA[This tutorial will show you how to install DataValve into your local Maven repository. You should already have Maven installed locally on your machine into which we will be installing the DataValve libraries. Prerequisites Install Maven First, download the DataValve framework and place it into a temporary folder of your choice. Open a command prompt [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will show you how to install DataValve into your local Maven repository. You should already have Maven installed locally on your machine into which we will be installing the DataValve libraries.<br />
<span id="more-1122"></span></p>
<div class="prereq">
<ul><lh>Prerequisites</lh></p>
<li>Install Maven</li>
</ul>
</div>
<ol>
<li>First, <a href="https://github.com/andygibson/datavalve">download</a> the DataValve framework and place it into a temporary folder of your choice.</li>
<li>Open a command prompt and change directory to the <code>&lt;install-dir&gt;\modules\</code> folder</li>
<li>in the modules folder, type the command :
<pre class="brush: plain;">
mvn clean javadoc:jar source:jar install
</pre>
</li>
<li>This will compile the code, source and javadocs and install them into the local maven repository for use in your local maven applications.</li>
</ol>
<p>Once installed, to use DataValve in a Maven project you will need to add the necessary DataValvel modules as dependencies :</p>
<pre class="brush: xml;">
		&lt;dependency&gt;
			&lt;groupId&gt;org.fluttercode.datavalve&lt;/groupId&gt;
			&lt;artifactId&gt;datavalve-dataset&lt;/artifactId&gt;
			&lt;version&gt;0.9.0.CR2&lt;/version&gt;
		&lt;/dependency&gt;
</pre>
<p>Typically, adding the <code>datavalve-dataset</code> artifact pulls in the core module also. From there, you just need to add modules that your development environment will be dependent on (Wicket, JSF, Swing etc).</p>
<div class="notes">
<ul>
<lh>See Also :</lh></p>
<li><a href="http://www.andygibson.net/blog/tutorials/installing-libraries-into-maven-from-source">Installing libraries into Maven from source</a></li>
<li><a href="http://www.andygibson.net/blog/projects/datavalve/">DataValve project page</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/tutorial/install-datavalve-into-maven/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>See Java EE 6 in action</title>
		<link>http://www.andygibson.net/blog/news/see-java-ee-6-in-action/</link>
		<comments>http://www.andygibson.net/blog/news/see-java-ee-6-in-action/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 20:32:02 +0000</pubDate>
		<dc:creator>Andy Gibson</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Fluttercode]]></category>
		<category><![CDATA[Knappsack]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.andygibson.net/blog/?p=933</guid>
		<description><![CDATA[I&#8217;ve just released a new project called Knappsack which is a set of Maven archetypes for Java EE 6. In addition to the usual starter projects, these archetypes provide complete example applications so you can see the features of JEE 6 and play around with it without having to butcher existing demo applications. Knappsack Sandbox [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released a new project called <a href="http://www.fluttercode.com/projects/knappsack/">Knappsack</a> which is a set of Maven archetypes for Java EE 6. In addition to the usual starter projects, these archetypes provide complete example applications so you can see the features of JEE 6 and play around with it without having to butcher existing demo applications.<br />
<span id="more-933"></span></p>
<div class="diagram" style="width:360px">
<h1>Knappsack Sandbox Application</h1>
<p><a href="http://www.andygibson.net/blog/wp-content/uploads/2010/07/screenshot.png"><img src="http://www.andygibson.net/blog/wp-content/uploads/2010/07/screenshot-300x248.png" alt="Knappsack Application Screenshot" title="Knappsack Archetype Screenshot" width="300" height="248" border="0"/></a>
</div>
<h1 style="font-size : 120%">JEE, JSF, JPA and CDI demo</h1>
<p>The archetypes are based on the Weld Maven Archetypes and have been extended to contain a project that comes complete with a sandbox data model and pre-populated data, and also a full demo application that makes use of a number of Java EE 6 features. The projects have been tested and works with Glassfish (with a Weld update) and JBoss 6 Milestone 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andygibson.net/blog/news/see-java-ee-6-in-action/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

