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.

Kohányi Róbert
  • 9,791
  • 4
  • 52
  • 81
Doug Moscrop
  • 4,479
  • 3
  • 26
  • 46

2 Answers2

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.

Kohányi Róbert
  • 9,791
  • 4
  • 52
  • 81
  • 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. – Doug Moscrop Dec 04 '11 at 17:19
  • 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! – Doug Moscrop Dec 08 '11 at 16:08
  • @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. – Kohányi Róbert Dec 08 '11 at 16:28
  • 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: https://code.google.com/p/mintty/issues/detail?id=56#c14 – artbristol Mar 13 '13 at 11:07
  • How do you issue `mvn cargo:run` or `mvn cargo:stop` from Eclipse? – Big McLargeHuge May 14 '15 at 17:20
  • Thanks for mentioning this bug appears from Cygwin on windows, but not the normal windows command window – Dave May 05 '16 at 13:27
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

Andrea
  • 2,714
  • 3
  • 27
  • 38