2
votes

The deploy on save option of my EAR project is not working and I don't understand why. Here is my structure:

myproject-ear, packaging: EAR
--->myproject-core, packaging: JAR (ejbs)
--->myproject-web, packaging: WAR (.xhtml pages, some javascript and CSS)

I'm using maven and I have the war references the JAR as a provided dependency.

The thing is I have a Nexus repository to handle my JAR versioning, I do not develop with my JAR project open. But if I close my JAR project and then deploy the application the fast deployment simply stops working on glassfish (it doesn't even generate a gfdeploy on my EAR target folder, it instead copies all files to the glassfish directory).

Here are my (simplified) pom files:

Father project:

<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>myproject</name>

<modules>
    <module>myproject-web</module>
    <module>myproject-ear</module>
</modules>

EAR project (uses maven-ear-plugin):

<parent>
    <artifactId>myproject</artifactId>
    <groupId>mygroupid</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>

<artifactId>myproject-ear</artifactId>
<packaging>ear</packaging>

<name>myproject-ear</name>

<dependencies>
    <dependency>
        <groupId>mygroupid</groupId>
        <artifactId>myproject-core</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>ejb</type>
    </dependency>
    <dependency>
        <groupId>mygroupid</groupId>
        <artifactId>myproject-web</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>war</type>
    </dependency>
</dependencies>

WAR project (uses maven-war-plugin):

<parent>
    <artifactId>myproject</artifactId>
    <groupId>mygroupid</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>

<artifactId>myproject-web</artifactId>
<packaging>war</packaging>

<name>myproject-web</name>

<dependencies>
    <dependency>
        <groupId>mygroupid</groupId>
        <artifactId>myproject-core</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>ejb</type>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
2
What version of Netbeans? If you're using the development build, deploy on save has issues right now. Specifically, I've re-opened netbeans.org/bugzilla/show_bug.cgi?id=215976. - Alvin Thompson
Also, can you include the log file output for the build? - Alvin Thompson
@AlvinThompson I do am using Netbeans 7.2. It seems you are right and this bug is the problem I'm having. From the bug report it seems that it works on Netbeans 7.1.2. If you want to post it as an answer I can accept it until I have time to test it properly on Netbeans 7.1.2. - Hoffmann
Why such an old version? Netbeans 7.3 improved much of that stuff and 7.3.1 should add further refinements (including support for Jboss 7.1.1). The dev build (which will be 7.4 or 8) improves things even more--if you can live with the bugs. - Alvin Thompson
Glad to hear it helped. So what version did you move to? - Alvin Thompson

2 Answers

3
votes

It may be a bug with your version of Netbeans. Try Netbeans version 7.3 and see if it works there. The issue I mentioned says it works in 7.1.2 but I'd give 7.3 a shot first. The issue was reported resolved in 7.3 and only broke again for the 7.4/8 development builds.

1
votes

You are mixing lots of different magic (NetBeans, Maven, Nexus, and auto-deploy) and it's not surprising that it doesn't work exactly the way you would like. It's not clear (from an abstract tool developer's perspective) what the right thing to do is when you are trying to include in the deployment the latest version of a project under active development (that is, a project open in Netbeans) but that project is closed. Falling back to the version in the Nexus repository probably wasn't in the mind of the Netbeans developers who implemented auto-deploy.

My suggestion is to create another workspace where you do not include the JAR as a project but rather strictly treat it as a third-party library in the Maven and NetBeans configurations. Use this workspace except for when you need to work on the JAR.

Or else just leave the JAR project open.