aspose file tools*
The moose likes Tomcat and the fly likes shutdown command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "shutdown command" Watch "shutdown command" New topic
Author

shutdown command

naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

hi ranchers,

MY tomcat default home page is at : http://localhost:8090/index.html

since Server is listening the SHUTDOWN COMMAND ON 8005 port , i issue COMMAND like this http://localhost:8005/SHUTDOWN

i get

No data received
Unable to load the webpage because the server sent no data.


i have doubt here , Has tomcat been shutdown here ? because when again i issue http://localhost:8090/index.html i get the home .page.
i should not get home page here.








Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
It's not HTTP listening on that port; it's waiting for the string "SHUTDOWN". You can use a tool like nc (on Unix/Linux) to accomplish that, something like "nc -p 8005 SHUTDOWN" (I think, the syntax for piping the text may be off)). Or use the shutdown script that comes with Tomcat.
naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

Tim Moores wrote:It's not HTTP listening on that port; it's waiting for the string "SHUTDOWN".


Is it waiting the SHUTDOWN command from Tomcat not from user ?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Anyone/anything that can get to port 8005 can issue the shutdown request.
naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384


how can one get to 8005 port ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Why aren;'t you just using the scripts included in the bin folder?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384


i found 2 jar file named as bootstrap.jar and tomcat-juli.jar .And 2 more exe file.inside \lib.when i execute bootstrap.jar, the tomcat shutdown itself.
i am working on a code to develop a servlet container. as a part o process i am leaning the inner mechanics of the Tomcat container.
I was just curious who issues that SHUTDOWN command and how.
Now it seems that the code for shutting down the Tomcat has been included in a script file.


but if Tomcat is listening on 8005 for SHUTDOWN command , shouldn't there be a way to get to the port 8005 and issue shut down command ?


Saikat Roy Mahasay
Greenhorn

Joined: Jan 12, 2012
Posts: 10

I think you could telnet to localhost 8005 from command prompt, and type SHUTDOWN<ENTER>. Also, I think I remember that this worked only in the physical box. Somehow, it didn't respond when I tried telnet-ing from another m/c. But I am not sure if I remember correctly.

Accessing http://localhost:8005/SHUTDOWN may not be same as this. You are sending a HTTP request to fetch a URL, rather than sending a command at the port.

I am not sure of the details of how HTTP differs from telnet but I am sure it does. Can somebody post a proper explanation ?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
naveen yadav wrote:but if Tomcat is listening on 8005 for SHUTDOWN command , shouldn't there be a way to get to the port 8005 and issue shut down command ?

That is exactly what Bear and myself talked about. Did our replies make sense to you?

Saikat Roy Mahasay wrote:I think you could telnet to localhost 8005 from command prompt

Tomcat does not run a telnet server on the shutdown port, so that won't work.
Saikat Roy Mahasay
Greenhorn

Joined: Jan 12, 2012
Posts: 10

Tomcat does not run a telnet server on the shutdown port, so that won't work.


I do not know what tomcat runs on shutdown port, but it used to be possible to telnet to it and type shutdown. In fact this page shows some nice screenshots to demonstrate a solution to this potential problem

http://www.avajava.com/tutorials/lessons/how-do-i-prevent-people-from-shutting-down-my-tomcat.html
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
OK, in that case I stand corrected. On Unix/Linux it's still fewer keystrokes to use nc, though.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16061
    
  21

Telnet is a "dumb terminal" program. When you connect to a server/port in telnet, what you type in goes straight to the other end, and any response from the other end goes straight to the console (or more accurately, stdout).

HTTP is a more complicated protocol. You can issue an HTTP GET via telnet, because the "GET" command itself is a single line of text. However, HTTP as practiced from a web browser includes not only the HTTP command, it also includes additional text lines such as the headers (which include the cookies), and in the case of POST, the form data. Since this constitutes multiple lines and the telnet command is normally expecting to initiate transmission when you hit the first end-of-line character, that makes using telnet as a "web browser" rather awkward. More so, even, because telnet stays connected continously, whereas HTTP connects and disconnects on a per-request basis.

Still, telnet is a useful way to test an HTTP or email server and even to do limited REST functions.

How well it can handle pushing a "SHUTDOWN" command to Tomcat, I don't know. A lot depends on how Tomcat handles that end-of-line character. However, as was mentioned, the "netcat" (nc) command can copy data byte-for-byte, so if telnet doesn't work, try it.

Another possibility is to employ one of the J2EE management protocols. JSR-88 defines a control and deployment protocol that can be used, for example. I think that there's a newer version, but I don't know what JSR number it is. Likewise, JSR-77 (?) defined a J2EE control standard.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: shutdown command