How to make GlassFish 3.1 Platform Services Survive Logoff

Refer to my other blog for general details about setting up Platform Services

A running JVM does not survive the user logging off unless you wave a magic wand over the JVM startup parameters.  It is very simple.  If you give the -Xrs option then the JVM will completely ignore logoff events (as well as others).  The solution in V3 is very simple but first let me give you a little background.  Skip to the end of  this blog to see the solution if you are in a hurry.

 In V2 all you needed to do was add -Xrs as a jvm-option to domain.xml and you were all set.  If you tried this on V3 you'll have noticed that it does not work.  The reason is that V3 running as a service is really two separate JVM's.  There is an asadmin "watchdog" JVM and the V3 JVM.  This arrangement is exactly like running asadmin start-domain --verbose at a command line.  These 2 JVMs go through life together.  If one dies then the other is automatically killed.  That's the problem.  You can set the -Xrs flag in domain.xml but if the asadmin JVM does not also have it set, then logging off will kill the asadmin JVM which, in turn, will automatically take the V3 JVM down with it. 

The solution is simple: set -Xrs on both JVMs.  I verified that V3 running as a service will only survive a logoff if both JVM's have it set.  I tested all 4 combinations:

 domain.xml   -Xrs ?

 asadmin   -Xrs?

 Survives Logoff event?

 No

 No

 No

 Yes

 No

 No

 No

 Yes

 No

 Yes

 Yes

 Yes


My recommendation is to set -Xrs for asadmin once and then forget about it.  You can always adjust the behavior exclusively from domain.xml.

 Solution

  1. asadmin create-jvm-options -Xrs

  2. edit install-root/bin/asadmin[.bat] and add the -Xrs option to the java command

To turn off the behavior run this command:

asadmin delete-jvm-options -Xrs


Comments:

Hallo, I added the -Xrs-Option to the domain.xml and asadmin.bat, but it shows no effects. After logoff the service died.
Do you hava any suggestions?
Thanks.

Posted by Georg Loick on February 20, 2010 at 08:34 PM PST #

I have this problem too. I've set -Xrs in domain.xml and asadmin.bat (glassfishv3\\bin\\asadmin.bat and glassfishv3\\glassfish\\bin\\asadmin.bat).

On the asadmin.bat files, I've set the parameter on the last line. Now it is:

%JAVA% -Xrs -jar "%~dp0..\\glassfish\\modules\\admin-cli.jar" %\*

My problem is not solved and I ran out of options...

Posted by Roberto on April 29, 2010 at 12:13 AM PDT #

Did you start service under different account, than you use for login and logout?

Posted by Yakov on June 02, 2010 at 04:12 PM PDT #

This works for me:

glassfishv3\\bin\\asadmin.bat and glassfishv3\\glassfish\\bin\\asadmin.bat:

...
%JAVA% -Xrs -jar "%~dp0..\\glassfish\\modules\\admin-cli.jar" %\*

domain.xml:
...
<java-config ...>
...
<jvm-options>-Xrs</jvm-options>
...

lib/processLauncher.xml:

<process name="as9-server">
...
<sysproperty key="-Xrs"/>
...

Posted by Neon63 on September 30, 2010 at 07:30 PM PDT #

In my case, the service simply doesn't start. If I try to manually run it on Services, it says it did start and stop. You see no logs anywhere about it.

Posted by Paulo Pinheiro on February 15, 2011 at 12:09 AM PST #

@Paulo:

if you start the GlassFish server with the "asadmin start-domain domain1" command, what happens?

Maybe you can see the GlassFish error with the command output, instead of starting it with the Windows service.

Posted by Roberto Ferreira on February 15, 2011 at 01:20 AM PST #

Thank you for your reply.

After long hours trying to find a solution (installing and uninstalling glassfish and its service wrapper) I learned that asadmin created the Windows Service but forgot to put the magic word "start" as a parameter for domain1Service.exe

I put it manually and now it works

Posted by Paulo Pinheiro on February 15, 2011 at 10:57 PM PST #

Not a mistake. We purposefully leave it up to you, the user, to start the service.

Posted by Byron Nevins on February 16, 2011 at 08:38 AM PST #

Hello,

when adding the following line to the service xml config file, it's possible to set the -Xrs property to the asadmin java launcher process without editing the asadmin.bat start script. This may be the easier way in fully automatically installation scenarios.

<env name="JAVA_TOOL_OPTIONS" value="-Xrs" />

Posted by guest on October 07, 2011 at 01:57 AM PDT #

Hello,

when adding the following line to the service xml config file, it's possible to set the -Xrs property to the asadmin java launcher process without editing the asadmin.bat start script. This may be the easier way in fully automatically installation scenarios.

<env name="JAVA_TOOL_OPTIONS" value="-Xrs" />

Posted by guest on October 07, 2011 at 01:58 AM PDT #

Yakov: This seems to be the problem on my end. When logging in with the user Glassfish runs as it works fine with the settings mentioned in the blog post, but not when I log in with a different user. Is there a workaround for this?

Posted by objectified on June 12, 2012 at 09:52 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

ByronNevins

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today