users@glassfish.java.net

[SOLVED] asadmin create-service error on Windows XP:

From: <forums_at_java.net>
Date: Wed, 16 Jan 2013 15:48:52 -0600 (CST)

This is not a question, I am posting a problem and solution to help others
searching for a solution in the future. A customer gave us a test virtual
machine to install our application on, but it was Windows XP Pro (in 2013!) I
installed Java 7 update 11, GlassFish 3.1.2.2, our application, and they all
work well. However, I could not create a Windows service because of
UnauthorizedAccessException, even when I was logged into Windows as
Administrator. Another installer program was able to create a Windows service
without issue, so it seems to be a GlassFish/Windows Service Wrapper issue.
Below is the error that occured: C:\glassfish\3.1.2.2\bin>asadmin
create-service --name GlassFishV3122 domain1 Error while trying to install
GlassFish as a Windows Service. The return value was: -1. STDERR: STDOUT:
System.UnauthorizedAccessException at
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 e
rrorCode, IntPtr errorInfo) at
System.Management.ManagementObjectCollection.ManagementObjectEnumerator.Mo
veNext() at WMI.WmiRoot.ClassHandler.Invoke(Object proxy, MethodInfo method,
Object[] args) at WMI.Win32ServicesProxy.Select(String ) at
winsw.WrapperService.Run(String[] args) at winsw.WrapperService.Main(String[]
args) Command create-service failed. It still created the
GlassFishV3122Service.exe and GlassFishV3122Service.xml files for the Windows
Service Wrapper in C:\glassfish\3.1.2.2\glassfish\domains\domain1\bin\. All
that was missing was registering the exe file as a Windows service. I was
able to do this manually with the following command:
C:\glassfish\3.1.2.2\bin>sc create domain1 binPath=
"C:\glassfish\3.1.2.2\glassfish\domains\domain1\bin\GlassFishV3122Service.exe"
start= auto DisplayName= "domain1 GlassFish" [SC] CreateService SUCCESS
Notice the space after the = character. I've read that this is important. The
Windows service now works, but the JVM will shut down when you log out of
Windows. You need to add the -Xrs JVM option in a couple of places: 1)
C:\glassfish\3.1.2.2\glassfish\bin\asadmin.bat Pay close attention to the
path. There are multiple copies of asadmin.bat and you need to edit the one
referenced by the Windows Service Wrapper XML config file. Add -Xrs to this
line: set JAVA=java -Xrs 2)
C:\glassfish\3.1.2.2\glassfish\domains\domain1\config\domain.xml There are
two blocks of jvm-options elements. I added the following to both blocks
because I'm not sure which is used when: -Xrs Ryan de Laplante

--
[Message sent by forum member 'rdelaplante']
View Post: http://forums.java.net/node/893936