質問

I got a simple maven project and yet frustratingly fail for hours to get it right. The project contains 1 parent module, and 2 submodules (one for ear-packaging, the other for an ejb). Building works successfully, but the ear-packing just doesn't work as expected:

<project>
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>at.betrieb.projekt</groupId>
        <artifactId>extended</artifactId>
        <version>1.0</version>
    </parent>
    <artifactId>extended-ear</artifactId>
    <packaging>ear</packaging>

    <dependencies>
        <dependency>
            <groupId>at.betrieb.projekt</groupId>
            <artifactId>extended-ejb</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <version>6</version>
                    <generateApplicationXml>false</generateApplicationXml>
                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                    <jarModule>
                        <groupId>at.betrieb.projekt</groupId>
                        <artifactId>extended-ejb</artifactId>
                        <bundleDir>/</bundleDir>
                    </jarModule>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Now when I look into the packaged folder I see this structure:

|-lib
   extended-ejb-1.0.jar
   activation-1.1.jar
   javaee-api-7.0.jar
   javax.mail-1.5.0.jar
|-META-INF
   application.xml

What I expected however was this structure:

|-extended-ejb-1.0.jar
|-lib
   activation-1.1.jar
   javaee-api-7.0.jar
   javax.mail-1.5.0.jar
|-META-INF
   application.xml

So basically I wanted the ejb outside of the other libraries. These other 3 libraries come from the ejb-module which requires the javaee-api dependency for annotations. Unfortunately it also collects transitive the javax.mail.jar, activation.jar.

Now I really don't know why the structure just doesn't work as expected, by all means I tried to follow this guide step by step.

役に立ちましたか?

解決

Ok, after I checked out a project from various maven archetypes I found the error... the minimal error... it's always a minimal error costing huge amounts of time...

In the dependencies section of the ear file, where I define my ejb as dependency, just add this:

<type>ejb</type>

so it's:

<dependency>
    <groupId>at.betrieb.projekt</groupId>
    <artifactId>extended-ejb</artifactId>
    <version>1.0</version>
    <type>ejb</type>
</dependency>

Afterwards it works correctly. Obviously it is wrong on the IBM page and on many other pages. Besides I found out the following section is also outdated, and can be completely removed from the ear-plugin section:

<jarModule>
     <groupId>at.betrieb.projekt</groupId>
     <artifactId>extended-ejb</artifactId>
     <bundleDir>/</bundleDir>
</jarModule>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top