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.
When a maven process is started(test project,...), you can stop it from within the NB(unlike in 6.0). NB shows that the process is stopped but it's still running in the background.
->maven
most probably a duplicate of http://jira.codehaus.org/browse/MEVENIDE-566
a jdk issue, still looking for workaround if any.. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4770092
*** Issue 149445 has been marked as a duplicate of this issue. ***
There seems to be a library for killing windows processes. https://winp.dev.java.net/ http://maven.dyndns.org/2/org/jvnet/winp/winp/1.5/ hudson.util.ProcessTreeKiller class in hudson makes use of it and it also provides ways of killing unix/solaris processes.
*** Issue 160270 has been marked as a duplicate of this issue. ***
the root cause of the problem seems to be in plexus-utils component in maven see http://jira.codehaus.org/browse/PLXUTILS-40 I've tried to write a -javaagent for the maven build that patches the org.codehaus.classworlds.Launcher class (main class of the build JVM) to spawn a Thread that just listens on a port and when the connection is established, kills itself (the build JVM) with System.exit(). That seems to exhibit the same behaviour as sending signals to the build jvm. The build jvm is shutdown, the shutdown hooks are run, but the forked test JVM keeps running. I suspect it's caused by the (IMHO dubious) execution of "sh -c cd <workdir>&& java -cp <cp> <mainclass>". that plexus-utils' CommandLineUtils wrap each execution request into.
*** Issue 145256 has been marked as a duplicate of this issue. ***
*** Issue 162878 has been marked as a duplicate of this issue. ***
This is high priority, as it leads to resource starvation and more important blows your head off when you try to debug client/server applications
A quick n dirty workaround I just made until this issue is solved. A custom maven goal and a tiny unix shell script to kill the instance. 1.put this in nbaction.xml, rename NewClass to your runnable class name. --------- <action> <actionName>CUSTOM-kill</actionName> <displayName>kill</displayName> <goals> <goal>process-classes</goal> <goal>org.codehaus.mojo:exec-maven-plugin:1.1:exec</goal> </goals> <properties> <exec.args>./jpkill NewClass</exec.args> <exec.executable>exec</exec.executable> <forkMode>once</forkMode> </properties> </action> ----------- 2.put this shell script in your project , make sure it's executable -------------------------- #!/bin/sh echo -n "Kill $1 $2... " NAME=`/usr/bin/jps -l | grep -i $1` if [ "$NAME" = "" ]; then echo "Proccess $1 not found" exit fi echo -n "$NAME..." PID=`echo $NAME | awk {'print $1'}` if [ "$PID" = "" ]; then echo "Pid not found" exit fi if [ $PID -lt 100 ]; then echo "$PID < 100. abort kill" exit fi kill $2 $PID && echo "..Done" --------------- now instead of stopping with in the regular way, right click on your project->custom->kill No guarantee etc.. Hope that helps.
uprooter: P4 has less priority than P3, you've actually decreased the priority of this issue.
*** Issue 166654 has been marked as a duplicate of this issue. ***
Milos, Any quick workaround for 6.7?
come on guys, please get this one fixed before 6.7 final otherwise all the great work done for maven integration will be overshadowed by this unfortunate issue. I noticed that when I run my maven project with debugger attached, the stop functionality works properly. I haven't looked into this further, but maybe that indicates that there is a way to get it working properly even without the debugger.
Sorry, the deadline for 6.7 is long passed. Right now I'm experimenting with calling maven build without the shell script/bat file, but directly. That should help with builds alone, but spawned processes (forked surefire and exec-maven-plugin) still don't work. other options include some platform specific means of killing.
I think Igor Minar is right. This problem foils the good maven integration in netbeans. As a workaround I use, as Igor, the debugger for running applications. But this costs time. In my opinion this issue should be fixed in a bugfix release.
Can we convert Maven project to usual NetBeans Java project?
Created attachment 83808 [details] experimental module capable of killing maven builds entirely
the attached experimental module is capable of kill the process trees on all supported platforms (I've tested on windows and linux), it will start working in development builds after a few relevant changed are added to base modules. the upcoming automated message will point out which build is the first one to support it. The work is based on Hudson's codebase that is killing the processes via the jna, winp and libpam4j libraries. It's searching all relevant processes for a magic environment variable that was passed to the root process and that was inherited by any spawned child process and it kills all such processes found. We will need some more testing before this ends up in standard build (please test on your setup if you can) And also we will need to go through license approval: 7D1238825F32E60EA09CE97071239434F3D68639 winp-1.10.jar - MIT license - https://winp.dev.java.net/ 2E07375E5CA3A452472F0E87FB33F243F7A5C08C libpam4j-1.1.jar - MIT license - https://libpam4j.dev.java.net/ EA85C7BB7773A46AABFDF60672EB335F8B5A5459 processtreekiller-1.0.jar - MIT license - http://kenai.com/projects/nb-process-killler A8762D07E76CFDE2395257A5DA47BA7C1DBD3DCE commons-io-1.4.jar - Apache License - http://commons.apache.org/io/ We should also consider to make the codebase part of some api (external execution probably the best place).
I agree. Once this is tested we should make it API. There is issue 138116. We should either close it as duplicate or use it for API tracking. This is important enhancement as there are many commands NetBeans is using these days, such as maven, grails, php...
Integrated into 'main-golden', will be available in build *200906200201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/f1c8347a993c User: Milos Kleint <mkleint@netbeans.org> Log: #135475 create new module that's capable of killing process trees, derived from hudson.core, using native libraries. Recognizes the child processes by inherited special environment variable that identifies the spawned child processes
*** Issue 167337 has been marked as a duplicate of this issue. ***
mkleint. can you please do something that it will be possible to install the module killer on 6.7 ? it complains about dependency modules too old.
uprooter: sorry, this won't work, there is code missing in the 6.7 version of maven modules that would call this new module's killing method.
these changesets push the experimental module into standard build (a bit reworked), since now the experimental module is not working anymore but it should work automatically. http://hg.netbeans.org/main/rev/7274fb0c27c2 http://hg.netbeans.org/main/rev/ef9832e4cb2c http://hg.netbeans.org/main/rev/7d5e585ed012 I consider the issue fixed for 6.8. Please verify in the first build containing the changes.
Integrated into 'main-golden', will be available in build *200907030200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/7d5e585ed012 User: Milos Kleint <mkleint@netbeans.org> Log: #138116, #135475 proper termination of external maven processes via extexecution api call.
*** Issue 169287 has been marked as a duplicate of this issue. ***
I still see this with 7.3 and 7.4. Running projects and then stopping them leaves the Java process in the background. NB thinks it's killed. When doing client/server based stuff this means I have to go kill my processes externally between every single run, and it gets a bit boring quite fast. I won't reopen this though, not my task to do that, could be that this bug is just a duplicate and the real work is done somewhere else.
This is definitely still occurring with Netbeans 7.4. Steps to reproduce: 1. Create a new Maven web application project. (File > New Project, Categories: Maven, Projects: Web Application) 2. Create a simple class to run, something like: class MyClass { public static void main(String[] args) throws InterruptedException { while (true) { Thread.sleep(1000); } } } 3. Run the file (Right click the file, select 'Run File' or press Shift+F6) 4. Inspect your running processes, you should see two java processes. 5. Stop the Maven build (Click the red square on the left hand side of the output window) 5. Inspect your running processes, you should see one java process running still. This is extremely annoying when you're working on something that needs to listen on a particular port or happens to use a lot of resources as subsequent runs will cause multiple instances of the application to run in the background. The work around I have found for this is to never simply 'run' the application, but always launch it via a debugging session. The stop button on the output window still does not work as expected but the "Finish Debugging Session" button in the toolbar or Shift+F5 will terminate both running java processes. Like the comment above, I'm not sure about the workflow for reopening something like this, so I'll defer to someone more experienced to make that call.
(In reply to ccomer from comment #30) > This is definitely still occurring with Netbeans 7.4. > > Steps to reproduce: > > 1. Create a new Maven web application project. (File > New Project, > Categories: Maven, Projects: Web Application) > 2. Create a simple class to run, something like: > > class MyClass { > public static void main(String[] args) throws InterruptedException { > while (true) { Thread.sleep(1000); } > } > } > > 3. Run the file (Right click the file, select 'Run File' or press Shift+F6) > 4. Inspect your running processes, you should see two java processes. > 5. Stop the Maven build (Click the red square on the left hand side of the > output window) > 5. Inspect your running processes, you should see one java process running > still. > > This is extremely annoying when you're working on something that needs to > listen on a particular port or happens to use a lot of resources as > subsequent runs will cause multiple instances of the application to run in > the background. > > The work around I have found for this is to never simply 'run' the > application, but always launch it via a debugging session. The stop button > on the output window still does not work as expected but the "Finish > Debugging Session" button in the toolbar or Shift+F5 will terminate both > running java processes. > > Like the comment above, I'm not sure about the workflow for reopening > something like this, so I'll defer to someone more experienced to make that > call. Quick clarification, when checking the running processes, be aware there may be several additional java processes depending on what you have running, and at least two for Netbeans. Make sure you account for that when checking what is running using ps, Activity Monitor, Process Monitor or your tool of choice. I used ps aux | grep '<project name>' and Activity Monitor on OSX 10.9
we can only reliably kill the maven JVM itself. Any other JVMs that maven spawns are outside of our capacity to kill as far as I can see. Definitely not supported by the JDK. AFAIK jenkins employs quite some tricks (including platform specific code/shell scripts) to get rid of such spawned grandchildren processes.
This bug still occur in netbeans 8.1 I have same pb when i use exec-maven-plugin and run it with netbeans. If i run maven command from terminal and press ctrl+c, all process are killed. Netbeans kill the process differently?
Spring boot has same problem see last comment of "wilkinsona" here : https://github.com/spring-projects/spring-boot/issues/4457
Should be fixed in dev version.