netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Unnecessary redeploys by "deploy on save"

Open banifou opened this issue 1 year ago • 8 comments

Apache NetBeans version

Apache NetBeans 23

What happened

Working and making changes on different files and jumping from one file to another one sometimes triggers a webapp redeploy even though when no file has been saved at all. This is a problem because Wildfly, Tomcat and Glassfish run out of PermGen after 10 or so redeploys. The webapp should only redeploy when changes has been saved. Or am I misunderstanding this feature?

Language / Project Type / NetBeans Component

Java maven project

How to reproduce

Reproduceable with any maven webapp.

Did this work correctly in an earlier version?

No / Don't know

Operating System

ubuntu 24.04

JDK

openjdk 17

Apache NetBeans packaging

Apache NetBeans Snap Package

Anything else

No response

Are you willing to submit a pull request?

No

banifou avatar Sep 26 '24 15:09 banifou

I cannot say anything regarding your actual problem, but are your servers really running with Java <= 7? Because PermGen has been removed in JDK 8.

JoachimRohde avatar Sep 27 '24 07:09 JoachimRohde

That's right, I meant "out of memory". "deploy on save" shouldn't redeploy until any changes has been saved. But not before.

banifou avatar Sep 27 '24 08:09 banifou

I am a bit surprised that this works at all, since javac itself doesn't even support the 1.7 target anymore.

(assuming thats not it) you are saying that:

  • you have deploy on save enabled
  • and things deploy without you saving anything?

just to check the obvious: you don't have periodic autosave enabled or "save files when focus is lost"? Since this sounds like you are one checkbox away from resolving this issue ;)

mbien avatar Oct 08 '24 22:10 mbien

Never seen such a checkbox like "save files when focus is lost" or periodic autosave ! This is what I have:

Bildschirmfoto vom 2024-10-10 00-48-24

banifou avatar Oct 09 '24 22:10 banifou

And under "Build -> Compile" the "compile on save" is checked.

banifou avatar Oct 09 '24 22:10 banifou

autosave is a global setting in options -> editor -> autosave which makes NB save files periodically or on focus loss events depends on how it is configured. (default has everything disabled)

project settings like deploy on save are simply hooking into any save event - auto saves included.

the only anomaly is "compile on save", this setting is fairly invasive and does more than simply triggering a build target, a scary dialog should show up if you enable it (at least in maven projects, can't remember if the dialog got added to ant projects - CoS was never implemented for gradle projects)

mbien avatar Oct 09 '24 23:10 mbien

Autosave and "Save files when focus is lost" are disabled.
When "compile on save" is uncheked than it disabled "deploy on save"! I'm not sure if it's enabled?

Bildschirmfoto vom 2024-10-10 11-13-52 By the way the link to "Learn more about Deploy.." is broken. Don't know where to report this.

The redeploy is somehow triggered by something else when jumping from one tab to another. More investigation is required.

banifou avatar Oct 10 '24 09:10 banifou

you are right. deploy-on-save does depend on compile-on-save. The dialog has a bug where it has DoC enabled by default without checking if CoS is toggled on. CoS is a fairly complex feature and wasn't very well maintained so we switched it off by default for new projects, the DoC checkbox was likely overlooked.

mbien avatar Oct 10 '24 10:10 mbien

Hi, any news or progress regarding this issue? Thanks

banifou22 avatar Dec 27 '24 16:12 banifou22

Hi @banifou22 and @banifou, now there are two of you ;)

I don't think anyone is working on this. Your best chance to improve this usecase is to try to get involved yourself and figure out why deploy-on-save runs so often.

The underlying compile-on-save mechanism sidelines the project build and lets NB directly compile to the output folder. This is the root cause for many other issues and essentially deprecated since no longer maintained (CoS itself is also fairly complex). Today, the project build tools like maven or gradle are responsible for all this, NB only interfaces with the tools, scans input and output etc.

Also keep in mind that the second part of the fix is to run your application on java versions which don't use permgen anymore. Since anything which reduces deployments would only mitigate the issue, you will run out of memory still, just later.

mbien avatar Dec 27 '24 17:12 mbien

I use JDK 17! It doesn't have permgen but still get "java.lang.OutOfMemoryError".

banifou avatar Feb 07 '25 16:02 banifou