Bug 176221 - Apply code changes after save does not work for web applications
Apply code changes after save does not work for web applications
Status: STARTED
Product: serverplugins
Classification: Unclassified
Component: Infrastructure
6.x
All All
: P3 (vote)
: 6.x
Assigned To: Petr Hejl
issues@serverplugins
:
: 225714 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-09 06:22 UTC by chandru_in
Modified: 2013-02-05 10:16 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
Patch adding listeningcp attribute to nbjpdaconnect task (6.23 KB, patch)
2009-11-12 04:35 UTC, Jan Lahoda
Details | Diff
Fixes to SourcePathProviderImpl needed to make nbjpdaconnect work for web.project (2.60 KB, patch)
2009-11-12 04:36 UTC, Jan Lahoda
Details | Diff
Changing the build-impl.xml to invoke nbjpdaconnect with the listeningcp attribute. (2.59 KB, patch)
2009-11-12 04:37 UTC, Jan Lahoda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description chandru_in 2009-11-09 06:22:03 UTC
Selecting "Apply code changes after save" in

Tools > Options > Miscellaneous > Java Debugger > General

Does not have any effect on web applications even though "Deploy on Save" is enabled for the project.  However, it works fine for normal Java applications.
Comment 1 Petr Jiricka 2009-11-09 06:35:56 UTC
Hi, which version of the IDE are you using, and which server? It would be great if you can provide step by step instructions on how to reproduce this. Thanks.
Comment 2 chandru_in 2009-11-09 06:52:03 UTC
IDE Version: 6.7.1
Server: Apache Tomcat 6.0.20

Steps:

1. Enable the above said option.
2. Create a new web application and ensure that its "Deploy on Save" option is enabled.
3. Add a servlet to this web application and make it print a message to response.
4. Debug the web application.
5. Now change the servlet to print a different message and save the file.
6. Try reloading the page in the browser.

Expected: The new message must be displayed.
Actual: The message old message is displayed.

Manually invoking "Apply Changes" changes the servlet output.
Comment 3 Martin Entlicher 2009-11-10 07:26:17 UTC
Reproduced.
Comment 4 Martin Entlicher 2009-11-10 07:55:57 UTC
In Java project, when debugger is run on a project which has CoS enabled, debugger is started from <NB-user-dir>/var/cache/executor-snippets/debug.xml, which defines "listeningcp" property. That property is used for listening to changes in source files. When CoS is not enabled, debugger is started from build-impl.xml of the project, which does not define "listeningcp" property.

Web debugger is started from build-impl.xml in both cases. What is the way to find out if the project have CoS enabled in web? Debugger needs to get "listeningcp" property in CoS.
Comment 5 Petr Hejl 2009-11-11 09:22:44 UTC
Happens only when server is stopped on breakpoint.
Comment 6 chandru_in 2009-11-11 10:13:55 UTC
I'm experiencing it even without adding any breakpoint.
Comment 7 Jan Lahoda 2009-11-12 04:35:02 UTC
Unfortunately, changing the nbjpdastart to include listeningcp is not enough - this task is not used when debugging Web Project - nbjpdaconnect is used. I will attach three patches make the auto-apply work when the Web Project is debugger. These patches are:
176221-debugger-nbjpdaconnect: enhances nbjpdaconnect task with listeningcp attribute, and duplicates some of the supporting logic used nbjpdastart. Note that this patch probably does not do proper cleanup after debugger stops, etc. Someone from debugger will probably need to look at it. The patch also forces setListeningcp(String cp) to ignore empty cp (cp.length() == 0).
176221-debugger-relative-path: adds two more changes: first, the elements on cp can be relative paths, so the first part of this patch resolves these relative paths (uses PropertyUtils from ant.project, but there may be a better way to do this in debugger). Second, the srcRootsToListenForArtifactsUpdates was re-initialized for each element on the listeningcp, which I assume is not correct, so I tried to fix that.
176221-web-project: adjusts build-impl.xml to include listeningcp in nbjpdaconnect. Does not change the invocation of nbjpdastart, as I do not know when this is used, but changing that should be simple.

With this patch, the automatic apply changes works for me when debugging project. I am however afraid that doing this change for 6.8 may be too risky.
Comment 8 Jan Lahoda 2009-11-12 04:35:55 UTC
Created attachment 90889 [details]
Patch adding listeningcp attribute to nbjpdaconnect task
Comment 9 Jan Lahoda 2009-11-12 04:36:38 UTC
Created attachment 90890 [details]
Fixes to SourcePathProviderImpl needed to make nbjpdaconnect work for web.project
Comment 10 Jan Lahoda 2009-11-12 04:37:20 UTC
Created attachment 90891 [details]
Changing the build-impl.xml to invoke nbjpdaconnect with the listeningcp attribute.
Comment 11 David Konecny 2009-11-12 18:47:12 UTC
re. nbjpdastart - I would expect that nbjpdastart is used in web project for debugging unit test.
Comment 12 Petr Hejl 2009-11-13 05:51:45 UTC
The issue is reproducible when the first action is debug (no previous run). I pushed a simple fix as web-main 9c0fdfd5c1c4.

With this fix the deploy on save should work for you (unless you stopped execution on breakpoint).

Can you please verify?

Thanks,
P.
Comment 13 Martin Entlicher 2009-11-13 07:57:42 UTC
I've added -init-cos to debug target directly in my build-impl.xml and it does not seem to have any effect on debugger's "Apply code changes". I'll check the patches from Jan Lahoda....
Comment 14 Petr Hejl 2009-11-13 08:17:12 UTC
It does not have any effect on "Apply code changes" it does Deploy on Save as it is done for "Run" and as it should be done for "Debug" (unless the app is stopped at breakpoint).
Comment 15 Martin Entlicher 2009-11-13 09:11:55 UTC
The patch looks fine.
However, Petr, can you please elaborate what exactly means "it does Deploy on Save unless the app is stopped at breakpoint"? I understand that when the server is suspended, NetBeans can not do deploy, but will it defer the deploy to some later time or abandon it?

It looks like we should pay attention not to apply code changes from debugger when web project is doing deploy. Debugger's apply code changes is much less reliable than your redeploy I guess, therefore it would be best if debugger is just notified that the redeploy has happened.
I other words now I think that when web project does deploy on save, debugger should not to try to apply the code changes at all IMHO.
Comment 16 Martin Entlicher 2009-11-13 09:18:01 UTC
Now I see that run-deploy target calls nbjpdaappreloaded. This seems to be exactly what we need. This should also solve bug #167353. Then we should likely disable Apply Code Changes.
Comment 17 Quality Engineering 2009-11-16 03:13:16 UTC
Integrated into 'main-golden', will be available in build *200911160201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/9c0fdfd5c1c4
User: phejl@netbeans.org
Log: #176221 Apply code changes after save does not work for web applications
Comment 18 raviparekh 2011-07-13 13:21:48 UTC
i also got 'apply code change' Disable
i'm using 7.0
Comment 19 raviparekh 2011-07-13 13:23:42 UTC
i also got 'apply code change' Disable
i'm using 7.0(In reply to comment #18)
> i also got 'apply code change' Disable
> i'm using 7.0

i'm also having Break point set in my code. but no 'apply code change'
Comment 20 Jiri Skrivanek 2013-02-05 10:16:12 UTC
*** Bug 225714 has been marked as a duplicate of this bug. ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo