<?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>Next Presso &#187; Seam</title>
	<atom:link href="http://www.next-presso.com/tag/seam/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.next-presso.com</link>
	<description>Java, Seam, Spring &#38; co</description>
	<lastBuildDate>Fri, 30 Sep 2011 15:33:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Please JBoss don&#8217;t let CDI become the &#8220;Betamax&#8221; of Java by destroying Seam 3</title>
		<link>http://www.next-presso.com/2011/09/please-jboss-dont-let-cdi-become-the-betamax-of-java-by-destroying-seam-3/</link>
		<comments>http://www.next-presso.com/2011/09/please-jboss-dont-let-cdi-become-the-betamax-of-java-by-destroying-seam-3/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 13:42:07 +0000</pubDate>
		<dc:creator>Antoine Sabot-Durand</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[CDI]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://www.next-presso.com/?p=358</guid>
		<description><![CDATA[Following the <a href="http://relation.to/Bloggers/SoWhatsHappeningWithSeam" target="_blank">in.relation.to</a> blog post of last tuesday.As a tech lead on one Seam Module (Seam Social),  I wrote this open Letter to Red Hat employees in charge of Seam project and community. I find useful to share my point of view with the community on this matter.  You also might find interesting to read the <a href="http://hannelita.wordpress.com/2011/09/28/seam-3-whats-going-on/" target="_blank">blog post of Hannelita</a> on the same subject. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" src="http://t3.gstatic.com/images?q=tbn:ANd9GcQNHkaAUCvMxaQKyp2C33sIfRo1LJ8nhQahRRg0KrMGZhqElYzI" alt="" width="195" height="127" /><br />
Following the <a href="http://relation.to/Bloggers/SoWhatsHappeningWithSeam" target="_blank">in.relation.to</a> blog post of last tuesday, as a tech lead on one Seam Module (<a href="http://seamframework.org/Seam3/SocialModule" target="_blank">Seam Social</a>),  I wrote this open Letter to Red Hat employees in charge of Seam project and community. I find useful to share my point of view with the community on this matter.  You also might find interesting to read the <a href="http://hannelita.wordpress.com/2011/09/28/seam-3-whats-going-on/" target="_blank">blog post of Hannelita</a> on the same subject.</p>
<p>Here is my letter :</p>
<p><em>This email is a tentative to gather and synthesize all my thought following the yesterday announce on in.relation.to about Seam 3 reorganization. I want it to be seen as a positive feedback. I don&#8217;t pretend to have all the answers but being someone external to Red Hat and having worked with other frameworks / technologies give me (I think) a better &#8220;big picture&#8221; view and a more objective perception of the matter.</em></p>
<h2><em>Who&#8217;s talking ?</em></h2>
<p><em>I&#8217;m not going to tell you all my life here. But it can help for my legitimacy to know that I graduated from a famous IT School in 1995 (yes I&#8217;m 40) and had been working in IT since then. I started with C / C++ and then Lotus Domino (talking about mistakes). I started looking into Java in 1997 as a hobby and more seriously for work in 2001. I worked with a lot of Java frameworks : pure servlet and JSP, Struts 1.X, iBatis, Spring, JSF, Hibernate, EJB3, Seam 2 (I started with 2 beta in 2007) to finally adopt Java EE 6.</em></p>
<p><em>I&#8217;d been  working alone for 10 years then after that as a CTO in a small Web Agency (where I learnt some web marketing) and I&#8217;ve bee working since 2009 as a consultant in an IT Consulting company specialized on Java. My Job is to audit applications, design new application as an architect and doing support to other developer on a bunch of technologies.</em></p>
<h2><em>History (knowing our &#8220;opponent&#8221;)</em></h2>
<p><em>Again, I&#8217;m not going to write a novel here but I think it&#8217;s better to put things in perspective.</em></p>
<p><em>JCP had clearly a bad start. Most of specification in J2EE before Java EE 5 were full of flaws (especially EJB 1.X and 2.X). That&#8217;s mainly the reason why Spring was created and has been so successful : it was a pragmatic and rather clean way to address Java Enterprise needs. From a lightweight solution spring grown to a heavy but quite consistent eco-system and today it has a big market share in the Java Industry. Meanwhile spring was getting bigger, the JCP somehow took notice of its past errors and worked to change things and provide nice specification for the new Java EE edition. But we had to wait for Java EE 6 to get an official standard that was able to compete with Spring (the de Facto Standard) thanks to CDI and the tremendous work that JBoss guys put in it.</em></p>
<p><em>So today we are in a paradoxical situation where the official Java EE stack is the challenger of the de facto standard : Spring. To be honest, Java EE is better than core Spring but not way better. Also Spring has a lot of popular modules that help developers in their daily work (a big eco-system). A lot of  company have invested on Spring (training, support, etc&#8230;) and they have no obvious reason to switch to Java EE 6. If we want to bring them to this switch we have to build something better and something bigger</em></p>
<h2><em>What should be Red Hat goals ?</em></h2>
<p><em>The main goal for Red Hat is to sell licenses and support. I don&#8217;t know your exact income on JBoss activity but with a real big Java EE adoption, those incomes should rise very clearly. Right now most of the JBoss EAP server I see at my customer run Spring application and most of these server could be switched to Tomcat or Jetty tomorrow without any big trouble (the same for most WAS or Weblogic).</em></p>
<p><em>A secondary goal (that interest me more) is philosophical. The Java EE 6 stack is a community creation, its blue print doesn&#8217;t belong to a single shop and tomorrow if someone want to propose something new he could contribute to this community. Ok, it&#8217;s not perfect but for me it&#8217;s far way  better than having VMWare deciding what&#8217;s good and wrong for me. I often say to Spring Fanboys that if they want to have one editor to decide for them they&#8217;d better switch to .Net : Microsoft does a better Job than VMWare  and C# is better than Java <img src='http://www.next-presso.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . The advantage of Java eco-system is the community. So the Goal is to use the force of this community and bring open solutions to them.</em></p>
<p><em>Creating a big and good CDI eco-system will create value, bring real competition to the Java stack and create more business for Red Hat (AS license or support on main CDI components)</em></p>
<h2><em>Why CDI is so special</em></h2>
<p><em>CDI is not a spec among others. It&#8217;s the long awaited cement in Java EE stack. It could have been an extension of EJB spec but it was clever to create it as a separate spec and allow it to deal with EJBs. CDI is the first Java EE spec that contains in its DNA a natural extension mechanism. And last but not least CDI is probably the first Java EE spec to be usable in its V 1.0 (perhaps with Jax-RS).</em></p>
<p><em>A common critic to Java EE is that it has a very long cycle between each iteration and that it delivers outdated specs. Another common critic is that it provides a bunch of specs that doesn&#8217;t work well together.</em></p>
<p><em>This second critic was addressed by Seam 2. Seam was a big help to make Java EE 5 easy to use, but as you know it was proprietary.</em></p>
<p><em>CDI address both critics : it has the potential to provide the same services than Seam 2  and it is a good way to extend Java EE between two versions.</em></p>
<p><em>To sum up CDI is a central spec for Java EE (it&#8217;s its spine) :</em></p>
<ol>
<li><em>CDI is the cement between main Java EE spec</em></li>
<li><em>CDI the &#8220;melting pot&#8221; engine for adding new spec in Java EE. First in a proprietary approach and then by standardization in next EE version.</em></li>
<li><em>For extension that can&#8217;t be integrated in Java EE (like Seam social) it&#8217;s an elegant and seamless way to enhance the stack.</em></li>
</ol>
<h2><em>Past and present Errors</em></h2>
<h3>Error 1 : a bad name</h3>
<p><em>The first error in my opinion was to call it &#8220;Seam 3&#8243;. This bad choice triggered these pb :</em></p>
<ol>
<li><em>giving the impression that Seam 3 was an evolution of Seam 2. Which it is not.</em></li>
<li><em>creating the obligation to build a compatibility module from Seam 2 to Seam 3. This module is costing a lot of energy to the community and will only produce deception</em></li>
<li><em>Hiding the CDI nature of these extensions by calling them after  the name of an &#8220;old&#8221; JBoss proprietary framework</em></li>
</ol>
<div><em>What is done is done, Seam 3 is now among us, but the legacy is heavy&#8230;</em></div>
<h3>Error 2 : pretending Spring doesn&#8217;t exist</h3>
<p><em> Ignore existing market is a big mistake. Spring is well implanted and doing as if it wasn&#8217;t there is wrong. I think a better way would be to adopt the following philosophy :  &#8220;We know that you had to use this proprietary framework because there was nothing else but now we will show you something new, better, but <strong>that can use your Spring </strong>eco-system&#8221;. Yes the <strong>Spring bridge</strong> is not an option, It&#8217;s a priority. You have to help people switching by giving them a way to use their Spring components so they don&#8217;t feel lost and can use Spring module until Seam has the equivalent functionality.</em></p>
<p><em>Spring team is totally ignoring Java EE. Their ref doc is full of J2EE, EJB 2.1 and nothing about CDI or EJB 3. We have to show the Java community that we&#8217;re more open than them and care about people using Spring to come, see and perhaps adopt the standard. The idea is to behave at the opposite of the locking VMWare strategy by being opened and avoiding trolls and </em><em>misinformation like they do.</em></p>
<h3><em>Error 3  : eating our own dog food with Seam university.</em></h3>
<p><em>Don&#8217;t get me wrong : the idea of Seam University website is great. What is not so great is to use our tool to create the site. We don&#8217;t have time to build something neat, so it&#8217;ll be crappy and we&#8217;ll lost time on it.  Result : bad impression and time wasted. Other Framework don&#8217;t use themselves to create their website, they use standard tools. We should do the same for the Seam website. People are waiting for simple demo and example not a big steam machine like the Seam Wiki is today.</em></p>
<h3><em>Error 4 : mix internal functioning with façade functioning of the project</em></h3>
<p><em>Having Seam module created near their mother project (Hibernate, Resteasy&#8230;) is not a bad idea. The bad idea is to make them disappear from the Seam stack. You can have CDI-persistence (note I didn&#8217;t wrote CDI-Hibernate) driven by Hibernate project , but it should be visible in both  Seam stack and hibernate.  Because One can discover it while using Hibernate or while looking for a persistent CDI extension.</em></p>
<h3><em>Error 5 : giving the impression that those modules will have adherence to Jboss implementation</em></h3>
<p><em>Calling the module Hibernate-CDI or RestEasy-CDI is a big step back (even if you keep portability). Tomorrow developers on WAS or Glassfish won&#8217;t choose them because it doesn&#8217;t support JPA but hibernate (it&#8217;s in the name). A non sense after all the effort that Jboss has injected in working on standard.</em></p>
<p><em>It&#8217;s important that Seam appear as collection of CDI extension that allow to leverage standard Java EE. Having them under one umbrella allow Red Hat to sell optional support for them if people want to use them on WAS, Glassfish, Tomcat or Resin.</em></p>
<h3><em>What should Seam 3 be (according to me) </em></h3>
<p><em>Seam should be turned to the community. I don&#8217;t know if Red Hat would be ok to do that but the core project should be outside of JBoss and community driven. It would be the best solution to gather our effort with those of CDI Source, Codi, Caucho and others.</em></p>
<p><em>Seam 3 should run on all CDI implementation. That&#8217;s a priority (today, Solder doesn&#8217;t work on Candi, I didn&#8217;t tested on Open WebBeans but I guess there are issues).</em></p>
<p><em>Seam should provide light modules with good documentation and example. I mention that because i have he impression that Solder is becoming a kind of trash can. It&#8217;s not good. On the other way the split between persistence and transaction was a good move in my opinion</em></p>
<p><em>Seam should have a clear roadmap and timeline. We have to communicate, communicate and communicate. Don&#8217;t forget that we have to convince people using an equivalent solution. We must show why we are better and that we have a clear Goal.</em></p>
<p><em>Thanks for your time reading my long mail. I hope it&#8217;ll be useful and I&#8217;m ready to contribute to these orientation.</em></p>
<p><em>regards,</em></p>
<p><em>Antoine</em></p>
<p><strong>UPDATE : </strong>Shane Bryzak project leader on Seam 3 <a href="http://in.relation.to/Bloggers/SeamNextUpdate" target="_blank">posted an update</a> this morning, to explain there is something in preparation around Seam.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.next-presso.com/2011/09/please-jboss-dont-let-cdi-become-the-betamax-of-java-by-destroying-seam-3/feed/</wfw:commentRss>
		<slash:comments>11050</slash:comments>
		</item>
		<item>
		<title>WTP + M2eclipse + Seam : Maven works !</title>
		<link>http://www.next-presso.com/2009/06/wtp-m2eclipse-seam-cest-bien-maven/</link>
		<comments>http://www.next-presso.com/2009/06/wtp-m2eclipse-seam-cest-bien-maven/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 16:19:10 +0000</pubDate>
		<dc:creator>Antoine Sabot-Durand</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Outil]]></category>
		<category><![CDATA[Tutoriel]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[m2eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://www.next-presso.fr/?p=167</guid>
		<description><![CDATA[<p> Lucky me ! It&#8217;s only now that I need that one of my Seam project works with Eclipse WTP and Maven. Lucky because a few months ago, that tutorial would have been impossible to write. This article will show how to adapt a JEE5 project in order to make it usable with Eclipse WTP [...]]]></description>
			<content:encoded><![CDATA[<p>
Lucky me ! It&#8217;s only now that I need that one of my Seam project works with Eclipse WTP and Maven. Lucky because a few months ago, that tutorial would have been impossible to write. This article will show how to adapt a JEE5 project in order to make it usable with Eclipse WTP and Maven.
</p>
<p><span id="more-167"></span></p>
<h3>Starting the tutorial</h3>
<p>We start this tutorial with 3 Eclipse projects : an EAR, an EJB and a WAR project. These projects are showed in the following picture</p>
<p style="text-align: center;"><img class="size-full wp-image-204" title="figure1" src="http://www.next-presso.fr/wp-content/uploads/2009/06/figure1.png" alt="figure 1 : les trois projets sous Eclipse et WTP" width="235" height="168" /></p>
<p>
The 3 projects are linked with the Eclipse configuration files which contains informations about EAR, EJB and WAR projects. In this article the projects are based on JBoss Seam, but all the tutorial could be used in any project type.
</p>
<p>On the disk, the 3 projects are 3 directories in the workspace folders. Useless to say it&#8217;s not the Maven way to organize projects.</p>
<h4>Creation of the parent Project</h4>
<p>First step, we create a Maven parent project which will contain our EAR, EJB and WAR projects (that Maven call modules). In this parent project we can define global parameters for the modules. To create this project click on &#8220;File/New/Porject&#8230;&#8221;</p>
<p style="text-align: center;"><img class="size-medium wp-image-212 aligncenter" title="ChooseMavenProject" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-11-300x285.png" alt="ChooseMavenProject" width="300" height="285" /></p>
<p>Choose Maven Project in the Maven category and click on Next, this opens the &#8220;New Maven Project&#8221; wizard :</p>
<p style="text-align: center;"><img class="size-medium wp-image-213 aligncenter" title="New Maven Project 1" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-2-300x298.png" alt="New Maven Project 1" width="300" height="298" /></p>
<p>You can go to the next step after checking that &#8220;Create a simple project&#8221; is unchecked.</p>
<p style="text-align: center;"><img class="size-medium wp-image-214 aligncenter" title="Choose Archetype" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-3-300x254.png" alt="Choose Archetype" width="300" height="254" /></p>
<p>In this dialog box you have to choose an archetype (a template for your project). In Catalog choose Nexus Indexer which brings a richer list than the internal default one. In the filter field enter &#8220;pom&#8221; to reach the &#8220;pom-root&#8221; archetype&#8221;. Select it and click on &#8220;Next&#8221;.</p>
<p style="text-align: center;"><img class="alignnone size-medium wp-image-217" title="Maven Project Name" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-4-300x252.png" alt="Maven Project Name" width="300" height="252" /></p>
<p>In this last dialog box you choose the project name. click on &#8220;Finish&#8221;. Now you have a new project in your workspace. In my case it&#8217;s &#8220;pfm77-parent&#8221;</p>
<h4>Creating the Maven modules</h4>
<p>In the same way we created parent project, we&#8217;re going to create the children projects or modules. click on &#8220;File/New/Project&#8230;&#8221;</p>
<p style="text-align: center;"><img class="size-medium wp-image-211 aligncenter" title="Choose Maven Module" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-1-300x283.png" alt="Choose Maven Module" width="300" height="283" /></p>
<p>Choose &#8220;Maven Module&#8221; then click on &#8220;Next&#8221;. A new wizard opens :</p>
<p style="text-align: center;"><img class="size-medium wp-image-219 aligncenter" title="create ear module" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-5-300x204.png" alt="create ear module" width="300" height="204" /></p>
<p>Enter the name for the EAR module and the name of the parent project then click on &#8220;Next.</p>
<p style="text-align: center;"><img class="size-medium wp-image-220 aligncenter" title="Archetype EAR" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-6-300x253.png" alt="Archetype EAR" width="300" height="253" /></p>
<p>Don&#8217;t forget to choose &#8220;Nexus Indexer&#8221; in the catalog, enter &#8220;ear&#8221; in the filter field. Choose the &#8220;ear-jee5&#8243; archetype then click on &#8220;finish&#8221;</p>
<p>To create the EJB and WAR modules, we&#8217;ll use the same wizard choosing archetypes &#8220;ejb-jee5&#8243; and &#8220;webapp-jee5&#8243;.</p>
<p>After all those wizards and clicks, we have 4 new projects in the workspace :</p>
<p style="text-align: center;"><img class="size-medium wp-image-221 aligncenter" title="projets maven créés" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-7-300x285.png" alt="projets maven créés" width="300" height="285" /></p>
<p />
<p>The physical structure of these Eclipse projects are different. If you look on your disk, you&#8217;ll see a Maven hierarchy (a main project and modules in in the folder of the main project). It&#8217;s one of the m2eclipse benefits : supporting sub-projects in Eclipse. But it&#8217;s not the only advantage of the plugin.</p>
<h4>Benefits of m2eclipse</h4>
<h5>1) Managing sub-projects in Eclipse</h5>
<p>As we saw, you can have a Maven hierarchy that m2eclipse make look likes different Eclipse project in the IDE. This also works when you import existing maven project in the worskpace from the disk or versioning system.</p>
<h5>2) Managing Maven dependencies</h5>
<p>The plugin use the pom.xml files to download and add jar files in your project.</p>
<h5>3) Maven build in Eclipse</h5>
<p>The least we can wait for this plugin. A m2eclipse project has 2 builders : the standard Eclipse one and the maven one.</p>
<h5>4) A nice user interface to manage pom.xml files</h5>
<p>You can use this interface to look for dependencies or exclude a sub-dependency easily. It was rather bugy in the past but with version 0.99 of m2eclipse it starts to be very usefull.</p>
<h5>5) Automatic management of Eclipse projects configuration</h5>
<p>That&#8217;s an important benefit that is not very well documented on m2eclipse site. M2eclipse uses pom.xml information to generate and maintain Eclipse configuration files for the project. For instance the projects we just created are not Eclipse project. They were created from Maven Archetypes that have nothing to do with Eclipse. So the eclipse configuration files of these new project (.classpath, .project files and .settings folder) were generated by m2eclipse from the pom files. When pom files are modified, m2eclipse will change Eclipse configuration files automatically. For instance, let&#8217;s have a look at the Facets of the EJB project (right-click on the project, and choose properties/facets) :</p>
<p style="text-align: center;"><img class="size-full wp-image-222 aligncenter" title="project facets" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-9.png" alt="project facets" width="753" height="308" /></p>
<p>M2eclipse have added this EJB3 facets by analyzing the pom.xml file. So if you change Eclipse configuration on the project there can be some chance that you touch a configuration driven by m2eclipse. So take care of your modification. To be sure you won&#8217;t go battle wth m2eclipse in the configuration you should check the <a href="http://docs.codehaus.org/display/M2ECLIPSE/Integration+with+WTP" target="_blank">m2eclipse documentation</a>. This page show all the Maven parameters (with green checkboxes) that are used by m2eclipse to build and maintain Eclipse WTP configuration files.</p>
<p>To finish with this point, you&#8217;ll have to be extremely carrefull when you put those project under versioning system. The best solution is to ignore Eclipse configuration files and let m2eclipse do the job on the other systems (you&#8217;ll have to create local configuration on each IDE to configure information that are not in Maven files like deploying servers for instance).</p>
<h4>Copying Files</h4>
<p>Let&#8217;s go back to our tutorial : moving WTP projects to maven/WTP projects. The next step consist to copy files from our old WTP project to the newly created Maven/WTP projects. You can do this by dragging files from file system (Explorer, Finder, or whatever you use) to Eclipse using the &#8220;resources&#8221; perspective which is the more close to filesystem perspective. To keep it simple try to stick with the <a href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html" target="_blank">default Maven layout</a>, It will make pom files lighter.</p>
<ul>
<li style="list-style: none"></li>
<li>For the EAR module you&#8217;ll put  the content of META-INF in src/main/application/META-INF all the other files in te project will be  build from pom.xml</li>
<li>For the EJB module, all your classes should be put in src/main/java, resources files like properties or META-INF folder should be in src/main/resources.</li>
<li>For the WAR module you&#8217;ll use the same folders as EJB for classes and resources. The site files will be copied in src/main/webapp folder (be carefull and don&#8217;t take the WEB-INF/lib folder)</li>
</ul>
<p>
You should ignore Manifest files in all the project because they can cause runtime errors.</p>
<p>Now we have to deal with our pom files</p>
<h4>Pom pom pom pom</h4>
<p>It&#8217;s not a symphony but almost (sorry for that). The setting of our 4 pom.xml files will ask some patience (it&#8217;s the Maven feng-shui side) but we will get trough.</p>
<h4>Parent project</h4>
<p>I won&#8217;t detail all my pom.xml files content : I want to keep my readers till the end. Instead I&#8217;ll show you the result and comment the main part of each file</p>
<ul>
<li style="list-style: none"></li>
<li>Introduction : here I tell Maven that it is a pom project that drive construction of sub-projects (modules).</li>
<li>modules : here are the modules contained by this parent project.</li>
<li>properties : here I define variables that will be used in configuration of all the modules (libraries version for instance)</li>
<li>repositories : in this section I add Maven repositories used by my project. For me it&#8217;s JBoss repositories for Seam and java.net to get all Jee5 dependencies</li>
<li>dependencyManagement : In this part, I declare all the dependencies used by my modules. Declaring them here, I can set their version once for all.</li>
<li>build : in this final section I can set up compilation configuration once for all.</li>
</ul>
<p> </p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&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/maven-v4_0_0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;cos&lt;/groupId&gt;
  &lt;artifactId&gt;pfm77-parent&lt;/artifactId&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;pfm77-parent Multi Project&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  &lt;modules&gt;
    &lt;module&gt;pfm77-ear&lt;/module&gt;
    &lt;module&gt;pfm77-ejb&lt;/module&gt;
    &lt;module&gt;pfm77-war&lt;/module&gt;
  &lt;/modules&gt;

  &lt;properties&gt;
    &lt;seam.version&gt;2.0.3.CR1&lt;/seam.version&gt;
    &lt;jsf.version&gt;1.2_10&lt;/jsf.version&gt;
    &lt;richfaces.version&gt;3.2.1.GA&lt;/richfaces.version&gt;
  &lt;/properties&gt;

  &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;jboss&lt;/id&gt;
      &lt;name&gt;JBoss Repository&lt;/name&gt;
      &lt;url&gt;http://repository.jboss.org/maven2&lt;/url&gt;
      &lt;snapshots&gt;
        &lt;enabled&gt;false&lt;/enabled&gt;
      &lt;/snapshots&gt;
    &lt;/repository&gt;
    &lt;repository&gt;
      &lt;id&gt;jboss-snapshots&lt;/id&gt;
      &lt;name&gt;JBoss Snapshot Repository&lt;/name&gt;
      &lt;url&gt;http://snapshots.jboss.org/maven2&lt;/url&gt;
      &lt;releases&gt;
        &lt;enabled&gt;false&lt;/enabled&gt;
      &lt;/releases&gt;
      &lt;snapshots&gt;
        &lt;enabled&gt;true&lt;/enabled&gt;
      &lt;/snapshots&gt;
    &lt;/repository&gt;
    &lt;repository&gt;
          &lt;id&gt;java.net1&lt;/id&gt;
          &lt;name&gt;Java.Net Maven1 Repository, hosts the javaee-api dependency&lt;/name&gt;
          &lt;url&gt;http://download.java.net/maven/1&lt;/url&gt;
          &lt;layout&gt;legacy&lt;/layout&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;

 &lt;dependencyManagement&gt;
 &lt;dependencies&gt;

  &lt;dependency&gt;
      &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
      &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
      &lt;version&gt;1.8.0&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
       &lt;/dependency&gt;
        &lt;dependency&gt;
      &lt;groupId&gt;org.ostermiller&lt;/groupId&gt;
      &lt;artifactId&gt;utils&lt;/artifactId&gt;
      &lt;version&gt;1.07.00&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;/dependencies&gt;
 &lt;/dependencyManagement&gt;

  &lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
        &lt;configuration&gt;
          &lt;source&gt;1.5&lt;/source&gt;
          &lt;target&gt;1.5&lt;/target&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;

    &lt;/plugins&gt;
  &lt;/build&gt;

&lt;/project&gt;
</pre>
<p></p>
<h4>EAR project</h4>
<p>In the pom file, we can get rid of compilation plug-in because we configured it in the parent project. But we&#8217;ll have to add all the depending jars and their version. The m2eclipse auto-completion tools are very usefull for this. Right-click on the project and choose &#8220;Maven/add Maven dependency&#8221;. The following dialog box opens  </p>
<p style="text-align: center;"><img class="alignnone size-medium wp-image-252" title="Image 10" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-10-300x263.png" alt="Image 10" width="300" height="263" /></p>
<p>With this box you can search in Maven repositories the right jar and version for your project and add it the pom.xml file. With time some sub-depencies can appear in the project. You can exclude them by using the &#8220;Dependency graph&#8221; in pom editor. This view show a graph like this one : </p>
<p style="text-align: center;"><img class="size-full wp-image-253 aligncenter" title="dependency graph" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-111.png" alt="dependency graph" width="858" height="248" /></p>
<p>If yo want to exclude a jar you can do it via the context menu and choosing &#8220;Exclude Maven Artefact&#8230;&#8221; (wasn&#8217;t working in version 0.98 of m2eclipse). Now, back to our pom file of EAR module here are its content</p>
<ul>
<li>header : I specify that it&#8217;s an EAR module and I don&#8217;t forget to point to the Parent project</li>
<li>In the dependencies I don&#8217;t forget EJB and War modules</li>
<li>In the build section I add the Maven EAR plugin. In the configuration of the plugin I give the directory where to put the lib and ask Maven to generate my application.xml file</li>
<li>In the modules section of the plugin, I add my EJB and WAR modules that I defined at the beginning of the file as dependencies</li>
</ul>
<p></p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&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/maven-v4_0_0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;parent&gt;
    &lt;artifactId&gt;pfm77-parent&lt;/artifactId&gt;
    &lt;groupId&gt;cos&lt;/groupId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;/parent&gt;
  &lt;groupId&gt;cos&lt;/groupId&gt;
  &lt;artifactId&gt;pfm77-ear&lt;/artifactId&gt;
  &lt;packaging&gt;ear&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;pfm77-ear JEE5 Assembly&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;

  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;cos&lt;/groupId&gt;
      &lt;artifactId&gt;pfm77-ejb&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;type&gt;ejb&lt;/type&gt;
      &lt;scope&gt;compile&lt;/scope&gt;

    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;cos&lt;/groupId&gt;
      &lt;artifactId&gt;pfm77-war&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;type&gt;war&lt;/type&gt;
      &lt;scope&gt;compile&lt;/scope&gt;

    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.seam&lt;/groupId&gt;
      &lt;artifactId&gt;jboss-seam&lt;/artifactId&gt;
      &lt;version&gt;${seam.version}&lt;/version&gt;
      &lt;type&gt;ejb&lt;/type&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
      &lt;exclusions&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;javax.el&lt;/groupId&gt;
          &lt;artifactId&gt;el-api&lt;/artifactId&gt;
        &lt;/exclusion&gt;
        &lt;exclusion&gt;
          &lt;artifactId&gt;javassist&lt;/artifactId&gt;
          &lt;groupId&gt;javassist&lt;/groupId&gt;
        &lt;/exclusion&gt;
        &lt;exclusion&gt;
          &lt;artifactId&gt;dom4j&lt;/artifactId&gt;
          &lt;groupId&gt;dom4j&lt;/groupId&gt;
        &lt;/exclusion&gt;
      &lt;/exclusions&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.ostermiller&lt;/groupId&gt;
      &lt;artifactId&gt;utils&lt;/artifactId&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.richfaces.framework&lt;/groupId&gt;
      &lt;artifactId&gt;richfaces-api&lt;/artifactId&gt;
      &lt;version&gt;${richfaces.version}&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
      &lt;exclusions&gt;
        &lt;exclusion&gt;
          &lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
          &lt;groupId&gt;commons-collections&lt;/groupId&gt;
        &lt;/exclusion&gt;
        &lt;exclusion&gt;
          &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
          &lt;groupId&gt;commons-logging&lt;/groupId&gt;
        &lt;/exclusion&gt;
      &lt;/exclusions&gt;
    &lt;/dependency&gt;

  &lt;/dependencies&gt;

  &lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-ear-plugin&lt;/artifactId&gt;
        &lt;version&gt;2.3.2&lt;/version&gt;
        &lt;configuration&gt;
          &lt;version&gt;5&lt;/version&gt;
          &lt;defaultLibBundleDir&gt;lib&lt;/defaultLibBundleDir&gt;
          &lt;generateApplicationXml&gt;true&lt;/generateApplicationXml&gt;

          &lt;modules&gt;
            &lt;ejbModule&gt;
              &lt;groupId&gt;cos&lt;/groupId&gt;
              &lt;artifactId&gt;pfm77-ejb&lt;/artifactId&gt;
            &lt;/ejbModule&gt;
            &lt;ejbModule&gt;
              &lt;groupId&gt;org.jboss.seam&lt;/groupId&gt;
              &lt;artifactId&gt;jboss-seam&lt;/artifactId&gt;
            &lt;/ejbModule&gt;
            &lt;webModule&gt;
              &lt;groupId&gt;cos&lt;/groupId&gt;
              &lt;artifactId&gt;pfm77-war&lt;/artifactId&gt;
              &lt;contextRoot&gt;PFM77&lt;/contextRoot&gt;
            &lt;/webModule&gt;
          &lt;/modules&gt;

        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
    &lt;finalName&gt;pfm77-ear&lt;/finalName&gt;
  &lt;/build&gt;

&lt;/project&gt;
</pre>
<p></p>
<h4>EJB project</h4>
<p>Next step the EJB pom file. Not a lot of things to say about it except concerning the Maven EJB plugin which is used to set the EJB version.</p>
<p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&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/maven-v4_0_0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;parent&gt;
    &lt;artifactId&gt;pfm77-parent&lt;/artifactId&gt;
    &lt;groupId&gt;cos&lt;/groupId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;/parent&gt;
  &lt;groupId&gt;cos&lt;/groupId&gt;
  &lt;artifactId&gt;pfm77-ejb&lt;/artifactId&gt;
  &lt;packaging&gt;ejb&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;pfm77-ejb JEE5 EJB&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  &lt;dependencies&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;javaee&lt;/groupId&gt;
      &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
      &lt;version&gt;5&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;3.8.1&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.seam&lt;/groupId&gt;
      &lt;artifactId&gt;jboss-seam&lt;/artifactId&gt;
      &lt;version&gt;${seam.version}&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;

    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-annotations&lt;/artifactId&gt;
      &lt;version&gt;3.2.0.ga&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
      &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.ostermiller&lt;/groupId&gt;
      &lt;artifactId&gt;utils&lt;/artifactId&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
    	&lt;groupId&gt;mysql&lt;/groupId&gt;
    	&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
    	&lt;version&gt;5.1.6&lt;/version&gt;
    	&lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;

  &lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-ejb-plugin&lt;/artifactId&gt;
        &lt;version&gt;2.1&lt;/version&gt;
        &lt;configuration&gt;
          &lt;ejbVersion&gt;3.0&lt;/ejbVersion&gt;

        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
    &lt;finalName&gt;pfm77-ejb&lt;/finalName&gt;
  &lt;/build&gt;
&lt;/project&gt;
</pre>
<p></p>
<h4>WAR project</h4>
<p>Last but not least the WAR pom file. Notice that we&#8217;re not using Maven war plugin in this pom file, the default values of War packaging are enough.</p>
<p></p>
<p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&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/maven-v4_0_0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;parent&gt;
    &lt;artifactId&gt;pfm77-parent&lt;/artifactId&gt;
    &lt;groupId&gt;cos&lt;/groupId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;/parent&gt;
  &lt;groupId&gt;cos&lt;/groupId&gt;
  &lt;artifactId&gt;pfm77-war&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;pfm77-war JEE5 Webapp&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  &lt;dependencies&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
      &lt;version&gt;2.5&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
      &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
      &lt;version&gt;2.1&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;3.8.1&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.seam&lt;/groupId&gt;
      &lt;artifactId&gt;jboss-seam-ui&lt;/artifactId&gt;
      &lt;version&gt;${seam.version}&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
      &lt;exclusions&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;org.jboss.seam&lt;/groupId&gt;
          &lt;artifactId&gt;jboss-seam&lt;/artifactId&gt;
        &lt;/exclusion&gt;
      &lt;/exclusions&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.seam&lt;/groupId&gt;
      &lt;artifactId&gt;jboss-seam-debug&lt;/artifactId&gt;
      &lt;version&gt;${seam.version}&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
      &lt;exclusions&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;org.jboss.seam&lt;/groupId&gt;
          &lt;artifactId&gt;jboss-seam&lt;/artifactId&gt;
        &lt;/exclusion&gt;
      &lt;/exclusions&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.jboss.seam&lt;/groupId&gt;
      &lt;artifactId&gt;jboss-seam-pdf&lt;/artifactId&gt;
      &lt;version&gt;${seam.version}&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
      &lt;exclusions&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;org.jboss.seam&lt;/groupId&gt;
          &lt;artifactId&gt;jboss-seam&lt;/artifactId&gt;
        &lt;/exclusion&gt;
      &lt;/exclusions&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.richfaces.ui&lt;/groupId&gt;
      &lt;artifactId&gt;richfaces-ui&lt;/artifactId&gt;
      &lt;version&gt;${richfaces.version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.richfaces.framework&lt;/groupId&gt;
      &lt;artifactId&gt;richfaces-impl&lt;/artifactId&gt;
      &lt;version&gt;${richfaces.version}&lt;/version&gt;
      &lt;exclusions&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;commons-logging&lt;/groupId&gt;
          &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
        &lt;/exclusion&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;/exclusion&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;javax.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
        &lt;/exclusion&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;org.richfaces.framework&lt;/groupId&gt;
          &lt;artifactId&gt;richfaces-api&lt;/artifactId&gt;
        &lt;/exclusion&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
        &lt;/exclusion&gt;
        &lt;exclusion&gt;
          &lt;groupId&gt;javax.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
        &lt;/exclusion&gt;
      &lt;/exclusions&gt;
    &lt;/dependency&gt;

  &lt;/dependencies&gt;
  &lt;build&gt;

    &lt;finalName&gt;pfm77-war&lt;/finalName&gt;
  &lt;/build&gt;
&lt;/project&gt;
</pre>
<p></p>
<h4>Generating Eclipse configuration</h4>
<p>Now that we have our pom files, we&#8217;ll ask m2eclipse to refresh eclipse config files by accessing the &#8220;Maven/update configuration file&#8221; in the context menu of each project. Doing this refresh .classpath, .project files and .settings folder of our projects.</p>
<h4>First Maven build and first fix</h4>
<p>From the context menu of the parent project (not the EAR), choose &#8220;Run as&#8230;/Maven install&#8221; or &#8220;Maven package&#8221;. Maven is launched but the build fails. Don&#8217;t panic this issue is caused by a conflict in Maven resolution and Workspace resolution. Disable Worksapce resolution in the parent project by choosing  &#8220;Maven/Disable Workspace Resolution&#8221; in contextual menu of the parent project. Launch the build again and &#8220;voila&#8221;. You get an ear file in the target directory of the EAR project. In command line you&#8217;ll have to launch &#8220;mvn install&#8221; from parent project folder to have the same result.</p>
<h4>What about WTP ?</h4>
<p>Before using WTP to deploy your project you&#8217;ll have to copy the application.xml file from the target folder (of the EAR project) to the &#8220;src/main/application/META-INF&#8221; folder and do it again each time EAR modules change (which is not so often). And now ? Beleive it or not but it&#8217;s over and it works. In the server view choose your server (if you don&#8217;t have one you can create a &#8220;local deployer&#8221;). In the contextual menu choose &#8220;Add remove&#8230;&#8221; and add your project.</p>
<p style="text-align: center;"><img class="size-medium wp-image-254 aligncenter" title="Deployment" src="http://www.next-presso.fr/wp-content/uploads/2009/06/Image-12-293x300.png" alt="Deployment" width="293" height="300" /></p>
<p>Then click on &#8220;publih&#8221; and tadaaa, your project is deployed with WTP (if it&#8217;s not, you just have to restart all this tutorial over <img src='http://www.next-presso.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ). The only issue is a WEB-INF directory in the root of the EAR which contains a copy of the lib directory of the good WEB-INF directory of the war module. This problem should be harmless for a local deployment and is caused by this <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=247090" target="_blank">Eclipse bug</a>.</p>
<h4>Conclusion</h4>
<p>So m2eclipse is not working out of the box with WTP project. However it&#8217;s a powerfull tool even without this need. About Seam and Maven, JBoss is working on making developer life more simple. JBoss tools 3.1 should include extensions to <a href="https://jira.jboss.org/jira/browse/JBIDE-3874" target="_blank">ease the work with m2eclipse and Seam</a> and Seam 3.0 should be totally mavenized, so easier to be <a href="http://sfwk.org/Download/SeamDownloads#H-BuildingSeam3" target="_blank">build with Maven</a>.</p>
<p>We&#8217;ll keep an eye on it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.next-presso.com/2009/06/wtp-m2eclipse-seam-cest-bien-maven/feed/</wfw:commentRss>
		<slash:comments>14337</slash:comments>
		</item>
		<item>
		<title>Who&#8217;s @In ? who&#8217;s @Out ? Clarification on Seam bijection (part 1)</title>
		<link>http://www.next-presso.com/2008/10/whos-in-whos-out-clarification-on-seam-bijection/</link>
		<comments>http://www.next-presso.com/2008/10/whos-in-whos-out-clarification-on-seam-bijection/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 22:13:54 +0000</pubDate>
		<dc:creator>Antoine Sabot-Durand</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://www.next-presso.fr/?p=59</guid>
		<description><![CDATA[<p>After reading the article of Chiral Software about @Factory and @Unwrap Seam annotations, I found it could be useful to add some information on Seam bijection from my experience on the subject. One common mistake with Seam is to be too confident in its &#8220;magic&#8221;. One of the first traps you can fall in when [...]]]></description>
			<content:encoded><![CDATA[<p>After reading the article of <a href="http://chiralsoftware.com/jboss-seam-book/unwrap.seam" target="_blank">Chiral Software</a> about @Factory and @Unwrap Seam annotations, I found it could be useful to add some information on Seam bijection from my experience on the subject.<br />
<!--more--><br />
One common mistake with Seam is to be too confident in its &#8220;magic&#8221;.<br />
One of the first traps you can fall in when you start with Seam is about outjection.</p>
<p>See this code for instance :</p>
<p><code><br />
@Name("registerHdl")<br />
@Scope(ScopeType.CONVERSATION)<br />
public class RegisterHandler implements Serializable{</p>
<p>        @Out<br />
	private Registrant registrant=new Registrant();</p>
<p>        @Create<br />
        public void create()<br />
        {<br />
        }</p>
<p>}<br />
...</p>
<p>@Entity<br />
public class Registrant {</p>
<p>	private Long id;<br />
	private String firstName;<br />
	private String lastName;<br />
	private String email;<br />
	private String origine;</p>
<p>(getters and setters skiped)<br />
}<br />
</code></p>
<p>It defines a component in the conversation scope with a private field containing an entity which is outjected with &#8220;registrant&#8221; name.</p>
<p>Later we&#8217;ll want to use this variable in a view :</p>
<p>pages.xml :<br />
<code><br />
...</p>
<page view-id="/register.xhtml">
		<begin-conversation join="true" /></p>
<navigation>
			<rule if-outcome="ok"><br />
				<end-conversation /><br />
				<redirect view-id="/thanks.xhtml"></redirect><br />
			</rule><br />
		</navigation>
	</page>
...<br />
</code></p>
<p>register.xhtml :<br />
<code><br />
...<br />
<span class="inputLabel">Your  name : </span><br/><br />
<h:inputText id="Name" styleClass="inputShort" required="true"<br />
value="#{registrant.lastName}"/><br />
...<br />
</code></p>
<p>But it doesn&#8217;t work (an exception occurs when the form is submitted). We started a conversation in pages.xml and called the outjected &#8220;registrant&#8221; variable from registerHdl without any success.<br />
So what went wrong ?<br />
The problem is that the &#8220;registerHdl&#8221; component is never created and the call we made to &#8220;registrant&#8221; didn&#8217;t trigger this creation.<br />
To trigger this creation we could have called a method of registerHdl. We could have mapped the fields with #{registerHdl.registrant} in the view after having defined getter and setter for registrant in the component. But ther&#8217;s a better way.<br />
That&#8217;s here that @Factory start to be useful.</p>
<p><code><br />
@Name("registerHdl")<br />
@Scope(ScopeType.CONVERSATION)<br />
public class RegisterHandler implements Serializable{</p>
<p>	private Registrant registrant=new Registrant();</p>
<p>        @Factory<br />
	public Registrant getRegistrant() {<br />
		return registrant;<br />
	}</p>
<p>	public void setRegistrant(Registrant registrant) {<br />
		this.registrant = registrant;<br />
	}<br />
        @Create<br />
        public void create()<br />
        {<br />
        }</p>
<p>}<br />
</code></p>
<p>We deleted the @Out annotation and added a getter with the @Factory annotation.  This new configuration triggers  the creation of registerHdl component when we call #{registrant&#8230;} in our view.</p>
<p>To summarize @Out outjects a field as a context variable <strong>after</strong> the creation of the component and @Factory triggers if necessary the creation of the component to outject the return value of a method. @Out is only visible in the component life cycle and @Factory is visible in the whole application.<br />
But that&#8217;s not the only difference between @Factory and @Out as we&#8217;ll see in part 2 of this article.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.next-presso.com/2008/10/whos-in-whos-out-clarification-on-seam-bijection/feed/</wfw:commentRss>
		<slash:comments>14001</slash:comments>
		</item>
		<item>
		<title>How to use Hibernate filters in Seam</title>
		<link>http://www.next-presso.com/2008/10/how-to-use-hibernate-filters-in-seam/</link>
		<comments>http://www.next-presso.com/2008/10/how-to-use-hibernate-filters-in-seam/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 21:56:30 +0000</pubDate>
		<dc:creator>Antoine Sabot-Durand</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://www.next-presso.fr/?p=12</guid>
		<description><![CDATA[<p>JBoss Seam is very rich and powerful framework but some of its features are badly documented.</p> <p>Hibernate Filters is one of these forgotten features. In fact filters documentation in Seam is rather useless.</p> <p></p> <p>I won&#8217;t explain in details Hibernate Filters here. Hibernate documentation does it ways better. To make short it&#8217;s a smart solution [...]]]></description>
			<content:encoded><![CDATA[<p>JBoss Seam is very rich and powerful framework but some of its features are badly documented.</p>
<p>Hibernate Filters is one of these  forgotten features. In fact <a href="http://docs.jboss.org/seam/latest/reference/en-US/html/persistence.html#d0e6816" target="_blank">filters documentation in Seam</a> is rather useless.</p>
<p><span id="more-12"></span></p>
<p>I won&#8217;t explain in details Hibernate Filters here. Hibernate <a href="http://www.hibernate.org/hib_docs/v3/reference/en-US/html/filters.html" target="_blank">documentation</a> does it ways better. To make short it&#8217;s a smart solution to add conditions to the &#8220;where&#8221; clause of a request at runtime.</p>
<p>To create such a filter in Seam, one will also have to read <a href="http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html#entity-hibspec-filters" target="_blank">Hibernate annotations</a> on that matter.</p>
<p>For instance let say we have an used cars stock for which we had developed a bunch of forms and pages to search and navigate through it. We also created a Seam component to handle a requests collection to populate search form&#8217;s combo box fields and orchestrate all the search and navigation.</p>
<p>In database, cars have a &#8220;stockVoLib&#8221; field which gives car origin (demonstration, management car, etc&#8230;). Until now this field wasn&#8217;t used by the application and search were done on all the stock db. But now, our customer ask for a new navigation having exactly the same look at the first one but restricted on  a given car origin.</p>
<p>We can answer to this request in two different ways.</p>
<ul>
<li>Refactor all the running website&#8217;s engine to introduce the new &#8220;stcokVoLib&#8221; parameter in all the requests and code calling these requests</li>
<li>Create a filter which will save us a lot of refactoring work on existing code.</li>
</ul>
<p>Guess what ? I prefer to create a filter <img src='http://www.next-presso.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  (good news for the end of this post).</p>
<h3>1.Hibernate filter creation with annotations</h3>
<p>First thing to do : define the filter. We can dot it in the target entity or at the package level. As a filter can be applied to more than one entity I prefer the package level option. So I add a &#8220;package-info.java&#8221; file to my entities package to define the filter in it.</p>
<pre class="brush: java; title: ; notranslate">
@FilterDef(name = &quot;stockLib&quot;, defaultCondition = &quot;stockLibele = :aStockLib&quot;,
parameters = @ParamDef(name = &quot;aStockLib&quot;, type = &quot;string&quot;))

package org.fpp.domain;

import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.ParamDef;
</pre>
<p>The name of the filter is &#8220;stockLib&#8221;, it has a default condition which will be used if there is no condition defined when the filter is applied on the entity and it also has one string parameter : &#8220;aStockLib&#8221;.<br />
Keep in mind that the condition defined here is not a HQL &#8220;where&#8221; but a SQL one.</p>
<p>After that I apply the filter on one or more entities (I could also attach it to a collection). In my use case I only have one entity concerned : &#8220;usedCar&#8221;.</p>
<pre class="brush: java; title: ; notranslate">
@Entity
@Filter(name = &quot;stockLib&quot;)
public class usedCar {
...
</pre>
<h3>3.Using the filter with Hibernate</h3>
<p>Now, I can use the filter with Hibernate. I can activate it and send it parameter values  by getting Hibernate session (if we are using JPA we do that with EntityManager.getDelegate())</p>
<pre class="brush: java; title: ; notranslate">
Session session=(Session) entityManager.getDelegate();
session.enableFilter(&quot;stockLib&quot;).setParameter(&quot;aStockLib&quot;, &quot;VD&quot;);
...
session.disableFilter(&quot;stockLib&quot;);
</pre>
<h3>3.What about Seam ?</h3>
<p>You can do better with Seam by creating a filter component (wraping Hibernate filter) in which you can inject parameter at runtime.<br />
We only have to have this component in the Seam components.xml file.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;persistence:filter name=&quot;stockLibFilter&quot;&gt;
  &lt;persistence:name&gt;stockLib&lt;/persistence:name&gt;
  &lt;persistence:parameters&gt;
    &lt;key&gt;aStockLib&lt;/key&gt;
    &lt;value&gt;#{parameterHdl.stockLib}&lt;/value&gt;
  &lt;/persistence:parameters&gt;
&lt;/persistence:filter&gt;
</pre>
<p>Remember that parameters value in this &#8220;meta-filter&#8221;  should always be expressed in expression language even if we want inject a constant : #{&#8216;VD&#8217;}.<br />
In our example &#8220;parameterHdl&#8221; is a Seam component in which the stockLib parameter is injected from the URL according tto the the following configuration in pages.xml</p>
<pre class="brush: xml; title: ; notranslate">
&lt;param name=&quot;stockLib&quot; value=&quot;#{parameterHdl.stockLib}&quot; required=&quot;false&quot;/&gt;
</pre>
<p>At that point Seam filter can be injected in a specific EntityManager on which the filter will be always activated.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;persistence:managed-persistence-context name=&quot;emStockLib&quot; auto-create=&quot;true&quot; persistence-unit-jndi-name=&quot;java:/fppEntityManagerFactory&quot; &gt;
  &lt;persistence:filters&gt;
    &lt;value&gt;#{stockLibFilter}&lt;/value&gt;
  &lt;/persistence:filters&gt;
&lt;/persistence:managed-persistence-context&gt;
</pre>
<p>This new entityManager could be injected in components instead of the standard entityManager (without filter). There is nothing to do to activate the filter, it is on by default.<br />
<strong>But that&#8217;s not all !</strong></p>
<h3>4.Dynamic filters activation in Seam</h3>
<p>It&#8217;s here that Seam documentation is lacking something very useful : filters activation can be dynamically set at run time.</p>
<p>Thus we can write someting like :</p>
<pre class="brush: xml; title: ; notranslate">
&lt;persistence:filter name=&quot;stockLibFilter&quot; enabled=&quot;#{!(empty parameterHdl.stockLib)}&quot;&gt;
  &lt;persistence:name&gt;stockLib&lt;/persistence:name&gt;
  &lt;persistence:parameters&gt;
    &lt;key&gt;aStockLib&lt;/key&gt;
    &lt;value&gt;#{parameterHdl.stockLib}&lt;/value&gt;
  &lt;/persistence:parameters&gt;
&lt;/persistence:filter&gt;
</pre>
<p>Pay attention to the &#8220;enabled&#8221; parameter in which we put a boolean expression. It means that the filter is activated only if stockLib field of component parameterHdl is not empty. As this field is filled by URL parameter injection, an existing stockLib parameter in URL activate the filter.</p>
<p>In this usage we can apply the filter to the application&#8217;s main entityManager (no need to create a specific one) and this filter will be activated if its enabled parameter is satisfied. This test will be evaluated each time the entityManager is called (that&#8217;s Seam&#8217;s &#8220;magic&#8221;).</p>
<pre class="brush: xml; title: ; notranslate">
&lt;persistence:managed-persistence-context name=&quot;entityManager&quot; auto-create=&quot;true&quot; persistence-unit-jndi-name=&quot;java:/fppEntityManagerFactory&quot; &gt;
  &lt;persistence:filters&gt;
    &lt;value&gt;#{stockLibFilter}&lt;/value&gt;
  &lt;/persistence:filters&gt;
&lt;/persistence:managed-persistence-context&gt;
</pre>
<p>So we have injected a dynamically activated Hibernate filter in the entityManager and its activation will depend of the application context.<br />
One last thing to keep in mind : if the enabled parameter of the filter uses a Seam component (like in my example), you should not inject the &#8220;filtered&#8221; entityManager in this component. If you did you would get an exception at the application launch caused by the circular reference.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.next-presso.com/2008/10/how-to-use-hibernate-filters-in-seam/feed/</wfw:commentRss>
		<slash:comments>14923</slash:comments>
		</item>
		<item>
		<title>Bienvenue sur Next Presso</title>
		<link>http://www.next-presso.com/2008/10/bienvenue-sur-next-presso/</link>
		<comments>http://www.next-presso.com/2008/10/bienvenue-sur-next-presso/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 03:20:52 +0000</pubDate>
		<dc:creator>Antoine Sabot-Durand</dc:creator>
				<category><![CDATA[Général]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://www.next-presso.fr/?p=3</guid>
		<description><![CDATA[<p>Comme il faut un premier post le voici </p> <p>Cela fait un certain nombre d&#8217;années que je conçois des architectures applicatives et les développe. Aujourd&#8217;hui j&#8217;ai envie de partager un peu de mon expérience sur le sujet.</p> <p>Bon, de quoi va-t-on parler ici ?</p> <p>Tout d&#8217;abord d&#8217;outils et de frameworks issus du mode Java. J&#8217;ai [...]]]></description>
			<content:encoded><![CDATA[<p>Comme il faut un premier post le voici <img src='http://www.next-presso.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Cela fait un certain nombre d&#8217;années que je conçois des architectures applicatives et les développe. Aujourd&#8217;hui j&#8217;ai envie de partager un peu de mon expérience sur le sujet.</p>
<p>Bon, de quoi va-t-on parler ici ?</p>
<p>Tout d&#8217;abord d&#8217;outils et de frameworks issus du mode Java. J&#8217;ai un petit faible pour <a title="Site de Seam" href="http://www.seamframework.org/" target="_blank">Seam</a>, <a title="Site de Spring" href="http://www.springframework.org/" target="_blank">Spring</a> et <a title="Site d'Hibernate" href="http://www.hibernate.org/" target="_blank">Hibernate</a> donc je risque d&#8217;en parler un peu&#8230;</p>
<p>Je vais également aborder des problématiques concrètes pour mettre en œuvre des outils (IDE, software factories et autres serveurs d&#8217;application).</p>
<p>La méthodologie et l&#8217;architecture sont aussi des sujets qui m&#8217;intéressent et j&#8217;écrirai articles sur le sujet de temps en temps.</p>
<p>Enfin, de par sa nature historique pour moi, je ne pourrais pas passer à côté d&#8217;articles sur <a title="Developer works Domino" href="http://www.ibm.com/developerworks/lotus" target="_blank">Lotus domino</a> (si, si&#8230;) qui m&#8217;a longtemps accompagné, que j&#8217;ai essayé de semer mais qui revient de temps en temps dans mon activité.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.next-presso.com/2008/10/bienvenue-sur-next-presso/feed/</wfw:commentRss>
		<slash:comments>13041</slash:comments>
		</item>
	</channel>
</rss>

