Friday, December 27, 2013

JBOSS 7.1.1 Final Run as Windows Service


Run as Single Service
We can create Windows Service for Run JBOSS 7.1.1 Final
Please follow below step to create Windows Service
1)      To create  windows service we need  below files
·         jbosssvc.exe
·         jbossweb.x64.exe
·         jbosswebw.x64
·         service.bat

2)      But Above files not present in In C:\jboss-as-7.1.1.Final\bin directory.
3)      So We need to download these files from below link

Please select downloads as per your operating system , I am using Windows 7 is 64 bit OS
So I have downloaded below bundles

binaries 2.0.10-windows x64
jboss-native 2.0.10 zip bundles
1.5M
2011-08-10
LGPL

Unzip this bundle it will shows
C:\jboss-native-2.0.10-windows-x64-ssl\
\bin
\licenses
4)      Copy all files and folder from bin directory of C:\jboss-native-2.0.10-windows-x64-ssl\ bin\
To C:\jboss-as-7.1.1.Final\bin
So all above 4 files and 1 native folder now available in C:\jboss-as-7.1.1.Final\bin
5)      Run.bat and shutdown.bat not present in C:\jboss-as-7.1.1.Final\bin so

Instead of Run.bat - > use
standalone.bat 
Instead of shutdown.bat -> use
jboss-cli.bat

6)      We need to update Service.bat file , instead of that create copy of service.bat  we call it
serviceAS.bat.
We need to modify the serviceAS.bat file as per our requirement

7)      Open ServiceAS.bat got line number 20, 21 ,22 update  these lines.

set SVCNAME=JBOSSASONE
set SVCDISP= JBOSSASONE
set SVCDESC=JBoss Application Server 7.1.1 Final GA/Platform: Windows x64

8)      Go to line number 26 and change the line as per below options
set JAVA_OPTS=-Xrs  -Xms1024M  -Xmx1024M

9)      Go to line number 55  and make change as per below code , serviceAS.bat need update instead of service.bat

jbosssvc.exe  -imwdc  %SVCNAME% "%DIRNAME%" "%SVCDISP%" "%SVCDESC%" serviceAS.bat                                 

10)   Now   Go to line number  75 and 104 , update these line as per below

call standalone.bat  < .r.lock >> run.log 2>&1

As per above mentioned, we are using standalone.bat instead of run.bat

11)   In Jboss Application server 7.1.1 Final bin folder there no any shutdown.bat present.
So instead of shutdown.bat use jboss-cli.bat 
Go to line number 84 and 94, Update as per below


call jboss-cli.bat --connect controller=127.0.0.1:9999 command=:shutdown >> shutdown.log 2>&1



 Even we can execute above command manually from command prompt to stop the service like

C:\jboss-as-7.1.1.Final\bin> jboss-cli.bat --connect controller=127.0.0.1:9999 command=:shutdown;

You will get output like as follows

Shutting down JBOSSASONE [2013-12-26 17:18:26]
{"outcome" => "success"}
Shutdown JBOSSASONE service [2013-12-26 17:18:28]


I have considered default local host controller 127.0.0.1 and 9999 is default management command.

Now we have completed all the changes in serviceAS.bat file

Installation as a Windows Service
After all the changes done in serviceAS.bat now we can install the windows service as per below command


C:\jboss-as-7.1.1.Final\bin>serviceAS.bat install
Installed  JBOSSASONE
Service JBOSSASONE installed


Starting Windows Service

We are using Windows 7 
1)  Open Windows Management console using run.
Click on start button, in Run or search text box type service.
Now on the top we are able to service option. Click on in.
Or we can access by using task manager also.


2)      After  windows management console search our service in it  and change the startup type Manual to Automatic which would make sure that whenever you start/bootup your system the JBoss AS 7 services starts up automatically. C
3)      Click on start service, status will change to started.
4)      To stop the service we have to click  on stop link in Windows Management Console
5)      We can stop service using command like
C:\jboss-as-7.1.1.Final\bin>serviceAS.bat stop
6)      Or if the server not shutdown or stopped properly through service then we can execute below command from command prompt to stop the service.


C:\jboss-as-7.1.1.Final\bin> jboss-cli.bat --connect controller=127.0.0.1:9999 command=:shutdown;

You will get output like as follows

Shutting down JBOSSASONE [2013-12-26 17:18:26]
{"outcome" => "success"}
Shutdown JBOSSASONE service [2013-12-26 17:18:28]





6 comments:

  1. hi,

    i m getting "The JBOSSASONE service on local computer started and then stopped. Some service stops automatically if they are not in use by other services or programs"
    plz suggest

    ReplyDelete
  2. Thanks Mahavir.
    That has helped me hugely!
    Tim

    ReplyDelete
  3. Hi
    bin folder not available in C:\jboss-native-2.0.10-src-ssl

    ReplyDelete
  4. try to check jboss-native-2.0.10-windows-x64-ssl

    ReplyDelete
  5. where can we download it without a redhat subscription?

    ReplyDelete