CI Tools and Best Practices in the Cloud

Continuous Integration

Subscribe to Continuous Integration: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get Continuous Integration: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Continuous Integration Authors: Yeshim Deniz, Mehdi Daoudi, Elizabeth White, Liz McMillan, Pat Romanski

Related Topics: Java EE Journal, Apache Web Server Journal, XML Magazine, Eclipse Platform, Continuous Integration

J2EE Journal: Article

An Introduction to Maven - Part III

Application development management using Maven 2 and Eclipse

Packaging and Installing 'Connector' Artifacts
With the current implementation of the plug-in, the plug-in won't automatically create a separate JAR file for the module classes. If the JAR file for the current classes is created separately, there's an option to include the JAR in the final RAR file. Note that the packaging type for the current module is 'rar' and so no separate JAR file is created for the 'connector' classes. This means that we'll have to explicitly add a separate plug-in to create the JAR file. This is very simple to do just by adding 'maven-jar-plugin' to the POM file. Note that the JAR plug-in should be put before the RAR plug-in since the plug-ins are executed in the order they appear in the POM file. The plug-in configuration added to the POM file is in Listing 2.

Note that by default both plug-ins get executed during the 'package' phase of the Maven lifecycle. To deploy the 'connector' RAR artifact to the local repository, right-click on the module's POM file in Eclipse and then in the 'Run As' options, select 'Maven2 install.' Maven will execute the configured plug-ins to build both JAR and RAR files in the 'target' build directory and will copy over the primary artifact, the RAR file, to the local repository along with the POM information.

Attaching Additional Artifacts
Sometimes, you may have to deploy additional artifacts to the Maven repository. For example, in the case of 'connector' module, we can attach the JAR file as an artifact along with the primary RAR artifact. This is fairly easy to do by using 'build-helper-maven-plugin' from the 'org.codehaus.mojo' plug-in group. The snippet below shows the configuration for the plug-in to attach the JAR file as an additional artifact.


Please refer to the plug-in documentation at for additional information. After adding 'build-helper-maven-plugin' to the POM file, redeploy the 'connector' to the Maven repository and you should see the JAR file along with the RAR file deployed in the local repository as shown in Figure 7.

Setting Up an 'ejb' Module
We'll move on to create an 'ejb' module with a default Maven project. To do this, go to the 'EmployeeInfo' directory on the command prompt and execute the following Maven command:

mvn archetype:create -DgroupId=com.somecompany -DartifactId=ejb -Dversion=1.0

Refresh the 'EmployeeInfo' project in Eclipse and update the Maven source directories. Delete the sample Java class and its JUnit Test case. As in the case earlier, we'll use Maven's project inheritance model as described before and remove redundant version, group, and common dependency information from the 'ejb' POM file. Since this module will yield an EJB artifact, we'll change the packaging type to 'ejb' in the POM.

The 'ejb' module provides a stateless session bean that internally invokes the JCA connector to retrieve the Employee info XML object. This implies that the 'ejb' module will have dependencies on both 'xmlBinding' and 'connector' artifacts. However, since the 'connector' module already depends on the 'xmlBinding' module, it's sufficient to include dependency on the 'connector' artifact alone since Maven will transitively resolve dependencies and thereby transparently include dependency on the 'xmlBinding' artifact. Note that this module also needs compile-time EJB specification classes and classes from the J2EE connector specification as the Session bean refers to some of J2EE connector classes internally. We'll add dependencies on 'geronimo-spec-ejb-1.0-M1.jar' and 'geronimo-spec-j2ee-connector-1.0-M1.jar' with a scope value of 'provided.'

