Configuring the jboss-ejb3-ejb subproject

We will generate an EAR file using the Maven project: jboss-ejb3, which includes the jboss-ejb3-ejb, jboss-ejb-web and jboss-ejb3-ear subproject/artifacts. We will use the Maven build tool to compile, package, and deploy the EAR application. The jboss-ejb3-ear module to be deployed to WildFly has two submodules: jboss-ejb3-web and jboss-ejb3-ejb.

The jboss-ejb3-ear, jboss-ejb3-web and jboss-ejb3-ejb modules may be referred to as ear, web, and ejb modules respectively. The ear module has dependency on the web module, and the web module has dependency on the ejb module, as shown in the following diagram:

Configuring the jboss-ejb3-ejb subproject

The ejb, web, and ear modules can be built and installed individually using subproject-specific pom.xml, or these can be built together using the pom.xml file in the jboss-ejb3 project. If built individually, the ejb module has to be built and installed before the web module, as the web module has a dependency on the ejb module. The ear module is to be built after the web and ejb modules have been built and installed. We will build and install the top level project using the pom.xml file in the jboss-ejb3 project, which has dependency specified on the jboss-ejb3-web and jboss-ejb3-ejb artifacts. The pom.xml file for the jboss-ejb3-ejb subproject specifies packaging as ejb. The WildFly 8.x provides most of the APIs required for an EJB 3.x application. The provided APIs are specified with scope set to provided in pom.xml. Dependencies for the EJB 3.1 API and the JPA 2.0 API are pre-specified. Add the following dependency for the Hibernate Annotations API:

<dependency>
  <groupId>org.jboss.spec.javax.ejb</groupId>
  <artifactId>jboss-ejb-api_3.1_spec</artifactId>
  <version>1.0.0.Final</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>org.hibernate.javax.persistence</groupId>
  <artifactId>hibernate-jpa-2.0-api</artifactId>
  <version>1.0.0.Final</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-annotations</artifactId>
  <version>3.5.6-Final</version>
</dependency>

The Hibernate Validator API dependency is also preconfigured in pom.xml. The build is preconfigured with the Maven EJB plugin, which is required to package the subproject into an EJB module. The EJB version in the Maven EJB plugin is 3.1:

<build>
  <finalName>${project.artifactId}</finalName>
  <plugins>
    <plugin>
      <artifactId>maven-ejb-plugin</artifactId>
      <version>${version.ejb.plugin}</version>
      <configuration>
        <!-- Tell Maven we are using EJB 3.1 -->
        <ejbVersion>3.1</ejbVersion>
      </configuration>
    </plugin>
  </plugins>
</build>

The Maven POM.xml file for the EJB subproject is available in the code downloaded for the chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset