users@glassfish.java.net

Re: How to use -XX:OnOutOfMemory with GlassFish

From: <glassfish_at_javadesktop.org>
Date: Tue, 12 May 2009 06:55:53 PDT

Hi Balbir,

thanks for your answer. I know how to set JVM options in GlassFish, but my problem is, that it's not accepted in the correct way.

I had 2 problems ( the first, I have solved some minutes ago, the second is still there):

1) I had problems to set the option:
-XX:OnOutOfMemoryError="kill -9 %p"
in exact this way. When you insert the option in this way then the GF accept it, but it didn't work. There are qouting problems with the double quotes when executing the command. The only way to make it work is to insert it in the following way in GF (it costs me houers to find it out):
"-XX:OnOutOfMemoryError=kill -9 %p"
Now, the command itself work, like it should. In case of an OutOfMemory, GF kills itself.

But to make the whole process "restart in case of an OutOfMemory" working, this is not enough. I need a way to realize in an outlined shell script, that this OutOfMemory event occures and then restart FG. So it will come to the 2nd problem.

2) The idea was, that I use a self written shell script to start GF (which already has set this JVM option - see point 1). This script should wait until the GF process stops and then check the returncode of the GF java process. If this process return code is 137 (128 + OS signal number), than the OutOfMemory event occures and the script should immediately restart GF.

But this idea didn't work because the "asadmin start-domain" command is only a launching process for the GF daemon process. So I have problems to determine why the GF process stops. I can't not restart GF in all cases, because the admin may have stopped GF intentionally to do support. The script should only restart GF in case of a realk OutOfMemory event. Do I have a chance to start GF as a foreground process to be able to get the exit code?

Thanks again and greetings,
 Frank
[Message sent by forum member 'fmeili' (fmeili)]

http://forums.java.net/jive/thread.jspa?messageID=345947