Error creating glassfish as a service

2019-08-13 18:50发布

问题:

Trying to do: asadmin create-service

And getting:

Error while trying to install Glassfish as a Windows Service.
The return value was: 8.
STDERR:
STDOUT: WMI.WmiException: UnknownFailure
at WMI.WmiRoot.BaseHanderl.CheckError(ManagementBaseObject result)
at WMI.WmiRoot.ClassHandler.Invoke(Object proxy, MethodInfo method, Object[] ags)
at WMI.Win32ServicesProxy.Create(String, String, STring, ServiceType, ErrorControl, StartMode, Boolean, String[])
at winsw.WrapperService.Run(String[] args)
at winsw.WrapperService.Main(String[] arges

Command create-service failed

Trying to create glassfish as a service to start glassfish at windows boot (with a WAR file in the auto-deploy folder to start the application ASAP.)

回答1:

do you have more than one domain in your domain directory? if so you must specify the name of the domain as noted in the asadmin create-service documentation



回答2:

I got the same error because Glassfish v3 was already installed as a Windows Service with the same default Display Name for the service: "Domain1 Glassfish Server". The create-service command allows you specify a Service Name, but not the Service Display Name. Even though I supplied a new name when using create-service, it was trying to add the duplicate Display Name.

SOLUTION: Use the Windows SC tool to change the Display Name of the existing Glassfish Service to something else before creating the new Windows Service:

sc config Domain1 DisplayName= "Domain1 GlassfishInstance1"

Then the create-service command will work for your new Glassfish Instance.

asadmin> create-service --name GlassfishInstance2"

The new Service will have the default Display Name of Domain1 Glassfish Server. I also changed that with the SC tool afterward (optional)

sc config GlassfishInstance2  DisplayName= "Domain1 GlassfishInstance2"


回答3:

I got the same error when I had a service of the same name existing already. The service wasn't actually used any more and the domain had been deleted.

C:\sc delete domainName 

removed the service and afterwards I could call asadmin create-service domainName