Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven ear project with ejb module. error generating application.xml

when compiling the following pom, I get an exception stating that the core dependency is missing from the project:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.8:generate-application-xml (default-generate-application-xml) on project theear: Artifact[ejb:com.myapp:core] is not a dependency of the project. -> [Help 1]

theear is setup like so:

<project ...>
    ...

    <artifactId>theear</artifactId>
    <packaging>ear</packaging>

    <dependencies>
        <dependency>
            <groupId>com.myapp</groupId>
            <artifactId>web</artifactId>
            <version>${application.web.version}</version>
            <type>war</type>
            <scope>runtime</scope>
        </dependency>

        <!-- myapp projects -->
        <dependency>
            <groupId>com.myapp</groupId>
            <artifactId>core</artifactId>
        </dependency>

        ...
    </dependencies>

    <build>
        <finalName>theear</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <modules>
                        <webModule>
                            <groupId>com.myapp</groupId>
                            <artifactId>web</artifactId>
                            <contextRoot>/web</contextRoot>
                            <bundleFileName>web.war</bundleFileName>
                        </webModule>
                        <ejbModule>
                            <groupId>com.myapp</groupId>
                            <artifactId>core</artifactId>
                            <bundleFileName>core.jar</bundleFileName>
                        </ejbModule>
                    </modules>
                    <defaultLibBundleDir>lib/</defaultLibBundleDir>
                    <skinnyWars>true</skinnyWars>
                </configuration>
            </plugin>
            ...
        </plugins>
    </build>
</project>

And the core project like so:

<project ...>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>core</artifactId>
    <version>1.0.0.Pre-Alpha</version>
    <packaging>ejb</packaging>

    <dependencies>
        ...
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <ejbVersion>3.1</ejbVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

As you can see the ear clearly lists the core module as a dependency

NOTE: the version is missing as this pom declares an aggregate pom as it's parent with the corresponding dependencyManagement tags.

Any idea what may be the cause of this please?

like image 995
coderatchet Avatar asked Nov 10 '13 01:11

coderatchet


2 Answers

I came across this website, and the problem was that I did not include the <type>ejb</type> element when listing the core dependency.

the full dependency should look like this:

    <dependency>
        <groupId>com.myapp</groupId>
        <artifactId>core</artifactId>
        <version>1.0.0.Pre-Alpha</version>
        <type>ejb</type>
    </dependency>

I don't know why but maven complains about not having the version when you specify the type as ejb.

like image 68
coderatchet Avatar answered Nov 17 '22 03:11

coderatchet


Maven fails to build the Application.xml when adding an EJB module as dependency to an EAR application. The reason is that the dependency must be of type ejb. That happens when manually adding an EJB Module to an EAR app dependencies. It also happens if adding a WAR module to an EAR manually. war should be specified in the POM for each dependency.

like image 4
Justo Disla Avatar answered Nov 17 '22 01:11

Justo Disla