1
votes

Today I thought it was a good idea to convert my projects into Maven projects.

I have an EAR that contains 4 WARs and 3 EJB-modules. I followed IBM's tutorial about migrating an EAR project. I ended up converting all my wars/ejb-jars one by one, and finally the EAR. I also added the war to the EAR as dependencies in the EAR's pom.xml. But when I launch the mvn ear:ear command it throws me a warning like this one :

[WARNING] The POM for server-admin-connector:server-admin-connector:war:0.0.1-SNAPSHOT is missing, no dependency information available

Then, the build fails because of this error :

[ERROR] Failed to execute goal on project server-ear: Could not resolve dependencies for project server-ear:server-ear:ear:0.0.1-SNAPSHOT: The following artifacts could not be resolved: server-admin-connector:server-admin-connector:war:0.0.1-SNAPSHOT

I think IBM's article is not complete, but I couldn't find any other source about migrating a whole EAR project to Maven. Can anyone help me on this? How can I get rid of this error?

EDIT : I don't have a particular project structure in my workspace. Here are my projects, however :

/server-project/
               *server-ear (EAR)
               *server-admin-connector (WAR)
               *server-adminClient (JAR - stores the shared POJOs and interfaces for admin)
               *server-business-layer (EJB)
               *server-business-layerClient (JAR - stores the shared POJOs and interfaces for the business connector)
               *server-business-connector (WAR)

I started converting the non-EAR projects, with their required dependencies. Then I used the maven ear module to add them all in the ear's POM.xml. Eclipse didn't show me any errors when doing this, so I assumed the build part was OK.

Here's the EAR's pom.xml

<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>server-ear</groupId>
<artifactId>server-ear</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<name>server-ear</name>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.8</version>
            <configuration>
                <earSourceDirectory>EarContent</earSourceDirectory>
                <generateApplicationXml>true</generateApplicationXml>
                <applicationXml>${project.build.directory}/application.xml</applicationXml>
                <skinnyWars>true</skinnyWars>
                <version>7</version>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <modules>
                    <ejbModule>
                        <groupId>server-business-layer</groupId>
                        <artifactId>server-business-layer</artifactId>
                    </ejbModule>
                    <webModule>
                        <groupId>server-admin-connector</groupId>
                        <artifactId>server-admin-connector</artifactId>
                        <contextRoot>/admin</contextRoot>
                    </webModule>
                    <webModule>
                        <groupId>server-intern-rest-connector</groupId>
                        <artifactId>server-intern-rest-connector</artifactId>
                        <contextRoot>/api</contextRoot>
                    </webModule>
                </modules>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>server-admin-connector</groupId>
        <artifactId>server-admin-connector</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>server-business-layer</groupId>
        <artifactId>server-business-layer</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>ejb</type>
    </dependency>
    <dependency>
        <groupId>server-intern-rest-connector</groupId>
        <artifactId>server-intern-rest-connector</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>server-business-layerClient</groupId>
        <artifactId>server-business-layerClient</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>server-adminClient</groupId>
        <artifactId>server-adminClient</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>

1
Can you show your project structure where you war/ejb modules are located and where your EAR module is located etc. Apart from that calling maven via mvn ear:ear you are not calling the life cycle which is never a good idea...better is to go mvn clean package.khmarbaise
Thank you for your answer. I edited my post accordingly. I'm a total newbie on Maven, and I try to learn it. But Eclipse is not helping. I mean, it shows me no error at all when I add the projects to the POM.xml. And it seems to build correctly.mrik974
The best thing to check if a Maven build works is simply the command line and not eclipse.khmarbaise

1 Answers

2
votes

I found my problem. I wasn't installing every war/jar one by one. Don't forget to run the "mvn install" command on all WARs/JARs before trying to generate the EAR!

I don't know if I mark this as answer, or if i simply delete the question...