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.
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.
IDE Version: 6.7.1
Server: Apache Tomcat 6.0.20
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.
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.
Happens only when server is stopped on breakpoint.
I'm experiencing it even without adding any breakpoint.
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.
Created attachment 90889 [details]
Patch adding listeningcp attribute to nbjpdaconnect task
Created attachment 90890 [details]
Fixes to SourcePathProviderImpl needed to make nbjpdaconnect work for web.project
Created attachment 90891 [details]
Changing the build-impl.xml to invoke nbjpdaconnect with the listeningcp attribute.
re. nbjpdastart - I would expect that nbjpdastart is used in web project for debugging unit test.
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?
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....
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).
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.
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.
Integrated into 'main-golden', will be available in build *200911160201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Log: #176221 Apply code changes after save does not work for web applications
i also got 'apply code change' Disable
i'm using 7.0
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'
*** Bug 225714 has been marked as a duplicate of this bug. ***