How to cleanly stop m2e cargo:run from Eclipse?
Asked Answered
D

2

6

Using the run mojo from the cargo-maven2-plugin I would like to know of a better way to shut down the container.

The console output says Ctrl+C to stop, but that seems to do nothing.

If I terminate, it leaves an orphan java.exe process that I have to kill myself.

Am I doing something wrong? This is a little cumbersome.

Edit: I am usign Tomcat in a standalone config. If I use embedded Jetty, naturally terminate works, however we need Tomcat.

Disaffiliate answered 12/10, 2011 at 16:58 Comment(0)
C
5

The CTRL+C thing seems to be a known Eclipse/Jetty issue. The last post says that issuing mvn cargo:stop would stop an already running container, however it doesn't work for me—albeit, I've only made some quick test a with an archetype generated webapp.

Using Eclipse Indigo Service Release 1 (20110916-0149) if I issue mvn cargo:run and wait for the container to boot (for now it's Jetty, no configurations; let's see if you can get it working like this) clicking on the big red Terminate button kills the running process and no lingering java{,w}.exe are left behind.

I don't know how do you issue mvn cargo:run from Eclipse right now, but maybe you're using it as an External Tool (and that's why a process is left behind). If you have m2eclipse installed you should create Maven run configurations for it like this:

Run --> Run Configurations --> Maven build --> right click --> New

It should be straightforward from here on.

(I've found two Eclipse bug tickets (here and here) that seems to be related to Eclipse's inability to read a healthy CTRL+C via it's console.)


I've verified that when I'm starting an external Tomcat (7.0.23) instance with mvn cargo:run from Eclipse via the m2e plugin (after the container have started) CTRL+C indeed doesn't work.

After this I've ran mvn cargo:run from my Cygwin console. The result was the same.

Finally I've tried it from Windows's cmd and it worked.

My guess is that this is a bug in the cargo-maven-plugin.

Running mvn cargo:stop from either Eclipse or Cygwin did the trick for me.

You can run the cargo plugin from Eclipse by creating a Maven build Run or Debug configuration in Eclipse.

Coadjutant answered 4/12, 2011 at 7:45 Comment(6)
I am using the Maven build configuration. The difference I've noticed is that when you use Jetty, it is Embedded and I don't think I recall seeing a java.exe -- whereas if I use Tomcat, I used a non-embedded install (inside the target dir though which I think is default) and that is where the extra java.exe process comes from. The issue you linked does capture the problem in the context of clicking terminate. Maybe I'm wrong. I will take a look again when I return to work on Wednesday.Disaffiliate
I am going to award you this bounty if only because you are the only one who attempted to provide info and it is a good starting place. Thanks for your effort!Disaffiliate
@Doug I will take a look again when I return to work on Wednesday. I was waiting for just that. So, in the end it didn't worked I guess. I'll take a quick look (I have a Tomcat installation at home—where I'm at right now). Just a small remark: it doesn't look like an Eclipse issue at this point.Precocious
My experience is that you should always run cargo:run (or indeed any other Windows program that expects Ctrl-C) from cmd. There is more background on this thread comment on the mintty wiki: code.google.com/p/mintty/issues/detail?id=56#c14Hunley
How do you issue mvn cargo:run or mvn cargo:stop from Eclipse?Leatherjacket
Thanks for mentioning this bug appears from Cygwin on windows, but not the normal windows command windowMotherofpearl
S
0

In general if you run Cargo using an Eclipse Maven launcher in DEBUG mode (i.e. Debug as --> Maven build...), killing the process on the Eclipse console (the red button) doesn't leave any orphan process...

I don't know why, but it works :) At least on my workspace

Stretch answered 3/9, 2014 at 15:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.