Bug 732889 - Instructions for installing JBoss as Windows service do not work
Summary: Instructions for installing JBoss as Windows service do not work
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Scripts and Commands
Version: 6.1.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Tom Fonteyne
QA Contact:
URL:
Whiteboard: Topic ID:3757 Build: 20110822-1045
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-08-24 04:28 UTC by James Livingston
Modified: 2018-12-01 14:24 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
The `service.bat` batch file for managing JBoss EAP installed as a service on Microsoft Windows Server has been upgraded, with improved error checking. The added checks are aimed at testing for conditions which would prevent the service running as expected.
Clone Of:
Environment:
Last Closed: 2013-09-19 10:58:59 UTC
Type: Enhancement
Embargoed:


Attachments (Terms of Use)
service.bat version5 fixed for 6.1 (6.89 KB, text/plain)
2013-06-10 15:53 UTC, Tom Fonteyne
no flags Details
service.bat version6 (3.17 KB, application/zip)
2013-08-21 15:10 UTC, Tom Fonteyne
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 900708 0 high CLOSED Starting EAP as a service on Windows does not work with the startup scripts (standalone.bat/domain.bat) 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 960560 0 unspecified CLOSED Add service.bat and service.conf.bat 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 1006346 0 high CLOSED Upgrade to common-daemons windows service management scripts supported by SEG/GSS 2021-02-22 00:41:40 UTC
Red Hat Issue Tracker JBPAPP-9508 0 Major Closed Starting EAP as a service on Windows does not work with the startup scripts (standalone.bat/domain.bat) 2018-04-24 07:46:56 UTC

Internal Links: 900708 960560 1006346

Description James Livingston 2011-08-24 04:28:48 UTC
> 32-bit, 64-bit, and Itanium 64-bit packages are available from http://www.jboss.org/jbossweb/downloads/jboss-native-2-0-9.html.


This is probably okay for now, but this bug can be a reminder that it needs to be changed to not point to community bits before actual releases.

Comment 1 Misty Stanley-Jones 2011-12-02 05:04:59 UTC
On hold until the Enterprise components are available.

Comment 2 Misty Stanley-Jones 2012-01-05 23:51:35 UTC
Changing to new default queue.

Comment 3 Misty Stanley-Jones 2012-05-02 03:02:35 UTC
Sent this email to EAP PM List:


Hi,

We currently point customers to http://www.jboss.org/jbossweb/downloads/jboss-native-2-0-9.html for the JBoss Natives packages which will let them install EAP as a service on Windows. Where will these packages be located and what will they be called, for GA? We really need to make sure we have all of the appropriate links in place.

Thanks,
Misty

Comment 4 James Livingston 2012-06-06 03:20:05 UTC
There are bits in http://download.devel.redhat.com/devel/candidates/JBEAP/JBEAP-6.0.0-CR1/native/ in the jboss-eap-native-utils zips, which I *think* is for service installation.

A customer just reported that the instructions given do not work with EAP 6 since there is no shutdown.bat

Comment 5 Misty Stanley-Jones 2012-06-14 02:06:02 UTC
Substantial changes to this topic have been made. Needs new QE.

Comment 8 Misty Stanley-Jones 2012-06-26 02:25:23 UTC
It's a bit risky because things can change. We can see what we can do about it for 6.0.1.

Comment 9 James Livingston 2012-06-26 02:33:17 UTC
You can point to specific downloads, but that isn't what you'll want to do since they are version-specific.

You would have to change the URL in the docs every release to point to the current version, and that will almost certainly confuse everyone who wants them for a previous release.

Comment 12 James Livingston 2012-07-20 04:05:27 UTC
What we want to execute is this:
  taskkill.exe /F /FI "SERVICES eq JBossEAP6" /t


We could use the following, except that quote escpating doesn't work quite like this in Windows and I can't figure it out:
  --StopImage=taskkill.exe ++StopParams="/F /FI \"SERVICES eq JBossEAP6\" /t"


So use:
  --StopMode=exe --StopImage=cmd.exe --StopPath=%JBOSS_HOME/bin  ++StopParams="shutdown-pid.bat"

where shutdown-pid.bat contains:
  @echo off
  setLocal EnableDelayedExpansion
  set /p PID=<=%JBOSS_HOME%\standalone\log\jboss-service.pid
  taskkill.exe /PID %PID%



Both of these will obviously need testing

Comment 13 James Livingston 2012-07-20 04:20:56 UTC
This works, but causes an error to appear since prunsrv.exe gets killed:

--StopImage=taskkill.exe ++StopParams=/F ++StopParams=/FI ++StopParams="SERVICES eq JBossEAP6"

Comment 14 JBoss JIRA Server 2012-07-30 12:56:40 UTC
Madhumita Sadhukhan <msadhukh> made a comment on jira JBPAPP-9508

