Pinchy
Pinchy

Reputation: 1536

How Two different Maven Web project can share same EJB

I have two different Maven-Based JSF Web Projects (Netbeans and Glassfish) one for admin users and the other one is for regular users. I wanted to keep them separate because it is simpler this way. Entity classes will be the same and I want these two war projects share these entity classes.

What is the best way of doing this? I don't want users and admins share the same UI because it gets too complicated I want to keep their user interfaces separate it is much easier and clear for me.

Thanks a lot

Upvotes: 4

Views: 1056

Answers (1)

JScoobyCed
JScoobyCed

Reputation: 10413

I would suggest that you split both your projects into at least 4 maven projects:

  • common-ejb: maven project type 'EJB', keep all of your EJB/Entities there
  • customer-web: maven project type 'WAR', keep all your UI for the regular users, with dependency on 'common-ejb'
  • admin-web: maven project type 'WAR', keep all your UI for the admin users, with dependency on 'common-ejb'
  • common-ear: maven project type 'EAR', that includes 'common-ejb' as EJB dependency, and contains the 2 web projects (WAR).

The EAR pom.xml could look like:

<groupId>com.example</groupId>
<artifactId>example-ear</artifactId>
<version>1.0</version>
<packaging>ear</packaging>

<dependencies>

  <dependency>
    <groupId>com.example</groupId>
    <artifactId>example-ejb</artifactId>
    <version>${project.parent.version}</version>
    <type>ejb</type>
  </dependency>

  <dependency>
    <groupId>com.example</groupId>
    <artifactId>customer-web</artifactId>
    <version>${project.parent.version}</version>
   <type>war</type>
  </dependency>
  <dependency>
    <groupId>com.example</groupId>
    <artifactId>admin-web</artifactId>
    <version>${project.parent.version}</version>
   <type>war</type>
  </dependency>
<dependencies>

and look at the maven-ear-plugin doc if you need some customization of context-root or library deployment.

Upvotes: 6

Related Questions