Search code examples
javaeclipsemavenweb-applicationsear

Ear project dynamic webapplication and maven


I have to create a dynamic webapplication. And I have to create an ear-file from it. I also want to use maven. What is the best way to do this in eclipse?

I found the "maven-archetype-j2ee-simple" archetype (Create complete EAR Project with Maven and Eclipse Helios). Can someone tell me what I have to put in which folder(controllers,test,jsp-sites,java classes) and how I create an ear-file.

If I run maven I get errors

 Child module */site of */pom.xml does not exist

I just need to delete <module>site</module> in the root pom.xml to get rid of this error but I dont even know what this one is doing. And why this archetyp got errors?

Kindly Regards!


Solution

  • There appears to be a bug in this archetype (it's quite old by the looks of the ejb module), you can delete the site module from the parent pom, I assume it was supposed to be a maven site.

    I would however suggest that you do not use this archetype.

    Create a war project from the maven-archetype-webapp, then create your own parent and your own ear project to package the war.

    The parent would look like this:

    <modules>
            <module>poc-war</module>
            <module>poc-ear</module>
    </modules>
    

    The ear pom would have a dependency on the war project and use the maven ear plugin to generate an ear:

    <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/maven-v4_0_0.xsd">
            <modelVersion>4.0.0</modelVersion>
    
            <parent>
                    <groupId>net.isban</groupId>
                    <artifactId>poc</artifactId>
                    <version>1.0-SNAPSHOT</version>
            </parent>
    
            <artifactId>poc-ear</artifactId>
            <packaging>ear</packaging>
    
            <description>EAR deployment </description>
            <name>FMIS EAR</name>
    
            <dependencies>
                    <dependency>
                            <groupId>net.isban</groupId>
                            <artifactId>poc-war</artifactId>
                            <version>${project.version}</version>
                            <type>war</type>
                    </dependency>
            </dependencies>
    
            <build>
                    <finalName>${project.artifactId}-${project.version}</finalName>
                    <plugins>
                            <plugin>
                                    <artifactId>maven-ear-plugin</artifactId>
                                    <version>2.10.1</version>
                                    <configuration>
                                            <skinnyWars>false</skinnyWars>
                                            <filtering>true</filtering>
                                            <modules>
                                                    <webModule>
                                                            <groupId>net.isban</groupId>
                                                            <artifactId>poc-war</artifactId>
                                                            <contextRoot>/poc</contextRoot>
                                                    </webModule>
                                            </modules>
                                    </configuration>
                            </plugin>
                    </plugins>
            </build>
    
    </project>