Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Sunday, April 19, 2015

Monitoring JBoss running as service from JVisualVM

Monitoring JBoss 4.x  that runs as a service in Windows server was not straight forward when I had to do that. There were some JVM settings required in order to monitor the server successfully. 

JVisualVM being the free tool, provides enough information on heaps, threads, CPU time and GC details. I found this an easy tool for performance monitoring in development and test setup. This tools is available with Hotspot JVM package (jVisualVM.exe inside bin folder) and can be used to monitor application performance. There are no settings required either at JVM end or in this tool. 

The settings required are at JBoss end and here is the step-by-step instruction on the same.

When the JBoss runs as a service changes need to be made in Windows Registry. Otherwise the below JVM parameters can be set in run.bat itself using JVM_OPTIONS environment variable. 

1. Open registry by entering "regedit" in command prompt. Found he parameters set in Registry at below location in my case.  Find out the JBoss setting location in your case first. 

HKEY_LOCAL_MACHINE
                                              SYSTEM
                                                             CurrentControlSet
                                                                                         Services
                                                                                                      MyJbossd
                                                                                                                      Parameters

2. Open "Parameters" section and add below parameters to existing setting

JVM Option Number 11=-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl
JVM Option Number 12=-Djboss.platform.mbeanserver
JVM Option Number 13=-Dcom.sun.management.jmxremote
JVM Option Number 14=-Dcom.sun.management.jmxremote.port=8077
JVM Option Number 15=-Dcom.sun.management.jmxremote.ssl=false
JVM Option Number 16=-Dcom.sun.management.jmxremote.authenticate=false 

//For remote debugging 
JVM Option Number 17=-Dcom.sun.management.jmxremote.local.only=false 
JVM Option Number 18=-Dcom.sun.management.jmxremote=true 
JVM Option Number 19=-Djava.rmi.server.hostname=0.0.0.0


3. Restart the JBoss from services.

4. Open VisualVM console. 

5. Right click on "localhost" and select "Add JMX"

6. Enter host/IP in case of remote monitoring and the port in this case is 8077. It should be something like below:

<IP>:8077

7. Successful connection would start the JBoss server monitoring.


Hope this simple steps helps. Happy monitoring!









Friday, March 23, 2012

Java Program as a Service in Windows

When first time heard about the requirement of running java programs as a Windows service, my mind ran right towards java native (JNI) programming. Took really some time to figure out that there is a simple way to achieve this. That simple way is to use just one ready made jar file for the same occasion.    
Thought of sharing this which I''m sure many test and development boxes setup requires this for some quick testing references.

There is a free utility tool available for this and can be downloaded from Java Service Launcher (JSLWIN).

The description says that it is a lightweight tool to run Java applications as Windows (NT, Win2000, Win2003) services. JSL is released as a ready to use executable. Setup is straight forward including just one executable and one configuration file.

Thought, there are many ways to achieve it, the way I set up was something like below:

1. Download JSL utility and place it in some directory. IN my case it is E:\JSL

2. Created ServiceLauncher class which in turn calls my entry class. Build jar file for the same.

3. JSL.jar need to be placed in lib folder along with the module that need to be made run as a service and dependent jars. ServiceLauncher.jar to be placed in JSL.

4. Change the Java path, JSL path, library path and very importantly working directory information in jsl.ini file

5. Place all the module related files(XML and classes here) in E:\JSL

6. From command prompt, run jsl -install to install the module as a service

7. Start the service from windows service console

8. To remove the sevice from console, stop the service and then run jsl -remove

9. To test before install, run jsl -debug or jsl -run