views:

2953

answers:

4

I'm having a hard time to make my Maven2 multi module project, with a deep project structure, appear as a single ear (with its dependencies - which includes 1 war, 2 ejbs and 1 jar) to be deployed in my JBOSS 5 server inside my Eclipse Ganymede (tab Servers).

I've been trying to use Maven Eclipse Plugin to turn my projects into a WTP project without success. Therefore they appear to be deployed in the server they appear as separated projets.

My project has 1 war, 2 ejbs and 1 jar that must be packaged inside an ear, each of the "subprojects" is a separate module.

Project's pom.xml (type pom):

...

<modules>
   <module>ejb1</module>
   <module>ejb2</module>
   <module>war</module>
   <module>jar</module>
   <module>ear</module>
</modules>

...

The ear module is only responsable to pack the other modules together.

Is there a way to tell eclipse (ganymede) that all those projects (ejbs, war and jar) are inside the ear module so I can deploy the ear in the server?

+2  A: 

What you want to do is have maven create the eclipse projects via mvn eclipse:eclipse This might be helpful.

sal
+2  A: 

try m2eclipse (google it) and install the WTP integration tool, create a project using the maven wizard, change the type to pom in the pom xml editor, create a sub modules from the pom and that adds it as child, if its a web project it get the WTP behavior i.e it can be deployed to a j2ee container ( jboss / tomcat ), add a dep to the web module for ejb module in the web pom etc, deploy the web app to the container

ssmithstone
+1  A: 

Installing the m2eclipse with the optional WTP configuration worked for me. I also added the following to my parent pom to ensure the right natures and builders in the eclipse files

This yields eclipse .project files that are ready for m2eclipse. then I can Update the project files using m2eclipse allowing hot deploy the webapp and its dependencies

<build>
  ...
        <plugin>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.5.1</version>
      <!--
      Eclipse project natures: http: //vikashazrati.wordpress.com/2007/12/22/adding-project-nature-to-your-maven-pomxml/
      Maven-eclipse-plugin: http: //maven.apache.org/plugins/maven-eclipse-plugin/
      -->
      <configuration>
      <additionalProjectnatures>
      <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
      <projectnature>org.eclipse.jem.workbench.JavaEMFNature</projectnature>
      <projectnature>org.eclipse.wst.common.modulecore.ModuleCoreNature</projectnature>
      <projectnature>org.eclipse.wst.common.project.facet.core.nature</projectnature>
      <projectnature>org.eclipse.jdt.core.javanature</projectnature>
      <projectnature>org.eclipse.wst.jsdt.core.jsNature</projectnature>
      <projectnature>org.maven.ide.eclipse.maven2Nature</projectnature>
      </additionalProjectnatures>
      <buildcommands>
       <buildcommand>org.eclipse.wst.jsdt.core.javascriptValidator</buildcommand>
       <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
       <buildcommand>org.eclipse.wst.common.project.facet.core.builder</buildcommand>
       <buildcommand>org.eclipse.wst.validation.validationbuilder</buildcommand>
       <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
          <buildcommand>org.maven.ide.eclipse.maven2Builder</buildcommand>

      </buildcommands>
      </configuration>

  </plugin>
Peter Kahn
+1  A: 

use -Dwtpversion=2.0 parameter of maven or on command line mvn -Dwtpversion=2.0 in super pom project. i use m2eclipse plugin but has got some issues for multi module project. I use m2eclipse plugin for dependency management. If i want to clean, install etc. all project with super pom, i do it on command line. Also project properties must check in eclipse. Project Facets, Java EE Module dependencies must check. You can also export to ear project, but be carefull to check maven modules is compiled after changing.

javaloper