How to deploy ear into WildFly 8.0 via eclipse IDE

1.3k views Asked by At

I have installed the JBoss AS tools in my eclipse. Then I have created an WildFly 8.0 server. I have parent project pom.xml like below:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company</groupId>
    <artifactId>trx-server-parent</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java-version>1.7</java-version>

        <javaee-api-version>7.0</javaee-api-version>
    </properties>

    <modules>
        <module>trx-server-ear</module>            
        <module>trx-server-domain</module>
        <module>trx-server-services</module>
        <module>trx-server-web</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>${javaee-api-version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <!-- compiler plugin -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.2</version>
                    <configuration>
                        <source>${java-version}</source>
                        <target>${java-version}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-ejb-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <ejbVersion>3.2</ejbVersion>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-ear-plugin</artifactId>
                    <version>2.9.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

And ear project pom.xml is like:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.company</groupId>
        <artifactId>trx-server-parent</artifactId>
        <version>1.0.0</version>
    </parent>
    <artifactId>trx-server-ear</artifactId>
    <packaging>ear</packaging>

    <dependencies> 
        <dependency>
            <groupId>com.company</groupId>
            <artifactId>trx-server-web</artifactId>
            <version>${project.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>com.company</groupId>
            <artifactId>trx-server-services</artifactId>
            <version>${project.version}</version>
            <type>ejb</type>
        </dependency>
    </dependencies>

    <build>
        <finalName>trx-server</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <configuration>
                    <finalName>trx-server</finalName>
                    <version>7</version>
                    <defaultJavaBundleDir>lib/</defaultJavaBundleDir>
                    <modules>                        
                        <webModule>
                            <groupId>com.company</groupId>
                            <artifactId>trx-server-web</artifactId>
                            <contextRoot>/trx-server-web</contextRoot>
                        </webModule>
                        <ejbModule>
                            <groupId>com.company</groupId>
                            <artifactId>trx-server-services</artifactId>
                        </ejbModule>
                    </modules>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I defined the trx-server-domain module as jar file and packaged into the lib folder. When run mvn clean install on my parent pom.xml, I got an ear file named trx-server.ear. Then the trx-server.ear file structure is like:

-- trx-server
   -- lib
      -- trx-server-domain-1.0.0.jar
   -- trx-server-services-1.0.0.jar
   -- trx-server-web-1.0.0.war

I can deploy this ear file to WildFly server manually (via web management page). Everything is fine for that.

My problem is when I deploy some changes via Eclipse, I mean via the server adapter. The root web contextRoot is not what I defined in the ear project pom.xml file. And the trx-server-domain will be deploy as EJB which should be a jar file under lib folder.

I got a trx-server-ear.ear folder in the WildFly deployments directory which is not what I wanted. The structures of this folder is:

trx-server-ear.ear
-- trx-server-domain-1.0.0.jar
-- trx-server-services-1.0.0.jar
-- trx-server-web-1.0.0.war

No lib folder and all jar/war files are in same level.

The problem only exist when I deploy the ear in the Eclipse. Is there any other plungin I should install?

Anyone could give me example of how to configure the ear with multiple modules?

0

There are 0 answers