Separated Maven JavaEE Application and Backend

I would like to create a Java EE application with fully separated FrontEndand BackEnd. I found several tutorials in which these two modules were packaged into a single EAR file. I could create this, and I could deploy my application to the application server.

For security reasons, now I need to deploy FrontEnd (Tomcat) and BackEnd (Weblogic).

What I have:

Front:

  • JSF Pages
  • Managedbeans

Back

  • Sessions with business logic (EJB)
  • The essence of classes.

The communication interface between the two layers will be RMIcalls.

The first solution, when I had one EAR project with these two modules, worked because my pom.xml package of the backEnd module was jar:

<packaging>jar</packaging>

, jar frontEnd, frontEnd .

backEnd, jar , . , backEnd ear pom.xml , ear build from backEnd, frontEnd, backEnd.

, . - , . , ear jar maven?

!

+6
4

, .. http://maven.apache.org/plugins/maven-ear-plugin/examples/skinny-wars.html

J2EE WAR EAR . WAR JAR WEB-INF/lib, EAR , WAR, - JAR. J2EE WARs JAR, EAR, Class-Path MANIFEST.MF.

+2

JSF, maven, , UI (css/js/*. jsf Backing Bean), , DemoProject-UI . .

JSF bean . seprate maven, DemoProject-Service. - , DemoProject-UI -. DemoProject-Service -, - Spring/DAO ..

, , seprate-, DemoProject-UI, (Tomcat), DemoProject-Model on (Weblogic). 2 seprate .

, -.

+1
  • - pom, . , .

    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com</groupId>
        <artifactId>practice</artifactId>
        <version>0.0.1</version>
    </parent>
    <groupId>com.xplanr</groupId>
    <artifactId>SheelBatchClient</artifactId>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.22.2</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.6.5</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.6.5</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jettison</groupId>
            <artifactId>jettison</artifactId>
            <version>1.3.8</version>
        </dependency>
    </dependencies>
    <description>Xplanr Batch Client</description>
    <name>xplanrBatchClient</name>
    
    <scm>
        <connection>scm:git:git//github.com/XplanrAnalyticsInc/XplanrMain.git</connection>
    </scm>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
    
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/utility/XplanrBatchClient/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <!-- here the phase you need -->
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/utility/XplanrBatchClient</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/utility/XplanrBatchClient</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                            <configuration>
                                <archive>
                                    <manifest>
                                        <addClasspath>true</addClasspath>
                                    </manifest>
                                </archive>
                            </configuration>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <format>{0,number}</format>
                    <items>
                        <item>buildNumber</item>
                    </items>
                    <doCheck>false</doCheck>
                    <doUpdate>false</doUpdate>
                    <revisionOnScmFailure>unknownbuild</revisionOnScmFailure>
                    <!-- <shortRevisionLength>5</shortRevisionLength> -->
                </configuration>
            </plugin>
    
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jarName>xplanrBatchClient</jarName>
                    <version>1.0.0</version>
                    <outputDirectory>${project.build.directory}/utility/XplanrBatchClient/lib</outputDirectory>
                    <archive>
                        <manifestEntries>
                            <implementation-version>${project.version}</implementation-version>
                            <implementation-build>${buildNumber}</implementation-build>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
    
        </plugins>
    </build>
    <version>1.0.0</version>
    

2. pom ,

<parent>
    <groupId>com</groupId>
    <artifactId>practice</artifactId>
    <version>0.0.1</version>
</parent>
<groupId>com.practice</groupId>
<artifactId>framework</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<name>DAG Maven Webapp</name>
<url>http://www.practiceanalytics.com/</url>
<repositories>
    <repository>
        <id>practice</id>
        <name>framework</name>
        <url>file://libs</url>
    </repository>
    <repository>
      <id>cloudera</id>
      <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
      <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>

</repositories>
<dependencies>


</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
                <execution>
                    <id>default-jar</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <classifier>client</classifier>
                        <finalName>udf-framework</finalName>
                        <includes>
                            <include>**/udf/*</include>
                        </includes>
                        <outputDirectory>${project.build.directory}/udf/lib</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <!-- <archiveClasses>true</archiveClasses>
                <webresources>
                    <resource>
                        <directory>src/main/resources</directory>
                        <targetpath>WEB-INF/classes</targetpath>
                        <filtering>true</filtering>
                    </resource>
                </webresources>
                <warName>${project.war.name}</warName>
                <warSourceExcludes>**/*.class</warSourceExcludes> -->
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
    <finalName>framework</finalName>
</build>
<description>Web Project for Practice Code</description>
+1

All Articles