This discussion is archived
13 Replies Latest reply: Oct 1, 2012 3:47 PM by IanTrimble RSS

Eclipse m2e-wtp integration with glassfish

964369 Newbie
Currently Being Moderated
first let me thanks for the great job. I work on a rather large project organized as follow:

-EAR is composed of

-EJB A1
-EJB A2
-WAR A3
....
-EJB C1
-EJB C2
-WAR C3

Developers usually only work on one or two projects. Say EJB A2 and WAR A3. The other dependencies are pulled from the nexus.

Now the problem is that I would like to test the whole thing (that is the ear). When deploying the ear on glassfish under eclipse I get the following error message:
"Expected to find an expanded directory for submodule {0} but found a JAR. If this is a directory deployment be sure to expand all submodules."

I tried to put <unpack>true</unpack> on all modules of the pom.xml but that did not solve the problem

This comes from the fact that the jars/wars that are not open projects are packed and not exploded. I asked the m2e-wtp team and they told me that this is probably related to the glassfish connector.


Have someone any idea on how to solve that? This is very problematic to us because we cannot ask the developers to have all projects open (or even in the workspace)

Many thanks in advance
  • 1. Re: Eclipse m2e-wtp integration with glassfish
    kosta Journeyer
    Currently Being Moderated
    A quick way to check if the issue is with m2e-wtp or the GF adapter is to try EAR export using Eclipse wizard (not Maven facilities). Could you give that a try and let us know if the result is a valid EAR that runs as expected, etc.

    File -> Export -> Java EE -> EAR file

    Thanks,

    - Konstantin
  • 2. Re: Eclipse m2e-wtp integration with glassfish
    964369 Newbie
    Currently Being Moderated
    Hello and thank you for the quick answer.

    I did an export the way you mentioned and the ear is correct. I do not really understand what this is proving but let me mention something that I forgot n my previous message:
    - If I check the "Use real jar archives for deployment" checkbox of the Glassfish adapter configuration page, it deploys but of course it is very slow and this is not really hot deploy.
    With the size of my project, this is not practicable.

    To sum up:

    If all the projects are present in the workspace then it works: It means that it deploys in exploded mode everything and that it works fine.
    If one project is absent or closed then this module is replaced by its jar/war version and then glassfish complains that I mix up the things.

    Many thanks in advance
  • 3. Re: Eclipse m2e-wtp integration with glassfish
    kosta Journeyer
    Currently Being Moderated
    I did an export the way you mentioned and the ear is correct.
    Could you confirm that when you did the export, your workspace was in the state described earlier (only some of the EAR's modules imported as projects, the rest pulled from the repository)?
    I do not really understand what this is proving
    Eclipse maintains a model for how to assemble your application. When you are using m2e-wtp, that plugin is maintaining this model. This model is then used during publish to an app server as well as by export EAR wizard. When users report publish problems, it could either be an issue with the assembly model or a bug in the publisher. Trying EAR export is a quick way to triage between those two possibilities.

    We will look into your scenario further and will update when we have more information. To set the expectations, m2e and m2e-wtp are not currently supported by Oracle for use in conjunction with OEPE, although we are presently evaluating adding that support. Input of users such as yourself will be valuable in that process.

    - Konstantin
  • 4. Re: Eclipse m2e-wtp integration with glassfish
    964369 Newbie
    Currently Being Moderated
    kosta wrote:
    I did an export the way you mentioned and the ear is correct.
    Could you confirm that when you did the export, your workspace was in the state described earlier (only some of the EAR's modules imported as projects, the rest pulled from the repository)?
    I do not really understand what this is proving
    Eclipse maintains a model for how to assemble your application. When you are using m2e-wtp, that plugin is maintaining this model. This model is then used during publish to an app server as well as by export EAR wizard. When users report publish problems, it could either be an issue with the assembly model or a bug in the publisher. Trying EAR export is a quick way to triage between those two possibilities.

    We will look into your scenario further and will update when we have more information. To set the expectations, m2e and m2e-wtp are not currently supported by Oracle for use in conjunction with OEPE, although we are presently evaluating adding that support. Input of users such as yourself will be valuable in that process.

    - Konstantin
    Hi Konstantin and thank you for you help.

    As I investigate the problem I was able to remove m2e and m2-wtp from the equation and I can still reproduce the problem.
    Furthermore, I did simplify the layout using a maven sample. Here is the example:

    Directory structure on filesystem:

    MavenEnterpriseApp
    - pom.xml

    - MavenEnterpriseApp-ear
    - pom.xml
    - src
    -main
    - application
    - META-INF
    application.xml
    - target

    - MavenEnterpriseApp-web
    - pom.xml
    - src
    - target


    1) mvn clean install in MavenEnterpriseApp (super pom)
    2) mvn eclipse:eclipse in MavenEnterpriseApp (super pom)
    3) import ear and war projects in eclipse (and only these) the rest is loaded from nexus.


    The ear's pom:
         <dependencies>
              <dependency>
                   <groupId>com.mycompany</groupId>
                   <artifactId>MavenEnterpriseApp-ejb</artifactId>
                   <version>1.0-SNAPSHOT</version>
                   <type>ejb</type>
              </dependency>
              <dependency>
                   <groupId>com.mycompany</groupId>
                   <artifactId>MavenEnterpriseApp-web</artifactId>
                   <version>1.0-SNAPSHOT</version>
                   <type>war</type>
              </dependency>
         </dependencies>

    The org.eclipse.wst.common.components generated by mvn eclipse:eclipse

    <?xml version="1.0" encoding="UTF-8"?>
    <project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="MavenEnterpriseApp-ear-1.0-SNAPSHOT">

    <wb-resource deploy-path="/" source-path="/target/m2e-wtp/ear-resources"/>
    <wb-resource deploy-path="/" source-path="/src/main/application" tag="defaultRootSource"/>

    <dependent-module archiveName="MavenEnterpriseApp-web-1.0-SNAPSHOT.war" deploy-path="/"
                        handle="module:/resource/MavenEnterpriseApp-web/MavenEnterpriseApp-web">
    <dependency-type>uses</dependency-type>
    </dependent-module>
    <dependent-module archiveName="MavenEnterpriseApp-ejb-1.0-SNAPSHOT.jar" deploy-path="/"
    handle="module:/classpath/var/M2_REPO/com/mycompany/MavenEnterpriseApp-ejb/1.0-SNAPSHOT/MavenEnterpriseApp-ejb-1.0-SNAPSHOT.jar">
    <dependency-type>uses</dependency-type>
    </dependent-module>
    </wb-module>
    </project-modules>

    finally the deployment looks like the following in the eclipseApps directory of my glassfish domain:

    MavenEnterpriseApp-ear
    - MavenEnterpriseApp-ejb-1.0-SNAPSHOT.jar
    - MavenEnterpriseApp-web-1.0-SNAPSHOT_war
    - index.jsp
    - WEB-INF
    - META-INF
    -application.xml

    At the end I get the following error message:.
    java.lang.IllegalArgumentException: Expected to find an expanded directory for submodule MavenEnterpriseApp-ejb-1.0-SNAPSHOT.jar but found a JAR.  If this is a directory deployment be sure to expand all submodules.

    I can provide a zip of the workspace if it can help.

    Thanks again for your time and help
  • 5. Re: Eclipse m2e-wtp integration with glassfish
    IanTrimble Newbie
    Currently Being Moderated
    You say that you have been told that the issue is "...probably related to the glassfish connector". Could you please clarify; what is this connector? An m2e connector for Glassfish? A Glassfish J2EE connector? Or are we referring to the Glassfish server adapter? I ask because I am trying to understand how you are deploying to Glassfish - are you invoking a maven plugin goal (or is an m2e connector doing this when triggered by a build), or are you publishing from Eclipse via the Glassfish server adapter?

    Thanks,
    - Ian
  • 6. Re: Eclipse m2e-wtp integration with glassfish
    IanTrimble Newbie
    Currently Being Moderated
    Could it be related to an older version of Glassfish? Please see http://netbeans.org/bugzilla/show_bug.cgi?id=199710

    - Ian
  • 7. Re: Eclipse m2e-wtp integration with glassfish
    964369 Newbie
    Currently Being Moderated
    I meant the glassfish adapter. As mentionned in my previous post I remove m2e-wtp and m2e from the equation and I still have the problem.
    I do "Add and remove" on the glassfish adapter and then I start the container.

    I am using glassfish 3.1.1
  • 8. Re: Eclipse m2e-wtp integration with glassfish
    965146 Newbie
    Currently Being Moderated
    Definitely not maven related. This is an issue with Glassfish itself not being able to cope with packed archived mixed with exploded projects.
    This is easily reproducible with the following setup :
    - have a web project in workspace
    - have an ear project in workspace containing an ejb jar
    - have an application.xml in the ear, referencing both web and ejb
    - deploy on glassfish 3.1.2
    - see it crash

    See http://screencast.com/t/rqyzT38Wo

    Curiously, without the application.xml (ear 6.0), the app deploys but the ejb is not started.


    Fred Bricon

    Edited by: user10516528 on Sep 28, 2012 1:20 PM

    Edited by: user10516528 on Sep 28, 2012 1:21 PM
  • 9. Re: Eclipse m2e-wtp integration with glassfish
    964369 Newbie
    Currently Being Moderated
    Now that it is clear that this is not related to m2e or m2e-wtp, should I create a new topic with a different title?
    In any case, I think that this issue is critical for large projects, with 50 different artefacts to generate you do no want to have all the projects open in eclipse.
    On the short term, for us the solution will be to migrate to another application server.

    Many thanks again for the help

    Steve
  • 10. Re: Eclipse m2e-wtp integration with glassfish
    965146 Newbie
    Currently Being Moderated
    @Ian @Konstantin I created https://bugs.eclipse.org/bugs/show_bug.cgi?id=390797 as a somewhat related issue in WTP
  • 11. Re: Eclipse m2e-wtp integration with glassfish
    IanTrimble Newbie
    Currently Being Moderated
    I'm not sure if it's a short-term solution, or even if it solves the issue (haven't tried it, myself), but have you tried deploying via the Glassfish maven plugin (http://maven-glassfish-plugin.java.net/)? Also, you may wish to look for ideas in the Glassfish forums (http://www.java.net/forums/glassfish).

    - Ian
  • 12. Re: Eclipse m2e-wtp integration with glassfish
    964369 Newbie
    Currently Being Moderated
    Thank you for the alternative (and your time) but we actually want to include many new developers in the project in a near future and we therefore need a smooth and straightforward solution.
    My goal is to reduce the steps that are required for the developers for deployment etc.

    I also seized a Jira issue: java.net/jira/browse/GLASSFISHPLUGINS-362 maybe it should be marked as duplicate with fred's one.

    If the solution is not too difficult to implement I am ready to help.

    Steve

    Edited by: 961366 on Oct 1, 2012 12:19 PM
  • 13. Re: Eclipse m2e-wtp integration with glassfish
    IanTrimble Newbie
    Currently Being Moderated
    Please don't mark the issues as duplicates, as they actually address different aspects. Fred is proposing new API in configuring "components" in WTP such that the Maven tooling could set an "unpack" flag and then server adapter implementers could do the right thing at deployment time. You have reported the core issue, which is not in WTP but either Glassfish itself or the Glassfish server adapter. Both issues are relevant and fixing one might mean first fixing the other.

    - Ian

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points