Friday, August 8, 2008

Run Sun Java Application Server 9.1 on Windows Server 2003 as Service

I don't usually dabble in the Java world too much, but had to recently because a client required us to use a Java Solution and we needed to integrate with as part of our Windows Workflow Foundation. This solution Runs under Sun Java Application Server (SJAS).

Installation of the JAR file in SJAS worked fine as a Service and everything seemed to be going great. Right up until I logged off the server - this is where the service stop responding to calls but the service itself still beleived everything was working fine. This was weird because if you choose to install as a service, you don't expect it stop when you logout (i.e.the whole reason for having the "windows service" concept).

There seemed to be a lot of people out there looking for a solution to this issue, but no one seemed to have the answer (at least not for Windows 2003/SJAS 9.1 combination). Not even the vendor of the solution we were integrating with had a solution to this problem.

It turns out that the information is actually in the documentation for SJAS after all - which tripped me up because my searched kept taking me to the old 8.x version SJAS which doesn't include the extra special setting for Windows 2003, and following the 8.x version doesn't work.

Anyway, here's the information and a link to the Sun documenation - it's a bit of fiddling, but it works fine once you make these changes.

http://docs.sun.com/app/docs/doc/819-3671/ablwz?l=en&a=view&q=Restarting+Automatically


Preventing the Service From Shutting Down When a User Logs Out
By default, the Java VM catches signals from Windows that indicate that the operating system is shutting down, or that a user is logging out, and shuts itself down cleanly. This behavior causes the Application Server service to shut down when a user logs out of Windows. To prevent the service from shutting down when a user logs out, set the -Xrs Java VM option.

To set the -Xrs Java VM option, add the following line to the section of the as-install\domains\domain-name\config\domain.xml file that defines Java VM options:

-XrsIf the Application Server service is running, stop and restart the service for your changes to become effective.


And the all imporant bit...


Note –
In some Windows 2003 Server installations, adding the -Xrs option to the domain.xml file fails to prevent the service from shutting down. In this situation, add the option to the as-install\lib\processLauncher.xml file as follows:

<process name="as-service-name">
...
<sysproperty key="-Xrs"/>
...


3 comments:

Volkan UÇARKAYA said...

milions of thanks to you. your post resolved my very big problem.

Matthew Hunter said...

Glad I could help.

Anonymous said...

I am very grateful for this tip! It's resolved my problem
thx again