Hi James,

          So should I assign this to you?I believe the scripts need to be fixed.

Comment 15 Tom Fonteyne 2012-07-30 13:14:17 UTC
I think I have the full solution:

1. Make sure to set JBOSS_HOME as a system environment variable pointing to the JBoss installation directory

2. Add a system environment variable NOPAUSE=1
   Alternatively edit the last line of both   standalone.bat (domain.bat) / jboss-cli.bat
   and remove this line:
       if "x%NOPAUSE%" == "x" pause

3.Open a cmd.exe window

4. execute a  "set JBOSS_HOME=..."
  (not needed if you open the cmd.exe *after* you have added the system env. var)

5. Installing the service, enter the below on one line:

prunsrv //IS//JBossEAP6 --DisplayName="JBoss Enterprise Application Platform 6" --LogLevel=DEBUG --LogPath=%JBOSS_HOME%\standalone\log\ --LogPrefix=service --StdOutput=auto --StdError=auto --StartMode=exe --StartImage=cmd.exe --StartPath=%JBOSS_HOME%/bin ++StartParams="/c standalone.bat" --StopMode=exe --StopImage=cmd.exe --StopPath=%JBOSS_HOME%/bin  ++StopParams="/c jboss-cli.bat --connect command=:shutdown"

Adjust loglevel as required of course (f.e. just INFO) or use "domain" instead of "standalone" for executable and path as needed.

6. You should now have a service installed that you can manually start/stop from the Services window.
   Set to automatic is so required.

Should you need to remove the service, use this:

prunsrv //DS//JBossEAP6

Comment 16 Tom Fonteyne 2012-07-30 13:20:23 UTC
it is probably the cleanest if the above gets combined in a "service.bat" that takes commands line "install,start,stop,restart" just like JBoss 5 provided.

Let me know, and I can knock on up.

Comment 17 James Livingston 2012-07-31 03:26:36 UTC
Yeah, that would work. I probably avoided that because you couldn't do it in EAP 4/5 without including the credential details - EAP 6 you can because of local authentication.

Comment 22 Tom Fonteyne 2012-08-20 10:53:45 UTC
In replacement of my comment #15, covering domain mode + a little cleanup, the following can be added the documentation:

=====================================================================
1. Add a system environment variable NOPAUSE=1
   Alternatively edit the last line of both
       standalone.bat (domain.bat) / jboss-cli.bat
   and remove this line:
       if "x%NOPAUSE%" == "x" pause

2. Open a cmd.exe window

3. execute a  "set JBOSS_HOME=..." or use the full path in the below statement

4. Installing the service, enter one of the below on one line:

For standalone:

prunsrv //IS//JBossEAP6 --DisplayName="JBoss Enterprise Application Platform 6" --LogLevel=INFO --LogPath=%JBOSS_HOME%\standalone\log\ --LogPrefix=service --StdOutput=auto --StdError=auto --StartMode=exe --StartImage=cmd.exe --StartPath=%JBOSS_HOME%/bin ++StartParams="/c standalone.bat" --StopMode=exe --StopImage=cmd.exe --StopPath=%JBOSS_HOME%/bin  ++StopParams="/c jboss-cli.bat --connect command=:shutdown"

For domain mode:

prunsrv //IS//JBossEAP6 --DisplayName="JBoss Enterprise Application Platform 6" --LogLevel=INFO --LogPath=%JBOSS_HOME%\domain\log\ --LogPrefix=service --StdOutput=auto --StdError=auto --StartMode=exe --StartImage=cmd.exe --StartPath=%JBOSS_HOME%/bin ++StartParams="/c domain.bat" --StopMode=exe --StopImage=cmd.exe --StopPath=%JBOSS_HOME%/bin  ++StopParams="/c jboss-cli.bat --connect command=/host=master:shutdown"

Note the difference in shutdown command. If not using the default "master", make sure to add the right host name or alias you used for the domain controller

Adjust loglevel as required of course.

5. You should now have a service installed that you can manually start/stop
   from the Services window. Set to automatic if so required.

Should you need to remove the service, use this:

prunsrv //DS//JBossEAP6
=====================================================================

Comment 23 JBoss JIRA Server 2012-08-20 12:59:23 UTC
Tom Fonteyne <tfonteyn> made a comment on jira JBPAPP-9508

I created the attached service.bat for EAP 6.0 usage.

Copy it to the modules\native\sbin directory

It's a first attempt but does the job

Usage:

service.bat install
   => installs standalone.sh

service.bat install domain
   => installs domain.sh

Other options:

service.bat uninstall
service.bat start
service.bat stop
service.bat restart

You can edit the section at the top to change log level or service name.
For domain mode, it uses "master" for the domain controller. Change when needed

todo:
- nicer user messages like for example change the printing of the errorlevel
- have options for DC and loglevel

