<?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>Xebia Blog &#187; jboss tools</title>
	<atom:link href="http://blog.xebia.com/tag/jboss-tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com</link>
	<description>Software development done right!</description>
	<lastBuildDate>Wed, 01 Feb 2012 00:30:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Developing RESTful applications on JBoss AS 7</title>
		<link>http://blog.xebia.com/2011/07/12/developing-restful-applications-on-jboss-as-7/</link>
		<comments>http://blog.xebia.com/2011/07/12/developing-restful-applications-on-jboss-as-7/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 07:00:25 +0000</pubDate>
		<dc:creator>Maarten Winkels</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[jboss tools]]></category>
		<category><![CDATA[jee 6]]></category>
		<category><![CDATA[rest]]></category>

	<!-- AutoMeta Start -->
	<category>bookrepository</category>
	<category>applicationpath</category>
	<category>restful</category>
	<category>modules</category>
	<category>modules</category>
	<category>resteasy</category>
	<category>jboss</category>
	<category>admin</category>
	<category>bookrepository</category>
	<category>applicationpath</category>
	<category>restful</category>
	<category>modules</category>
	<category>modules</category>
	<category>resteasy</category>
	<category>jboss</category>
	<category>admin</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=6767</guid>
		<description><![CDATA[JBoss AS 7 CR1 has been released recently. On the previous release it was pretty easy to develop RESTful applications with the build in JAX-RS support based on RESTeasy. In this blog I&#8217;ll look at how well the new version of JBoss keeps up with the rest of the field. Changes: JBoss Modules JBoss AS [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://docs.jboss.org/author/display/AS7/Documentation"><img src="http://blog.xebia.com/wp-content/uploads/2011/07/as7_logo.png" alt="" title="JBoss AS 7" style="float:right; height:100px" /></a><a href="http://www.jboss.org/jbossas/downloads">JBoss AS 7 CR1</a> has been released recently. On the previous release it was pretty easy to develop RESTful applications with the build in JAX-RS support based on RESTeasy. In this blog I&#8217;ll look at how well the new version of JBoss keeps up with the rest of the field.</p>
<p><span id="more-6767"></span></p>
<h3>Changes: JBoss Modules</h3>
<p>JBoss AS 7 is quite a different beast from its predecessors. The most striking difference is the usage of <a href="https://docs.jboss.org/author/display/MODULES/Home">JBoss modules</a>, which is a modular class loading system, comparable to <a href="http://mreinhold.org/blog/jigsaw">Jigsaw</a>, THE modular system for Java that will (one day) (probably) reach the JVM. Till that day however, JBoss modules can be used.</p>
<p>After downloading and unzipping the JBoss AS 7 CR1 release, you&#8217;ll find all the modules in the &#8221;modules&#8221; subdirectory, grouped in a structure that somewhat resembles a maven repository: you&#8217;ll for example find directories for &#8221;org&#8221;, &#8221;javax&#8221; and &#8221;net&#8221;, similar to the directory structure of group-ids and artifact-ids in a Maven2 repository layout. At some level, however, there will be a &#8221;main&#8221; folder and that&#8217;s where the implementation details of the module are kept: a small XML file describing the module and some jar files that constitute the modules content. A very useful side effect of this is that finding out which versions of which jars the AS is using is rather simple: The jar files in the module are usually the maven artifacts and thus contain the version number in their name. See for example the javax.activation module below.<br />
<a href="http://blog.xebia.com/wp-content/uploads/2011/07/JbossModules.png"><img src="http://blog.xebia.com/wp-content/uploads/2011/07/JbossModules-300x114.png" alt="" title="JbossModules" width="300" height="114" class="aligncenter size-medium wp-image-7185" /></a></p>
<p>Another consequence of this change is that the usual JBoss structure with a &#8221;server&#8221; directory with several profiles, like &#8221;default&#8221;, &#8221;web&#8221; and &#8221;minimal&#8221; no longer exists. The main structure now has a &#8221;standalone&#8221; directory for running a simple server, and a &#8221;domain&#8221; directory for running a cluster.</p>
<h3>Installation</h3>
<p>Installation is as always straight forward. A development environment however is not ready for use without good integration between the IDE and the application server on the local system. IDE of choice is Eclipse, because of the nice JBoss Tools plugin suite. Following <a href="https://docs.jboss.org/author/display/AS7/Starting+JBoss+AS+from+Eclipse+with+JBoss+Tools">these instructions</a> is already a large part of the installation.</p>
<p>To make things really easy, we include <a href="http://eclipse.org/m2e/">Maven integration for Eclipse</a> with WTP from Sonatype into the mix. Especially finding the right version of the Maven integration for WTP was difficult. I finally found a copy that worked with the rest of the setup at this <a href="https://repository.sonatype.org/content/sites/forge-sites/m2eclipse-wtp/0.13.0/S/0.13.0.20110623-0455/">update site</a>.</p>
<p>Starting the server can now be done from the Eclipse servers window. Browsing to the default port shows a nice welcome window and going to the admin console shows a simple but useful administrative interface.<br />
<a href="http://blog.xebia.com/wp-content/uploads/2011/07/welcome.png"><img src="http://blog.xebia.com/wp-content/uploads/2011/07/welcome-300x235.png" alt="" title="welcome" width="300" height="235" class="alignleft size-medium wp-image-7108" /></a><a href="http://blog.xebia.com/wp-content/uploads/2011/07/admin.png"><img src="http://blog.xebia.com/wp-content/uploads/2011/07/admin-300x235.png" alt="" title="admin" width="300" height="235" class="alignleft size-medium wp-image-7107" /></a><br />
Two small problems with the setup so far:<br />
1. Eclipse doesn&#8217;t seem to detect the startup of the server. Which is kind of annoying, because Eclipse now wont compile anything since it is waiting for the process to end.<br />
<a href="http://blog.xebia.com/wp-content/uploads/2011/07/NotStarted.png"><img src="http://blog.xebia.com/wp-content/uploads/2011/07/NotStarted-300x251.png" alt="" title="NotStarted" width="300" height="251" class="aligncenter size-medium wp-image-7112" /></a><br />
This can be worked around by setting the Startup Poller to &#8221;Web Port Poller&#8221; in the Server overview screen of the JBoss 7 AS server.<br />
<img src="http://blog.xebia.com/wp-content/uploads/2011/07/StartUpFix.png" alt="" title="StartUpFix" width="572" height="92" class="aligncenter size-full wp-image-7113" /><br />
2. Eclipse is not able to stop JBoss. At least not from the server view.<br />
<a href="http://blog.xebia.com/wp-content/uploads/2011/07/CannotStop.png"><img src="http://blog.xebia.com/wp-content/uploads/2011/07/CannotStop-300x164.png" alt="" title="CannotStop" width="300" height="164" class="aligncenter size-medium wp-image-7111" /></a><br />
JBoss can still be stopped from the Console view, but that means restarting the server always takes at least 4 mouse clicks: (1) go to console (2) stop (3) go to servers (4) restart, which is kind of annoying.</p>
<p>Anyway, living with small annoyances is second nature for everybody in IT industry I suppose, so why would a simple JEE application developer be any different <img src='http://blog.xebia.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Starting up the project</h3>
<p>Now that everything is set up, we can continue to the more interesting part, the project and the Java code. With the help of M2Eclipse we create a maven project with the following pom:</p>
<pre class="brush: xml; highlight: [41,42,43,44,45,46,47]; title: ; notranslate">
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
	xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
	&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
	&lt;groupId&gt;com.xebia.library&lt;/groupId&gt;
	&lt;artifactId&gt;library&lt;/artifactId&gt;
	&lt;version&gt;0.9-SNAPSHOT&lt;/version&gt;
	&lt;packaging&gt;war&lt;/packaging&gt;
	&lt;repositories&gt;
		&lt;repository&gt;
			&lt;id&gt;jboss&lt;/id&gt;
			&lt;url&gt;https://repository.jboss.org/nexus/content/groups/public-jboss/&lt;/url&gt;
		&lt;/repository&gt;
	&lt;/repositories&gt;
	&lt;build&gt;
		&lt;plugins&gt;
			&lt;plugin&gt;
				&lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
				&lt;version&gt;2.4.3&lt;/version&gt;
				&lt;configuration&gt;
					&lt;encoding&gt;UTF-8&lt;/encoding&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;
			&lt;plugin&gt;
				&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
				&lt;version&gt;2.3.2&lt;/version&gt;
				&lt;configuration&gt;
					&lt;source&gt;1.6&lt;/source&gt;
					&lt;target&gt;1.6&lt;/target&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;
			&lt;plugin&gt;
				&lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
				&lt;version&gt;2.1.1&lt;/version&gt;
				&lt;configuration&gt;
					&lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;
		&lt;/plugins&gt;
	&lt;/build&gt;
	&lt;dependencies&gt;
		&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;2.0.0.CR1&lt;/version&gt;
			&lt;type&gt;pom&lt;/type&gt;
			&lt;scope&gt;provided&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
			&lt;artifactId&gt;resteasy-jaxrs&lt;/artifactId&gt;
			&lt;version&gt;2.2.1.GA&lt;/version&gt;
			&lt;scope&gt;provided&lt;/scope&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;
&lt;/project&gt;
</pre>
<p>This pom will configure the maven project and the Eclipse-WTP project correctly for deployment on JBoss. The highlighted lines show the dependency on a pom with the Aggregated Java EE 6.0 APIs that JBoss provides. This pom is supposed to be used to import the right version numbers of all the Java EE APIs into your own pom. Since I am lazy, I&#8217;ll just depend on this pom, so all the APIs are already available in my project without having to specify them separately.</p>
<p>Now we have a well configured Maven Web project in Eclipse. The layout will look like the image below.<br />
<a href="http://blog.xebia.com/wp-content/uploads/2011/07/JavaWebProject.png"><img src="http://blog.xebia.com/wp-content/uploads/2011/07/JavaWebProject-150x150.png" alt="" title="JavaWebProject" width="150" height="150" class="aligncenter size-thumbnail wp-image-7129" /></a></p>
<p>And now for some Java code, how do we configure RESTeasy framework?</p>
<pre class="brush: java; title: com/xebia/library/LibraryApplication.java; notranslate">
package com.xebia.library;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath(&quot;services&quot;)
public class LibraryApplication extends Application {

}
</pre>
<p>That&#8217;s it! From the class RESTeasy will be configured and the RESTful web services will be available at &#8221;/services&#8221; in the context of the project.</p>
<p>Let&#8217;s add a simple web service.</p>
<pre class="brush: java; title: com/xebia/library/BookRepository.java; notranslate">
package com.xebia.library;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.xebia.library.model.Book;

@Path(&quot;books&quot;)
public interface BookRepository {

	@GET
	@Path(&quot;/&quot;)
	@Produces(MediaType.APPLICATION_JSON)
	List&lt;Book&gt; all();
}
</pre>
<p>This interface defines the RESTful web service by means of the JAX-RS annotations. Adding an interface is useful, but not necessary.</p>
<pre class="brush: java; title: com/xebia/library/impl/BookRepositoryBean.java; notranslate">
package com.xebia.library.impl;

import java.util.Collections;
import java.util.List;

import com.xebia.library.BookRepository;
import com.xebia.library.model.Book;

public class BookRepositoryBean implements BookRepository {

	@Override
	public List&lt;Book&gt; all() {
		return Collections.singletonList(new Book(&quot;My Title&quot;));
	}

}
</pre>
<p>The implementation of the web service is very simple (for now) and it uses a very simple POJO as return value.</p>
<pre class="brush: java; title: com/xebia/library/model/Book.java; notranslate">
package com.xebia.library.model;

public class Book {

	private String title;

	public Book() {
	}

	public Book(String title) {
		this.title = title;
	}

	public String getTitle() {
		return title;
	}
}
</pre>
<p>With these simple files, we have all we need to get a RESTful web service running on JBoss AS 7. Pointing the browser to the correct URL, we get a JSON string as shown below.<br />
<a href="http://blog.xebia.com/wp-content/uploads/2011/07/WebServiceResult.png"><img src="http://blog.xebia.com/wp-content/uploads/2011/07/WebServiceResult-300x172.png" alt="" title="WebServiceResult" width="300" height="172" class="aligncenter size-medium wp-image-7133" /></a><br />
The URL is built up from a few parts:</p>
<ol>
<li><b>http://localhost:8080</b> The JBoss web server</li>
<li><b>library</b> The application context</li>
<li><b>services</b> The path configured for the JAX-RS application in the @ApplicationPath annotation</li>
<li><b>books</b> The path for the BookRepository resource as given in the @Path annotation</li>
</ol>
<p>JBoss AS 7 comes with <a href="http://www.jboss.org/resteasy">RESTeasy</a> (an implementation of JAX-RS) and <a href="http://jackson.codehaus.org/">Jackson</a> (a Java-JSON serializarion framework) configured and that is how the final result is obtained. This makes JBoss AS 7 an ideal platform for developing RESTful applications: it works out-of-the-box and is build on well known open source projects, making it easy to adapt the container to specific requirements in you application.</p>
<h2>Conclusion</h2>
<p>In this blog we have set up a development environment for JBoss AS 7 using Maven, Eclipse and WTP and we deployed a very simple RESTful application. The setup works pretty well.<br />
Keep an eye out for new blogs, in which I&#8217;ll improve on the current project to show more aspects of JBoss 7 and RESTful applications.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2011/07/12/developing-restful-applications-on-jboss-as-7/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2011%2F07%2F12%2Fdeveloping-restful-applications-on-jboss-as-7%2F&amp;title=Developing%20RESTful%20applications%20on%20JBoss%20AS%207" id="wpa2a_2"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2011/07/12/developing-restful-applications-on-jboss-as-7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Configuring a Seam EJB project for development with Maven and JBoss Tools</title>
		<link>http://blog.xebia.com/2009/06/06/configuring-a-seam-ejb-project-for-development-with-maven-and-jboss-tools/</link>
		<comments>http://blog.xebia.com/2009/06/06/configuring-a-seam-ejb-project-for-development-with-maven-and-jboss-tools/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 16:23:19 +0000</pubDate>
		<dc:creator>Maarten Winkels</dc:creator>
		<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/blog.xebia.com/www/wp-content/plugins/autometa/autometa.php</b> on line <b>303</b><br />
		<category><![CDATA[General]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[eclipse:eclipse]]></category>
		<category><![CDATA[eclipse:m2eclipse]]></category>
		<category><![CDATA[jboss tools]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven archetype]]></category>
		<category><![CDATA[maven-eclipse-plugin]]></category>
		<category><![CDATA[Seam]]></category>

	<!-- AutoMeta Start -->
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=1288</guid>
		<description><![CDATA[Say you want to build a web application and you want to use Seam for integrating standard technologies like JSF and EJB. Furthermore, you want to use the power of Maven to build your project for different environments, on different systems (like you continuous build system) and use its&#8217; rich reporting features to get an [...]]]></description>
			<content:encoded><![CDATA[<p>Say you want to build a web application and you want to use Seam for integrating standard technologies like JSF and EJB. Furthermore, you want to use the power of Maven to build your project for different environments, on different systems (like you continuous build system) and use its&#8217; rich reporting features to get an overview of the code quality of your project. And of course you want to use a good IDE, like Eclipse with JBoss tools to aid you in development. How does one go about setting up all these things?<br />
<span id="more-1288"></span><br />
<b>Maven &#8211; Project structure</b><br />
<span style="float:right"><a href="http://blog.xebia.com/wp-content/uploads/2009/04/module-dependencies.png"><img src="http://blog.xebia.com/wp-content/uploads/2009/04/module-dependencies-237x300.png" alt="module-dependencies" title="module-dependencies" width="237" height="300" class="alignright size-medium wp-image-1290" /></a></span>The first thing to realize is how to setup the maven project structure for this project. To develop a Seam project that uses EJBs (and JSF), we need an ejb-archive and a web-archive. These should be combined in an ear-archive. For maven this means we need at least three projects, one for each artifact, and preferably one more to easily build the others.<br />
The picture hows how these projects are related:</p>
<ol>
<li>The BLD (build) project is the parent project of all the other projects, that in turn are modules of the BLD project. The main purpose of this project is to provide a place for common configuration and a common build for all modules.</li>
<li>The WAR project depends on the EJB project, because it will use some of the services.</li>
<li>The EAR project depends on both the WAR and the EJB project, because these should be packaged in the ear.</li>
</ol>
<p><b>Maven &#8211; Dependencies</b><br />
Maven is all about dependencies. Luckily Seam libraries are available in the repositories, both the special repositories hosted by JBoss and the central repository. And there is more: Seam provides a very useful maven project, that can be used as the parent for our own project: org.jboss.seam:root. This project contains the JBoss repositories and a dependency management section that will ensure that compatible versions of all libraries are referenced. So the first step is to make our BLD project a child of the org.jboss.seam:root project.<br />
Then we have to add the necessary dependencies for Seam.</p>
<ul>
<li>The EJB project depends on org.jboss.seam:jboss-seam:ejb and on org.hibernate:hibernate-entitymanager, since we&#8217;re gonig to use hibernate for persistence.</li>
<li>The WAR project depends on org.jboss.seam:jboss-seam-ui. Now depending on your preference of front end technology, other dependencies will need to e added, but we will come to that later.</li>
</ul>
<p>The good thing is that since we&#8217;re using the org.jboss.seam:root as parent, we don&#8217;t need to specify versions, this is handled by dependency management.<br />
The Maven structure and dependencies (and some more support files like web.xml and ejb-jar.xml) can be packaged in a Maven archetype. Attached to this blog, you can find the one we are building right now. It can also be found in <a href="http://os.xebia.com/repository/">Xebias Opensource Maven repository</a> or the <a href="http://os.xebia.com/snapshot-repo/">snapshot repository</a>.</p>
<p><b>Eclipse</b><br />
<span style="float:left; margin: 10px;"><a href="http://blog.xebia.com/wp-content/uploads/2009/04/jboss-project.png"><img src="http://blog.xebia.com/wp-content/uploads/2009/04/jboss-project-181x300.png" alt="jboss-project" title="jboss-project" width="181" height="300" class="alignleft size-medium wp-image-1309" /></a></span>Now, after handling Maven, let&#8217;s turn our attention to this Eclipse beast. We would like to have an easy path from the Maven project to the Eclipse development environment. Eventually we would like to have JBoss Tools running out-of-the-box starting from the simple Maven project. First let&#8217;s take a look at a JBoss Tools Seam project.<br />
The image on the left shows the outline of a Seam project as created by JBoss Tools. There are 4 projects: test (WAR), test-ejb, test-ear and test-test. The last contains the tests, which in a maven project will be part of the same project, so we will not discuss it further. The other three projects are WTP enabled projects. looking at the configuration files (.settings/org.eclipse.wst.common.component in each project), we find that it is using WTP version 1.5.<br />
Now we&#8217;ll try to build a similar configuration starting from the maven project.</p>
<p><b>Eclipse &#8211; WTP support</b><br />
Maven has a maven-eclipse-plugin, that has as sole purpose to transform a maven project into a working eclipse project configuration. Unfortunately, it&#8217;s WTP support is seriously broken. To configure the plugin, we use this XML snipped, taken from <a href="http://maven.apache.org/plugins/maven-eclipse-plugin/examples/multi-module-projects.html">the official documentation</a>.</p>
<pre lang="xml">
<plugins>
<plugin>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <downloadSources>true</downloadSources>
          <wtpmanifest>true</wtpmanifest>
          <wtpapplicationxml>true</wtpapplicationxml>
          <wtpversion>1.5</wtpversion>
          <manifest>${basedir}/src/main/resources/META-INF/MANIFEST.MF</manifest>
        </configuration>
      </plugin>
    </plugins></pre>
<p>This snipped should be placed in the pom.xml of the BLD project, so it is applied to all projects. </p>
<p>Now, running the eclipse:eclipse maven goal on the BLD project will generate the eclipse configuration (.project, .classpath and WTP files) for all projects. The version of the JEE specifications will be inferred by the maven-eclipse-plugin by looking at the maven dependencies for the respective specifications. To make sure the plugin generates the correct WTP configuration, we need to add the javax.ejb:ejb-api:3.0 dependency to the EJB project and the javax.serlet:servlet-api:2.5 to the WAR project. With this, the configuration for these two projects is working fine. Unfortunately, the EAR project is not working and cannot be deployed. For some reason WTP does not recognize the modules for this project and when trying to deploy it, some ClassCastException is thrown. So much for maven-eclipse-plugin&#8230;</p>
<p><b>eclipse:m2eclipse</b><br />
&#8230;or not? The plugin features another goal, that could be useful here: eclipse:m2eclipse. This will generate the eclipse configuration in the same manner, but it will add the <a hre"http://m2eclipse.sonatype.org/">M2Eclipse plugin</a> to the projects. This plugin has a lot of useful features: It makes synchronizing the eclipse configuration with the maven configuration a breeze. It will, for example, add the maven dependencies to the eclipse classpath, but it will also synchronize other properties, like the java version. Furthermore adding dependencies and changing the POM in general becomes really easy and, finally, creating new Maven project or modules from within eclipse becomes really easy.<br />
This way of setting up the eclipse project is rather different from the previous one: In stead of generating all the configuration files correctly, the M2Eclipse plugin works from within eclipse to synchronize the eclipse and WTP configuration. The eclipse:m2eclipse goal does not work well with the configuration given above for the eclipse:eclipse goal, especially for EAR projects. It is better to remove all configuration from the maven-eclipse-plugin configuration and let the plugin do it&#8217;s work. This means that after generating the eclipse project files, you&#8217;ll have to open the Eclipse workspace and kick-off the synchronization process manually. More about this can be found on the <a href="http://os.xebia.com/seam-jboss-tools-archetype/">Maven site for the archetype</a>.</p>
<p><b>JBoss Tools support</b><br />
JBoss tools is a Eclipse feature, that can be enabled on a project by adding some configuration (JSF and Seam facets, the SeamBuilder and SeamNature) to the eclipse project. JBoss Tools will manage two projects: the WAR and the EJB project, but the WAR project will be the main source of configuration. By adding the necessary items to the maven-eclipse-plugin configuration for this project and also adding a special Seam configuration file to the .settings directory, JBoss tools will recognize the project correctly.<br />
For some reason, JBoss tools also stores some configuration in the workspace configuration. This can not be configured from the Maven Archetype and thus the JBoss Tools configuration is not complete. Because of this, the link between the WAR and EJB project will not be found by JBoss Tools from the EJB project. When a new Seam Artifact (Action, Entity, Form or Conversation) is added from the EJB project context meny, the configurations made in the WAR project are not picked up. When adding from the WAR project they are picked up and some sources will also be written in the EJB projects, as required.</p>
<p><b>JBoss Tools &#8211; JSF templates</b><br />
JBoss Tools will generate Java sources and JSF pages when a new component is added. The JSF pages expect certain templates to exist in the Seam project and wont work correctly if they are not found. Adding these files to the Maven Archetype makes the generated JBoss Tools project work correctly. Also the Maven projects needs additional dependencies on RichFaces and Facelets in a certain configuration (some jars should go in the WEB-INF/lib, some in the EAR/lib) to make the deployed application work correctly.<br />
The JBoss Tools project generated by the (current version of the) archetype will be exactly the same as a project created from within JBoss Tools, except for the security configuration.</p>
<p><b>Deploying on JBoss &#8211; application.xml troubles</b><br />
One last problem arises when trying to deploy the generated application on JBoss AS 4.2: It will complain about the missing META-INF/application.xml. As per latest JEE spec, the application.xml is no longer mandatory, but JBoss AS 4.2 doesn&#8217;t handle this correctly. To make it work with WTP on JBoss and also with the Maven created artifacts, we have to apply a few tricks to make it all work:</p>
<ol>
<li><i>We need to add an &#8216;empty&#8217; application.xml file in the META-INF directory in src/main/application of the EAR project.</i><br />This file is changed by the M2Eclipse plugin and used by WTP to make the deployment work on JBoss AS.</li>
<li><i>We let Maven generate an application.xml file during the build by setting the property generateApplicationXml on the ear plugin.</i><br />The file is generated in the normal bulid directory and not the same as the previous.</li>
<li><i>We exclude the first file from the maven-bulid EAR file using the property earSourceExcludes on the ear plugin (value:META-INF/application.xml).</i><br /> this way the first file is ignored and the second is used in the maven build.</li>
</ol>
<p>Et voila! At this point we have reached our goal of building a Seam project with Maven while still being able to use JBoss Tools, Eclipse and WTP for development.</p>
<p>Happy Coding!</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2009/06/06/configuring-a-seam-ejb-project-for-development-with-maven-and-jboss-tools/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2009%2F06%2F06%2Fconfiguring-a-seam-ejb-project-for-development-with-maven-and-jboss-tools%2F&amp;title=Configuring%20a%20Seam%20EJB%20project%20for%20development%20with%20Maven%20and%20JBoss%20Tools" id="wpa2a_4"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2009/06/06/configuring-a-seam-ejb-project-for-development-with-maven-and-jboss-tools/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Differences between Seam-gen and Jboss Tools</title>
		<link>http://blog.xebia.com/2009/04/21/differences-between-seam-gen-and-jboss-tools/</link>
		<comments>http://blog.xebia.com/2009/04/21/differences-between-seam-gen-and-jboss-tools/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 12:18:25 +0000</pubDate>
		<dc:creator>Gaurav Kohli</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[jboss tools]]></category>
		<category><![CDATA[Seam]]></category>
		<category><![CDATA[seam-gen]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=1114</guid>
		<description><![CDATA[In this article we will basically try to understand the basic difference between different ways in which we can do Seam application development. So before we get into details, let have a brief introduction about Seam So what is Seam?? Seam is a powerful open source development platform for building rich Internet applications in Java. [...]]]></description>
			<content:encoded><![CDATA[<p>In this article we will basically try to understand the basic difference between different ways in which we can do Seam application development. So before we get into details, let have a brief introduction about Seam</p>
<p><span id="more-1114"></span><br />
<strong>So what is Seam??</strong></p>
<p>Seam is a powerful open source development platform for building rich Internet applications in Java. Seam integrates technologies such as Asynchronous JavaScript and XML (AJAX), JavaServer Faces (JSF), Java Persistence (JPA), Enterprise Java Beans (EJB 3.0) and Business Process Management (BPM) into a unified full-stack solution, complete with sophisticated tooling(<a href="#build">1</a>). The simple chart of architectural design will show you about this:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1118" title="design-2" src="http://blog.xebia.com/wp-content/uploads/2009/04/design-2.png" alt="design-2" width="254" height="332" /></p>
<p style="text-align: center;">Diagram 1.1 Architecute of Seam</p>
<p>So Seam basically does the job of plumbing these disconnected frameworks. We had all the good things in J2EE world, but making them work together was a pain. But, now we do have Seam to do all the dirty work for us.</p>
<p>How to get started with Seam application development??<br />
Following could be the possible ways in which we could get started with a simple seam project structure.</p>
<ul>
<li>Seam- gen</li>
<li>Jboss Tools</li>
<li>Maven</li>
</ul>
<p>It was really fun to work on Seam, as it greatly reduced the initial project setup time which we normally have with J2EE project. Seam is basically a tool which give you more Return on Investment (ROI) for the same number of lines you write in any other Java framework like spring or struts.</p>
<p>So, let’s get started with the main aim of this article to have feature differentitation between seam-gen and Jboss Tools .</p>
<p>First of all I would write something about both the Tools and after that will try to get into more details about each.</p>
<h3 style="margin-left:6px">Seam-gen</h3>
<p>We will start with using seam-gen to generate a project structure, as seam-gen provides out-of –box scripts to generate Seam Action, Entity and Conversations</p>
<p><strong>So what is Seam-gen??</strong></p>
<p>Seam-gen is a rapid application generator shipped with the Seam distribution. With a few command line commands, seam-gen generates an array of artifacts for Seam projects to help you get started. In particular, seam-gen is useful for the following.</p>
<ul style="margin-top: 0cm;" type="disc">
<li>Automatically      generate an empty Seam project with common configuration files, a build      script, and directories for Java code and JSF view pages.</li>
<li>Automatically      generate complete Eclipse and NetBeans project files for the Seam project.</li>
<li>Reverse-engineer      entity bean objects from relational database tables.</li>
<li>Generate      template files for common Seam components.</li>
</ul>
<h3 style="margin-left:6px">Jboss tools</h3>
<p>JBoss Tools is a collection of Eclipse plugins. JBoss Tools a project creation wizard for Seam, Content Assist for the Unified Expression Language (EL) in both facelets and Java code, a graphical editor for jPDL, a graphical editor for Seam configuration files, support for running Seam integration tests from within Eclipse, and much more.<br />
In short, if you are an Eclipse user, then you&#8217;ll want to use JBoss Tools!</p>
<p>Now, we will mainly look at different aspects in which seam-gen and Jboss Tools are different and what could be the best option for building Seam application from scratch</p>
<p>Aspects in which they are different:</p>
<ol>
<li>Project Structure</li>
<li>Build process</li>
<li>Deployment strategy</li>
<li>Profiles</li>
<li>Testing approach</li>
</ol>
<h3 style="margin-left:6px">Difference in Project Structure:</h3>
<p><strong>Seam-gen source directories</strong></p>
<p style="text-align: justify;">The source directories created by seam-gen are each dedicated to holding certain types of source files. This enables seam-gen to determine what tests need to be executed as well as selectively hot-deploy your Seam components.(<a href="#d12">Diagram 1.2</a>)</p>
<table border="1" cellspacing="0" cellpadding="0" width="628">
<tbody>
<tr>
<td  width="104" valign="top">
/src/main
</td>
<td width="498" valign="top">
Classes to include in the main classpath
</td>
</tr>
<tr >
<td width="104" valign="top">
/src/hot
</td>
<td width="498" valign="top">
Classes to include in the hot deployable   classpath when running in development mode.
</td>
</tr>
<tr >
<td width="104" valign="top">
/src/test
</td>
<td  width="498" valign="top">These classes will not be deployed but will be executed as   part of the test target.</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;">So in this project structure, we only have one source folder which contains both, the EJB entities and the War content. This is one thing, which I don’t like about seam-gen. They could have provided a better project structure like the one we have with Jboss tools.</p>
<p><strong>Jboss tools source directories</strong></p>
<p style="text-align: left;">Jboss tools source directory is well arranged compared to the seam-gen project directory, as it follow the standard J2EE application packaging.In this struture we have a war project, ejb project and finally both of them bundled into a ear distribution. In addition to that they have separated out a test project, which is good for doing testing.This kind of structure also helps to manage large projects, where we have  teams working on different module of the project.</p>
<table  border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="132" valign="top">
HelloSeam
</td>
<td  width="477" valign="top">
Contains the deployment   descriptor, the Web component files, and related resources.
</td>
</tr>
<tr>
<td  width="132" valign="top">
HelloSeam-ear
</td>
<td  width="477" valign="top">
The final ear distribution
</td>
</tr>
<tr>
<td  width="132" valign="top">
HelloSeam-ejb/ejbModule
</td>
<td  width="477" valign="top">
Contains ejb deployment descriptor, the   enterprise bean files, and related files.
</td>
</tr>
<tr>
<td width="132" valign="top">
HelloSeam -test/test-src
</td>
<td  width="477" valign="top">
The test classes.
</td>
</tr>
</tbody>
</table>
<p><a name="d12"></a></p>
<p style="margin-left: 36pt; text-align: center;"><img class="aligncenter size-full wp-image-1307" title="seam-gen-project-structure-22" src="http://blog.xebia.com/wp-content/uploads/2009/04/seam-gen-project-structure-22.png" alt="seam-gen-project-structure-22" /></p>
<p style="margin-bottom: 0.0001pt; line-height: normal; text-align: center;">Diagram 1.2 Project struture of Seam-gen and JBoss tools</p>
<h3  style="margin-left:6px">Differences in Build process:</h3>
<p style="text-align: justify;">First let start with the build process seam-gen follows. The seam-gen project is built using the ant tool and they provide an extensive target in the build.xml. So most of what you want to do in different phases of application development, you can do that using the build.xml provided.</p>
<p>Some sample targets which might be of interest to everyone</p>
<table  border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="180" valign="top">
explode , reexplode
</td>
<td width="429" valign="top">
These are for doing the seam   application deployment as a exploded directory.
</td>
</tr>
<tr>
<td width="180" valign="top">
deploy , reploy
</td>
<td width="429" valign="top">
these are for deploying the   seam application as a packaged archive
</td>
</tr>
<tr>
<td width="180" valign="top">
groovy.compile
</td>
<td width="429" valign="top">
If you have some groovy code,   so this would just compile them into java classes
</td>
</tr>
<tr>
<td width="180" valign="top">
restart, restart-deployed,   restart-exploded
</td>
<td width="429" valign="top">
for doing the restart ,   depending on the kind of deployment
</td>
</tr>
<tr>
<td width="180" valign="top">
others like jar, war, javadoc
</td>
<td width="429" valign="top">
Utility targets for generating   different things.
</td>
</tr>
</tbody>
</table>
<p>In case of Jboss tools on the other hand, we don’t have a build.xml file provided, but we can tweet the build script of Seam-gen project to work with JBoss tools. I have <a href="#build">attached</a> a strip down version of the build.xml of seam-gen to provide the minimum task needed for Seam project, which works fine with JBoss Tools.</p>
<h3  style="margin-left:6px">Differences in Deployment Process:</h3>
<p style="margin-bottom: 0.0001pt;">As we have already discussed that the Jboss tools can be configured to use Eclipse Web Tool Platform (WTP) Project, so when we deploy the seam application using WTP the ear bundle along with the datasource deployment descriptor file are copied to the following directory.</p>
<p><em>“C: workspace .metadata.pluginsorg.jboss.ide.eclipse.as.coreJBoss_4.2_Serverdeploy” </em></p>
<p style="margin-bottom: 0.0001pt;">Whereas, in case of ant build, both the files goes directly into the Jboss main deploy directory .In my case it was this directory:</p>
<p><em>“C:Program Filesjboss-4.2.2.GAserverdefaultdeploy”</em></p>
<p>In this regard, the former process looks to be better, since we don’t clutter the main Jboss deploy directory.</p>
<h3  style="margin-left:6px" >Differences in Profiles</h3>
<p><strong>Seam-gen Profiles</strong></p>
<p style="text-align: justify;">Seam-gen supports the concept of &#8220;profile&#8221;. The idea is that the application probably needs different settings (e.g. database settings, etc) in the development, test, and production phases. So, the project provides alternative configuration files for each of the three scenarios. In the resources directory, you will find the following configuration files:</p>
<p style="margin-bottom: 0.0001pt; text-align: justify;">
<table  border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td  width="132" valign="top">
/META-INF/persistence-*.xml
</td>
<td  width="477" valign="top">Provides configuration   of a JPA persistence-unit for each environment.</td>
</tr>
<tr>
<td>import-*.sql</td>
<td  width="477" valign="top">
Imports data into a generated schema based on deployment environment.   Generally useful for testing purposes.s
</td>
</tr>
<tr>
<td  width="132" valign="top">components-*.properties</td>
<td  width="477" valign="top">
Allows wild-card replacement of Seam component properties based on   environment.
</td>
</tr>
</tbody>
</table>
<p><strong>Jboss Tool Profiles</strong></p>
<p style="text-align: justify;">Jboss tools doesn’t provide any support for profiles , so we only have one set of configuration files, which we have to use for different phases by making changes in them .</p>
<p style="text-align: justify;">So this could be one more drawback of using Jboss tools.</p>
<h3  style="margin-left:6px">Differences in Testing approach:</h3>
<p>Testing is a very important part of the Agile programming, so we also need a very good project structure for doing the same. Jboss tools, surely knows this and have done a good job of keeping a separate project, only for test. This really solves lot of problems you might face while running test in Eclipse for a seam- gen project</p>
<p>For a seam-gen project, if you are running test using ant task then its fine, but otherwise you would need to make some changes in classpath of all the test classes.</p>
<h3  style="margin-left:6px">Conclusion Matrix:</h3>
<p>We could conclude this article with a matrix which contains feature by feature comparison.</p>
<table style="border: medium none ; margin-left: 5.4pt; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding: 0cm 5.4pt; width: 99.25pt;" width="132" valign="top"></td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">Project Structure</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">Build Process</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">Deployment Strategy</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">Profiles</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">Testing approach</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 99.25pt;" width="132" valign="top">Seam-gen</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">**</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">****</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">***</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">****</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">**</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 99.25pt;" width="132" valign="top">JBoss tools</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">*****</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">**</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">****</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">*</td>
<td style="padding: 0cm 5.4pt; width: 357.45pt;" width="80" valign="top">***</td>
</tr>
</tbody>
</table>
<p style="text-align:justify">For me mixture of both is the winner for developing a Seam application.But till we don&#8217;t have that from the Seam&#8217;s framework , we can surely go with Jboss Tools. Even though it misses the ant support, we can tweak the ant script provided by seam-gen and use it in our Jboss Tools project.</p>
<h4>References</h4>
<ol> <a name="build"></a></p>
<li>Build. xml for JBoss Tools Project (<a href="http://blog.xebia.com/wp-content/uploads/2009/04/buildxml.txt" target="_blank">Build.xml</a>)</li>
<li><a href="http://seamframework.org/" target="_blank">http://seamframework.org/</a></li>
<li>Seam-gen Command guide <a href="http://www.jboss.org/community/docs/DOC-10750" target="_blank">http://www.jboss.org/community/docs/DOC-10750</a></li>
<li>Seam-gen and JBoss Tools together <a href="http://relation.to/Bloggers/UsingASeamgenProjectInJBossTools" target="_blank">http://relation.to/Bloggers/UsingASeamgenProjectInJBossTools</a></li>
</ol>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2009/04/21/differences-between-seam-gen-and-jboss-tools/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2009%2F04%2F21%2Fdifferences-between-seam-gen-and-jboss-tools%2F&amp;title=Differences%20between%20Seam-gen%20and%20Jboss%20Tools" id="wpa2a_6"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2009/04/21/differences-between-seam-gen-and-jboss-tools/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  blog.xebia.com/tag/jboss-tools/feed/ ) in 0.64656 seconds, on Feb 9th, 2012 at 4:16 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 9th, 2012 at 5:16 pm UTC -->
