I have an application that starts tomcat with an hidden command line (like startup.bat), when I shut down Windows tomcat process is not closed propery but simply killed. I can feel it because is not call the ContextDestroy method of my web application. By other hand if I call tomcat shutdown.bat the method is called.
Is there any way to let windows close correctly tomcat?
Related
I run the application from the command line and I need the method to be executed and send a post request when Windows shuts down
#PreDestroy - It only works if I end the application manually. Is it possible to somehow call the method in the code when windows shuts down?
I already tried to prescribe in the configuration server.shutdown: graceful
Or maybe there is another way to call the method before Windows shuts down?
I installed XAMPP and have trouble starting tomcat. Apache, MySQL, FileZilla start without problems when I click the "Start" button, while Tomcat writes Attempting to start Tomcat service... and seems to pass out - it doesn't start no matter how long I wait for it.
I can start it manually from catalina_start.bat though. But I really wish to find out what causes this problem and be able to start tomcat from control panel. Please help!
I think that problem is about port conflict, by default both Apache and Tomcat using port 8080, when you using XAMPP and start Apache first then Apache hold that port then you can not start Tomcat, you can start Tomcat via bat file my be because you already stopped the Apache. Also by default when you click on Start button of Tomcat on XAMPP, it will call to catalina_start.bat file.
This is only Windows specific, since in Unix system this works properly.
I have a java cli application (its actually a service written using spring-boot) that runs in the console (cmd).
When pressing ctrl+c in console the application gets killed on windows in a way that java virtual machine itself still remains in memory but the service is killed. This is very annoying since some of the resources still remains locked.
On uinux systems this works by generating an SIGINT and service has the possibility of graceful stop and jvm also exit properly.
Any workarounds?
if we are to have an RMI server application which runs permanently via autosys and then shuts down for a few hours over night, how to we send the shutdown message if the application was started from the command line.
for example, we start the jar using java -jar server.jar and now the application is running. if it contained a applicationClose() method how could we call it - we could parse the message from the client but of course this is undesirable?
It is perfectly acceptable to make a closedown request method available, that returns OK and then calls System.exit().
You might want to protect it with some sort of required credentials before it can be called, but other than that there is no reason why you can't.
The other option is for the process to have another TCP port open with your own protocol for shutting down, or to have a JMX extension installed to remotely shut down the service.
It might sound a bit too naive, but I always had a tough time to debug a java class during server startup. Here is the scenario:
The java application is hosted on a tomcat server.
Suppose there is a class which is invoked while the tomcat server starts up.
As soon as I stop the tomcat instance for a restart, the eclipse debug stops and I can start the debug only once the application is up and running.
Now how do I debug this class on eclipse?
Thanks for you help in advance.
You need to pass the "wait for debugger to connect" flag to tomcat. So the startup will wait until you have connected and thus you won't miss the breakpoint.
Take for example those java options to make tomcat listen for a debugger:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8797,server=y,suspend=y
The wait for a debugger connection flag is the suspend=y entry in the above line.
Debugging of classes during startup should work without problems. For example, suppose you implement a ServletContextListener class. The belonging contextInitialized method is called during Tomcat startup (or to be more precise: while your app gets deployed).
You can set breakpoints in this class. At that point, Tomcat is already started completely and there shouldn't be any problems with debugging.