Comment 24 JBoss JIRA Server 2012-08-20 12:59:36 UTC
Tom Fonteyne <tfonteyn> updated the status of jira JBPAPP-9508 to Coding In Progress

Comment 25 JBoss JIRA Server 2012-08-27 15:27:16 UTC
Nuno Ferreira <nuno.ferreira> made a comment on jira JBPAPP-9508

Hi, 

Using Tom´s script and the problem is that the domain controller don´t stop, or better, it stops, but the windows service remains in stopping state forever until the machine restarts.

anyone have this behavior? 

Using windows 2008 r2 server.

cheers

Comment 26 JBoss JIRA Server 2012-08-28 09:11:13 UTC
Jacek Palka <jacek.palka> made a comment on jira JBPAPP-9508

Hi,

I've tried to use the suggested work around, but the service has not been possible to stop - the Java processes went down, but the prunsrv.exe process was still running making the service to be marked as "Stopping" in the Server Manager. First after I've killed the process in the Task Manager the service has been stopped. I was testing on Windows 2008 R2.

Comment 27 JBoss JIRA Server 2012-08-28 09:20:34 UTC
Nuno Ferreira <nuno.ferreira> made a comment on jira JBPAPP-9508

I´ve come up with the solution.

I´ve to remove all the section of the domain.bat (i believe its the same as standalone.bat):
":END
if "x%NOPAUSE%" == "x" pause

:END_NO_PAUSE"

After doing this the windows service works well.

cheers.

Comment 28 Tom Fonteyne 2012-09-03 10:55:06 UTC
yes, that bit is missing from the service script which is not finalized yet.
I'll work that in later

Comment 29 JBoss JIRA Server 2012-09-06 14:05:52 UTC
Tom Fonteyne <tfonteyn> made a comment on jira JBPAPP-9508

I added the NOPAUSE support into the script. There is now no need any more to set environment variables or modify the standalone/domain.bat files.

service_v2.bat 06/Sep/12

Rename it to "service.bat" and copy it to the modules\native\sbin directory

Usage:

service.bat install
=> installs standalone.sh

service.bat install domain
=> installs domain.sh

Other options:

service.bat uninstall
service.bat start
service.bat stop
service.bat restart

You can edit the section at the top to change log level or service name.
For domain mode, it uses "master" for the domain controller. Change when needed.

todo:

 - nicer user messages like for example change the printing of the errorlevel
 - have options for DC and loglevel

Comment 30 JBoss JIRA Server 2012-09-14 12:53:56 UTC
Tom Fonteyne <tfonteyn> made a comment on jira JBPAPP-9508

service_v3.bat 14/Sep/12

- fixed the location for the service logfile
- added command line options for all settings, no need to edit the script any longer
  => this means a change in the syntax for installing in domain mode !
- better help

Install: Download service_v3.bat, rename it to "service.bat" and copy it to the modules\native\sbin directory

Run the batch file without arguments to get usage information.

still todo:

    nicer user messages like for example change the printing of the errorlevel

Comment 31 JBoss JIRA Server 2012-10-03 05:20:11 UTC
George Rypysc <georgethree> made a comment on jira JBPAPP-9508

Properly handles spaces in LogPath, StartPath, and StopPath

Comment 32 JBoss JIRA Server 2012-10-03 05:25:02 UTC
George Rypysc <georgethree> made a comment on jira JBPAPP-9508

service_v4.bat - Small changes to properly handles spaces in LogPath, StartPath, and StopPath and fix "Succes" typo.

Comment 33 Tom WELLS 2013-01-23 06:13:18 UTC
*** Bug 834255 has been marked as a duplicate of this bug. ***

Comment 34 Tom WELLS 2013-01-24 04:44:45 UTC
This procedure remains broken due to the underlying issues documented in the various tracking bugs.

I am removing the topic, and closing this as INSUFFICIENT_DATA until the underlying issues are resolved.

Comment 35 Tom Fonteyne 2013-06-10 08:11:01 UTC
re-opening, needs modifications for EAP 6.1

Comment 36 Tom Fonteyne 2013-06-10 15:53:22 UTC
Created attachment 759237 [details]
service.bat version5 fixed for 6.1

New version 5, now working with both EAP 6.0.x and 6.1

Comment 38 Misty Stanley-Jones 2013-06-18 04:01:20 UTC
https://access.redhat.com/site/solutions/183833

Comment 39 Jimmy Wilson 2013-07-18 20:25:06 UTC
@TomF: Given that this will have to have updated docs, this probably better belongs in 6.2 than 6.1.1.  Let's talk further if you disagree.

Comment 40 Tom Fonteyne 2013-07-19 07:48:18 UTC
@Jimmy: fair enough. The script could do with a little better error reporting anyhow. I'll make sure to do this in time for 6.2.0

