问题
I'm facing a weird problem and was not able to find somebody out there having the same behaviour creating a maven ear-ejb project in eclipse.
I have a parent pom that looks like this:
<modules>
<module>ear</module>
<module>ejb</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
the pom.xml from the ejb project:
<build>
<sourceDirectory>ejbModule</sourceDirectory>
<resources>
<resource>
<directory>ejbResources</directory>
</resource>
<resource>
<directory>ejbModule</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.4.RELEASE</version>
<scope>provided</scope>
</dependency>
</dependencies>
and finally the pom.xml of the ear project:
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<ejbModule>
<groupId>com.coba.test</groupId>
<artifactId>jms-test-ejb</artifactId>
<uri>jms-test-ejb.jar</uri>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.coba.test</groupId>
<artifactId>jms-test-ejb</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
</dependencies>
When running mvn eclipse:eclipse
on the projects I am able to import them as existing projects and all natures and references are ok. When I run mvn clean package
and deploy the ear to the server (tested on a websphere 8, jboss 7 and 8) the application (a single mdb) starts and acts as expected. BUT when I try to run the project from within eclipse no class from the shipped dependencies is found. When looking into the deployment assembly of the projects then (how it should be) all dependencies are listed in the ear project and the none of them appears in the ejb project. I had a look at the maven-eclipse-plugin and it does explicitly write the to deployed components to the ear project, so I think this is the way it should be. But when I manually add the classpath entries to the deployment assembly to the ejb project the application gets deployed and starts without any Problems.
Is this a Problem of my project setting or a maven-eclipse-plugin bug? Does anybody had this problem himself?
Thx for reading Markus
EDIT:
I dot not use the m2eclipse plugin.
来源:https://stackoverflow.com/questions/22837917/deployment-of-an-ejb-maven-project-from-eclipse