This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 165045 - redeployment on save fails for maven based web apps
Summary: redeployment on save fails for maven based web apps
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: Sun Solaris
: P2 blocker (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-13 11:39 UTC by japod
Modified: 2009-06-22 13:15 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
maven based helloworld web app (13.93 KB, application/octet-stream)
2009-05-13 11:40 UTC, japod
Details
ant based helloworld web app (21.71 KB, application/octet-stream)
2009-05-13 11:40 UTC, japod
Details

Note You need to log in before you can comment on or make changes to this bug.
Description japod 2009-05-13 11:39:16 UTC
Tried to take advantage of the [Compile On Save] option in project properties dialog.
In an ant based project, it allows me to update a java source, and instantly see the updated
application re-deployed on my GlassFish V2.1 instance. I have set the option
to [For both application and test execution] but still do not see the updates re-deployed.

I need to re-run the application to get the updates re-deployed, which is annoying
for incremental development as well as for demonstration purposes.

Will attach ant and maven based test applications, where after running them, you should see 
"hi there" string displayed with browser at both:

http://localhost:8080/HelloWorld/helloworld (ant)
http://localhost:8080/helloworld-webapp/helloworld (maven)

you can then try to change the String value returned 
from the HelloWorldResource.getClichedMessage() method from "hi there" to e.g. "hello there"
at line 14.

the content will get updated (after page refresh in the browser) only for the ant based web application
Comment 1 japod 2009-05-13 11:40:11 UTC
Created attachment 82035 [details]
maven based helloworld web app
Comment 2 japod 2009-05-13 11:40:45 UTC
Created attachment 82036 [details]
ant based helloworld web app
Comment 3 japod 2009-05-13 11:42:21 UTC
tried on NetBeans 6.7 daily build tagged as 20090512001, solaris_x86 nevada
Comment 4 Milos Kleint 2009-05-14 09:54:51 UTC
it seems the class gets compiled after change, but doesn't end up in the expanded web application.
When checking ant based project, I've noticed these compile directly into the expanded webapp space, while maven
projects comile to target/classes and only afterwards assemble the expanded web app in the next build steps. The
automated java Compile on Save infrastructure then saves the class files outside of the expanded webapp.

Comment 5 Milos Kleint 2009-05-15 08:51:41 UTC
thanks to greaqt help by phejl we've managed to add code that copies the class files from target/classes to the expanded
web application

http://hg.netbeans.org/main/rev/0f0ac1d94478
Comment 6 Quality Engineering 2009-05-16 08:56:41 UTC
Integrated into 'main-golden', will be available in build *200905160201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/0f0ac1d94478
User: Milos Kleint <mkleint@netbeans.org>
Log: #165045 deploy on save in maven projects needs to copy class files from target/classes into the expanded webapplication
Comment 7 japod 2009-05-18 12:54:52 UTC
Verified at the nightly build from 090518, where it works fine with GFv2
Thank you a lot for the fast response and fix.
Great job!
Comment 8 japod 2009-05-19 09:50:09 UTC
One more (and hopefully the last one) thing missing at this feature is auto-adding any newly created classed
to the auto-redeployed web application. This works perfectly for the ant based scenario.

How to reproduce:

add a new class called "Gaga":

--cuthere--
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Gaga {
 public String gaga="gaga";
}
--cuthere--

then change the existing class HelloWorldResource to:

--cuthere--
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.Path;

@Path("/helloworld")
public class HelloWorldResource {

    @GET
    @Produces("application/xml")
    public Gaga  getClichedMessage() {
        return new Gaga();
    }
}
--cuthere--

then you should see an xml displayed at the browser (http://localhost:8080/HelloWorld/helloworld for the ant based app)

for the maven based test case, you will end up with no class def found exception (nb just crashed, when i wanted to
copy&paste the exact message text)



Comment 9 Milos Kleint 2009-05-19 12:49:24 UTC
http://hg.netbeans.org/main/rev/c5788b72273c issue with FileObject conversion. FileObjects don't exist for missing files.
Comment 10 Quality Engineering 2009-05-20 07:30:05 UTC
Integrated into 'main-golden', will be available in build *200905200201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/c5788b72273c
User: Milos Kleint <mkleint@netbeans.org>
Log: #165045 when destination file doesn't exist (conversion to FileObject fails), we create it.
Comment 11 Jaroslav Pospisil 2009-06-22 13:15:05 UTC
v.