Women in Technology

Hear us Roar



Article:
  Building J2EE Projects with Maven
Subject:   ejb-jar.xml inclusion?
Date:   2005-10-14 15:02:59
From:   vmassol
Response to: ejb-jar.xml inclusion?

Hi smcnamara,


Yes, this is a bug in the code for the article. I've fixed it in the SVN repository (http://brahe.discursive.com/svn/mdn/code/j2ee/maven-xpetstore-ejb-3.1.3/).


Basically the business/project.xml file was missing a <resource> tag to copy the xdoclet-generated resources to the EJB JAR (the ejb-jar.xml is generated):


<resources>
<resource>
<directory>
${maven.build.dir}/xdoclet/ejbdoclet/
</directory>
</resource>
</resources>


There was also the same error in the presentation/ subproject. Specifically the web.xml and taglibs generated by xdoclet were not included in the war. However, the problem is that the WAR plugin doesn't honor the <resource> tag... So the solution was to modify presentation/maven.xml as follows:


<preGoal name="java:compile">
<attainGoal name="xdoclet:webdoclet"/>


<!-- Hack because the WAR plugin does not honor
the <resources> tag (Note that the EJB
plugins does honor it!) -->
<ant:copy todir="${maven.war.webapp.dir}"
preservelastmodified="true">
<ant:fileset
dir="${maven.build.dir}/xdoclet/webdoclet/"/>
</ant:copy>


</preGoal>


Last, there were also issues in the EAR generation:


* The applications/petstore/project.properties was missing a property telling the EAR plugin to generate the application.xml deployment descriptor:


maven.ear.appxml.generate = true


* The applications/petstore/project.xml file was not marking the xpetstore-business dependency to be included in the EAR:


<dependency>
<groupId>xpetstore</groupId>
<artifactId>xpetstore-business</artifactId>
<version>${pom.currentVersion}</version>
<type>ejb</type>
<properties>
<ear.bundle>true</ear.bundle>
</properties>
</dependency>


Same for the xpetstore-presentation dependency:


<dependency>
<groupId>xpetstore</groupId>
<artifactId>xpetstore-presentation</artifactId>
<version>${pom.currentVersion}</version>
<type>war</type>
<properties>
<ear.bundle>true</ear.bundle>
<ear.appxml.war.context-root>/</ear.appxml.war.context-root>
</properties>
</dependency>


Sorry for all those bugs in the source code. I don't think the article has any problem but I had not finished the parts of the samples that were not explicitely covered by the article. They should all build now. However you should bear in mind that they'll probably not run as they haven't been tested at runtime. The idea was to write a second article for showing how to perform functional testing but I've not written it yet... :-)


Thanks
-Vincent