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.

Bug 241321 - Server not being shut down properly, spring boot?
Summary: Server not being shut down properly, spring boot?
Status: REOPENED
Alias: None
Product: javaee
Classification: Unclassified
Component: Web Project (show other bugs)
Version: 8.0
Hardware: PC Mac OS X
: P3 normal with 3 votes (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-03 11:07 UTC by kimsp
Modified: 2016-07-29 19:17 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Run action configuration for running spring-boot maven plugin in netbeans (332.63 KB, image/png)
2014-12-20 14:03 UTC, lintech
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kimsp 2014-02-03 11:07:49 UTC
Hi,

I have followed this guide:
http://projects.spring.io/spring-boot/#quick-start

When I run (using run file) the main class sprint boot fires up as expected (among other things it starts a Tomcat server in the background). That is I can access the URL and the netbeans console shows me the same as if I had run the program from the command line. 

However, when I stop the program, using the red box with the white dot in it (Stop the currently executing build), NetBeans does not stop the Tomcat server that Spring boot has started in the background. If I terminate the program from a command line the tomcat server is killed. 

The program with not killing the tomcat process is that the next execution of the file will tell me that the port is taken which is very annoying, because there is no other way to see the tomcat process from within netbeans.

Best regards
Kim
Comment 1 Martin Janicek 2014-02-04 14:21:51 UTC
Hi Kim, could you please share with me few additional information? What kind of project (Maven or Ant) are you creating? What version of Tomcat you used?

Ideally please try to find few simple steps that leads to reproduction of the problem.

I tried to use Tomcat 7.0.14 in combination with both Ant Web and Maven War projects and did something like this:

1. Create project with Tomcat 7 selected as app. server
2. Debug application (it started server and show index page in the browser automatically)
3. Stop debugging (using the red box with the white dot as you described ;))
4. Debug application again (it correctly start-up the application again and show index in the browser)

Could you correct me, what I'm doing differently than you? Thanks in advance!
Comment 2 kimsp 2014-02-04 18:40:43 UTC
Hi Martin,

I just created a java maven application (from the maven menu) - note not a Web project -  and followed the spring boot documentation. I did Not configure a tomcat server in netbeans (spring boot grabs a tomcat and manages it all, but I think it is version 7 something).

The whole point of spring boot is that it makes it easy to run spring apps. Hence it starts and stops tomcat, or what other server you choose but tomcat is default.

Having created the pom and java controller described in the Quick guide, see link in first comment, I then ran the file as also described in comment one and experienced what I have described.

Please tell me if you need more info, I work with my computer tomorrow so I will be able to assist.

Regeres Kim
Comment 3 kimsp 2014-02-17 18:58:31 UTC
I have tested with build 201402160001 and jdk 8 and latest spring boot (CR2) and the bug is still there.
Comment 4 Martin Janicek 2014-02-18 13:31:11 UTC
Hi Kim,

please do not raise priority of issue without appropriate reasoning. This is not a P2 issue with respect to the NetBeans priority guidelines [1].

I was partially able to reproduce your problem with following steps:

1/ Create simple project (jar packaging) as you described
2/ Paste pom configuration from Spring boot quick start page
3/ Create SampleController as described in quick start page
4/ Run the project

--> Now if I stop the project, everything is fine and the Tomcat is shutdown by Spring boot and I can modify sources and run the project again without any issue

5/ Turn off IDE (note that project was still running when the IDE was turned off)
6/ Turn the IDE on again
7/ Try to run project
8/ Server is occupied

The problem here is actually the fact that Spring boot is taking care of starting up and shutting down of the server. Because of that NetBeans can't really control what's going on with Tomcat server and if user don't manually stop running application Spring boot server shutdown is not called.

The workaround here is to stop running application before exiting NetBeans. One way how we could theoretically resolve this issue would be to run the same shutdown when the IDE is turned off as we are doing when user click to stop the application run manually.

BTW: This does not have anything in common with Web Projects, even the example project is not a EE project. But since we officially don't support Spring boot, I'm not sure where this issue belong too (it's not about Spring, it's not about Maven or Ant).

[1] http://wiki.netbeans.org/BugPriorityGuidelines
Comment 5 lintech 2014-12-20 14:03:01 UTC
Created attachment 151222 [details]
Run action configuration for running spring-boot maven plugin in netbeans

This screen shot shows how to configure the "Run" action to successfully run spring-boot maven plugin from within netbeans.
Comment 6 lintech 2014-12-20 14:08:43 UTC
I had the same problem. I could start the spring-boot maven project inside netbeans but when I killed the build it did not shutdown the embedded tomcat server.

I managed to change the "Run" action for my project to only execute the spring-boot maven plugin e.g. "spring-boot:run".

This is all you need in your "Run" action to successfully start the spring-boot app. Now when you click the red button to stop the process, it actually stops the embedded tomcat container too.
Comment 7 adv 2014-12-24 01:23:22 UTC
Hi,

I have the same problem. If I run the SpringBoot main class using the netbeans run context menu, the project start normally. When I hit the red square button on the console window, the projects stop except the embedded Tomcat. To stop it I need to kill the process and after that I can run the project again.

Thanks!

Anderon Vaz
Comment 8 cknoll 2015-01-23 05:08:19 UTC
Having same problem:  launching web project with a few REST services configured worked fine until we introduced springboot.  I have not yet tried configuring the run button to use the spring-boot goal, but wanted to know if there was any special configuration required to launch the debugger?  Before it was just a matter of rightclick on project and debug, and everything launched, now i'm wondering if springboot need additional actions..
Comment 9 rptmaestro 2015-04-02 18:36:45 UTC
I am also seeing this issue since switching to Mac OS X without closing my IDE. I did not see this issue a month ago when I was using Windows and Linux with the same versions of Maven, NetBeans, and Spring Boot and I do not see this issue when I use IntelliJ.

When I run through the debugger, it will shut down properly if I use the red button from the "Debug" toolbar (i.e. "Finish Debugger Session"). But if I use the red button from the process output window it doesn't die properly. It has nothing to do with shutting down the IDE. This happens within the same IDE session.

My workaround solution is to set my "server.port" to 0 so my Spring Boot application will always pick a new port.

When I am ready to clean up the abandoned processes, I run `jps -l` from the terminal and kill them manually.

I have defined my run configurations exactly the same in IntelliJ. I have both NetBeans and IntelliJ using `mvn spring-boot:run`. IntelliJ properly shuts down my application, but NetBeans doesn't. I prefer the NetBeans development environment, but sometimes I confess I go to IntelliJ because I just don't want the hassle of having to manually kill my applications.
Comment 10 Martin Balin 2016-07-07 08:56:04 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 11 mcheung63 2016-07-29 19:17:45 UTC
this issue exist in netbeans 8.1 with my project https://github.com/mcheung63/quantr-server

i run my project by maven goal spring-boot:run, i can't stop it by clicking the stop button in output window