Finally, we'll add 'maven-ejb-plugin,' which gets executed during the 'package' phase and can build both the EJB JAR and EJB client JAR. Note that any client module that invokes an EJB can only include an EJB client JAR artifact as a dependency without dependency on the actual EJB JAR. This type of dependency inclusion will be shown later. Generating an EJB client JAR can be done by setting the 'generateClient' plug-in configuration element to true. Note that the contents of the EJB client JAR file can be customized using 'clientIncludes' and 'clientExcludes' plug-in configuration elements. By default, the plug-in excludes the following from the EJB client JAR.

  • **/*Bean.class
  • **/*CMP.class
  • **/*Session.class
  • **/package.html
The plug-in doesn't do any ejb-specific processing during the generation of the EJB JAR except for validating the existence of an ejb deployment descriptor if the ejb version is 2.0+. By default the plug-in assumes the 2.1 version. In EJB3, the 'ejb-jar.xml' deployment descriptor isn't required and in such cases, the exact version to be used can be specified using the 'ejbVersion' plug-in configuration element. For more information on 'maven-ejb-plugin' see the plug-in documentation at

The 'ejb-jar.xml' file and application server-specific EJB descriptor file should be put under the 'src/main/resources/META-INF' directory. The 'maven-ejb-plugin' by default picks them up from that location while building the EJB archive file. We'll add the necessary EJB source files for this module as shown in Figure 8. Please download and review the source code to understand the implementation.

The 'GetEmployeeInfoRemote' interface defines the business method 'getEmployeeInfo (String employeeId).' The 'GetEmployeeInfoBean' is the stateless session bean class that provides a concrete implementation for 'getEmployeeInfo' method as shown below.

public Employee getEmployeeInfo(String employeeId) throws Exception {
   Employee employee = null;
   try {
     ConnectionFactory connectionFactory = getConnectionFactory();
     Connection connection = connectionFactory.getConnection();
     RecordFactory recordFactory = connectionFactory.getRecordFactory();
     MappedRecord input = recordFactory.createMappedRecord("EmployeeInfoInput");
     input.put(EmployeeInfoCCIRecordFactory.EMPLOYEE_ID_INPUT, employeeId);
     MappedRecord output = recordFactory.createMappedRecord("EmployeeInfoOutput");
     Interaction interaction = connection.createInteraction();
     interaction.execute(null, input, output);
     employee = (Employee) output.get(EmployeeInfoCCIRecordFactory.EMPLOYEE_RESULT);
   } catch (Exception e) {
       throw e;
   return employee;

More Stories By Murali Kashaboina

Murali Kashaboina leads Enterprise Architecture at United Airlines, Inc. He has 15+ years of enterprise software development experience utilizing a broad range of technologies, including JEE, CORBA, Tuxedo, and Web services. Murali previously published articles in WLDJ and SilverStream Developer Center. He has master’s degree in mechanical engineering from the University of Dayton, Ohio.

More Stories By Geeth Narayanan

Geeth Narayanan is a senior architect at Ecommerce Technology, United Airlines, Inc. He has 10 years of experience in the IT industry, specializing in solutions using Java EE technologies. Geeth has master's degree in electrical engineering from the University of Toledo, Ohio.

Comments (6) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

Most Recent Comments
Aladin SOHAILI 10/06/07 04:38:08 PM EDT

Any link to download source files ?

Bob Arnold 09/11/07 02:34:39 PM EDT


"It's time to add connector implementation Java classes. The source files that we developed for the connector are shown in Figure 4.
Download and review the source files to understand the complete implementation."

Please specify the download link for the source code referred to.

vinny 09/04/07 08:40:13 AM EDT

Where is the link to download source files for connector EmployeeInfoCCIConnection??

Magne 09/04/07 03:25:58 AM EDT

It was with great interest I read these articles.
Article 3 refers to source files available for download.
Where can they be downloaded form?


Duty Editor 08/31/07 01:16:44 PM EDT

The Links to Parts I and II are to be found at the foot of the final page.

-Duty Editor

Jim 08/31/07 11:51:57 AM EDT

Next time you write part 3 of a three-part series, please include clickable links to the first two parts right there at the top.
Unless, of course, you want to keep the first two parts secret.