Meanwhile several customers use the script already and are happy with it.

Comment 41 James Livingston 2013-08-20 06:00:04 UTC
This is duplicated by bug 960560, where they have a completely different service script with less features, which is apparently going to be included in 6.1.1 :(

Comment 42 Tom Fonteyne 2013-08-21 15:10:48 UTC
Created attachment 788918 [details]
service.bat version6

I finished v6 of the script. I added quite a bit of extra defence against misuse and new options to set the service-user, service-name... and more.

I did do several tests, but I did not test to destruction.
So, anyone who wants to play/test is welcome.

*any* feedback is welcome, specially bad feedback as that would allow me to get it better

Unzip the attachment, and copy the file to one of these locations:

6.0.x: %JBOSS_HOME%\modules\native\sbin\
6.1.x: %JBOSS_HOME%\modules\system\layers\base\native\sbin\

or, as an alternative to %JBOSS_HOME%\bin

just execute the script to get the usage screen, and take it from there.

Comment 43 TSMY_MWSE 2013-08-22 09:23:28 UTC
Wow Tom, hot stuff this. Was just grumbling how v5 didn't work just a couple of hours ago. I can confirm v6 works with vanilla 6.1 EAP in my environment. Except when I enable SSL for management interface - 'service_v6.bat stop /controller xxx.xxx.xxx.xxx:9999' will fail with : ERROR: Failed to load service configuration. The certificate had been saved permanently. Stopping in services.msc will result in all-too-well-known 'stopping' state.

My known workaround is to shutdown the service via jboss-cli.bat instead. Is this a known limitation or am I doing something wrong? Running on Windows Server 2008 R2 SP1.

Comment 44 Tom Fonteyne 2013-08-22 10:26:33 UTC
@TSMY_MWSE : thanks :)

I did not actually test it yesterday, but have just tested it and it's not a bug.

If you configure the management interface to use certificates, then you really should configure %JBOSS_HOME%\bin\jboss-cli.xml as well.

What you are seeing is an unconfigured cli, which as a result goes in interactive mode and fails.

I've just tested with key+trusts store with mutual trust:
- management interface:
  keystore: the server cert/key
  truststore: the client cert
- jboss-cli.xml:
  keystore: the client cert/key
  truststore: the server cert

and the service cleanly shuts down.

Here are some details:

I use named paths:

    <paths>
        <path name="keystore.home" path="c:\etc\"/>
        <path name="truststore.home" path="c:\etc\"/>
    </paths>

management:

<security-realm name="CertificateRealm">
   <server-identities>
    <ssl>
     <keystore path="kdc2008.jbossuk.com.keystore.jks" relative-to="keystore.home" keystore-password="secret" alias="kdc2008.jbossuk.com"/>
    </ssl>
   </server-identities>
   <authentication>
     <truststore path="kdc2008.jbossuk.com.truststore.jks" relative-to="truststore.home" keystore-password="secret"/>
   </authentication>
</security-realm>

jboss-cli.xml:

    <ssl>
        <alias>cliclient</alias>
        <key-store>c:\etc\cliclient.keystore.jks</key-store>
        <key-store-password>secret</key-store-password>
        <trust-store>c:\etc\cliclient.truststore.jks</trust-store>
        <trust-store-password>secret</trust-store-password>
        <modify-trust-store>true</modify-trust-store>
    </ssl>

Comment 45 Vaclav Tunka 2013-09-19 10:58:59 UTC
It seems this BZ was accidentally reopened after it was properly closed. Everything is tracked in BZ1006346. This is now part of EAP 6.2.0 ER2.

Comment 46 Russell Dickenson 2013-11-21 01:27:48 UTC
Release notes entry added for publication in the JBoss EAP 6.2.0 Release Notes document.

Comment 47 Akeeb 2016-04-29 10:23:18 UTC
Hi Team,

I am new to Jboss and I am trying to setup Jbos EAP 6.3 and want to start and stop this server using batch script.Currently I am stopping the server using ctrl+c , I am trying difficult to find command to replace ctrl+c.I found alternative solution as setting jboss as service on windows then run star and stop commands.

But , I am unable to set jboss as windows service. Please help.
Let me know what details are required from my end.

I will appreciate quick response.


Thanks and Regards,
Akeeb.K.Y

Comment 48 Tom Fonteyne 2016-04-29 12:32:28 UTC
@Akeeb:

Note that this is not a support forum, but a bug reporting site.

Please visit   http://www.jboss.org/forums/   and log your request for help there.

Should you be a Red Hat customer, then open a support case on the Red Hat customer portal.

Kind regards
Tom

Comment 49 Akeeb 2016-05-02 06:26:10 UTC
Thank You Tom for link.


Note You need to log in before you can comment on or make changes to this bug.