Thursday, August 21, 2008

Installing, testing and Using JBoss Profiler 2.0 - beta2

This entry will show how start use the jboss-profiler beta2, first of all , download the software from here:
http://www.jboss.org/downloading/?projectId=jbossprofiler&url=/jbossprofiler/downloads/jboss-profiler-2.0.Beta2.tar.gz , save in some folder in your disk and unzip it.

Once you have the files in your disk, basically to setup jboss-profiler you will have to do the following steps:
  1. Copy jboss-profiler.jar to jbossas/bin
  2. Copy jboss-profiler.properties to jbossas/bin
  3. Edit jboss-profiler.properties in jbossas/bin to include the classes to be profiled
  4. Copy jboss-profiler-plugins.jar to jbossas/bin
  5. Edit run.conf (Unix) or run.bat (Windows) in jbossas/bin to include JBoss Profiler in JAVA_OPTS ( See you run.conf and add use this example: JAVA_OPTS="-javaagent:jboss-profiler.jar -Djboss-profiler.properties=jboss-profiler.properties -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000")
  6. Copy also to jbossas/bin the javaassist.jar if you are using JBoss AS 4.2.x
  7. Copy jboss-profiler.sar to jbossas/server//deploy
  8. Boot application server, if the following log appears everything is ok:
========================================================================= JBoss Bootstrap Environment JBOSS_HOME: /opt/java/jboss/profiler/as JAVA: /opt/java/jdk1.6.0_03/bin/java JAVA_OPTS: -Dprogram.name=run.sh -server -javaagent:jboss-profiler.jar -Djboss-profiler.properties=jboss-profiler.properties -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true CLASSPATH: /opt/java/jboss/profiler/as/bin/run.jar:/opt/java/jdk1.6.0_03/lib/tools.jar ========================================================================= JBoss Profiler 2.0.Beta2 (Sun Microsystems Inc. 1.6.0_03) JBoss Profiler depends on external communication module 10:55:51,681 INFO [Server] Starting JBoss (MX MicroKernel)... 10:55:51,707 INFO [Server] Release ID: JBoss [Trinity] 4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)

Profiling your Application with JBoss Profiler beta2

In order to show the testing, I will do some profiler in JBPM classes, just to check what is happening behind the scenes. To do that I have to edit the jboss-profiler.properties in jbossas.bin directory to add the reference for JBPM's classes, as which is: org.jbpm.* (includes=org.jbpm.*).

Actually JBoss Profiler uses JMX and MBeans as its infrastructure which allows you profiler either JBoss 4.2.x or future 5.x versions. When you deploy the .sar file, you can see the profiler in the jmx-console as you can see in the following image:

You can do several options using the commands via JMX-Console, or as well as you can use command-line interface. At this moment we will use the JBoss profiler CLI, so go to jboss-profiler2-beta-2-folder/ in your shell (Unix or Win) and type the following command: java -jar jboss-profiler-client.jar , the result will be the following:

[jsilva@jsilva jboss-profiler-2.0.Beta2]$ java -jar jboss-profiler-client.jar
Usage: Client [-h host] [-p port]
startProfiler : Start the profiler
stopProfiler : Stop the profiler
snapshot : Take a snapshot
getSnapshot : Get a snapshot
listSnapshots : List snapshots
clearSnapshots : Clear snapshots
gc : Trigger garbage collection
enable : Enable the profiler
disable : Disable the profiler
load : Load a snapshot
save : Save a snapshot
diff : Difference between snapshots
add : Add classes (repository must be enabled)
remove : Remove classes (repository must be enabled)


As far you can see you have all these options to invoke profiler operations, for testing I used the following:

1- java -jar jboss-profiler-client.jar snapshot - Which generated a snapshot.
2-java -jar jboss-profiler-client.jar listSnapshots - Which shows all snapshots I had taken from my App Server.
[jsilva@jsilva jboss-profiler-2.0.Beta2]$ java -jar jboss-profiler-client.jar listSnapshots
1: 21 August 2008 11:23:54:296 -> 21 August 2008 11:24:17:117
2: 21 August 2008 11:39:05:687 -> 21 August 2008 11:39:31:255
3: 21 August 2008 11:41:59:145 -> 21 August 2008 11:43:25:691

3- java -jar jboss-profiler-client.jar getSnapshot 3 - Which tells to my client flush in my disk the info about my snapshot number 3, after this if you type a ls (dir for win), you can see the folder with thesnapshot timestamp. Please enter on this folder and list the files and folders again, the results would be something like:

[jsilva@jsilva 20080821114159145-20080821114325691]$ ls
caller classes classes.txt hotspots.txt methods.txt overview.txt packages.txt threads


On the files above you can see the information about your classes, in my case, I just did some operations with my simple bpm application. Take a look on the overview.txt report content:

From: 21 August 2008 11:41:59:145
To : 21 August 2008 11:43:25:691

Threads:
========
Thread-60 20063.47 ms

Most time:
==========
Count Ms % Method
1 13453.22 67.05 org.jbpm.persistence.db.DbPersistenceServiceFactory#getSessionFactory()
1 6078.74 30.30 org.jbpm.db.hibernate.HibernateHelper#createConfiguration(String, String)
3 134.04 0.67 org.jbpm.configuration.ObjectFactoryImpl#getObject(org.jbpm.configuration.ObjectInfo)
6 116.03 0.58 org.jbpm.configuration.ObjectFactoryImpl#loadClass(String)
1 84.82 0.42 org.jbpm.persistence.db.DbPersistenceServiceFactory#openService()
1 79.14 0.39 org.jbpm.persistence.db.DbPersistenceServiceFactory#getConfiguration()
1 56.08 0.28 org.jbpm.persistence.db.StaleObjectLogConfigurer#wrap(org.apache.commons.logging.Log)
14 29.55 0.15 org.jbpm.calendar.Day#(String, java.text.DateFormat, org.jbpm.calendar.BusinessCalendar)
24 4.53 0.02 org.jbpm.calendar.Holiday#(String, java.text.DateFormat, org.jbpm.calendar.BusinessCalendar)
2 3.51 0.02 org.jbpm.calendar.Holiday#parseHolidays(java.util.Properties, org.jbpm.calendar.BusinessCalendar)

Hotspots:
=========
Count Ms Avg % Method
1 13453.22 13453.22 67.05 org.jbpm.persistence.db.DbPersistenceServiceFactory#getSessionFactory()
1 6078.74 6078.74 30.30 org.jbpm.db.hibernate.HibernateHelper#createConfiguration(String, String)
1 84.82 84.82 0.42 org.jbpm.persistence.db.DbPersistenceServiceFactory#openService()
1 79.14 79.14 0.39 org.jbpm.persistence.db.DbPersistenceServiceFactory#getConfiguration()
1 56.08 56.08 0.28 org.jbpm.persistence.db.StaleObjectLogConfigurer#wrap(org.apache.commons.logging.Log)
3 134.04 44.68 0.67 org.jbpm.configuration.ObjectFactoryImpl#getObject(org.jbpm.configuration.ObjectInfo)
6 116.03 19.34 0.58 org.jbpm.configuration.ObjectFactoryImpl#loadClass(String)
14 29.55 2.11 0.15 org.jbpm.calendar.Day#(String, java.text.DateFormat, org.jbpm.calendar.BusinessCalendar)
2 3.51 1.76 0.02 org.jbpm.calendar.Holiday#parseHolidays(java.util.Properties, org.jbpm.calendar.BusinessCalendar)
1 1.35 1.35 0.01 org.jbpm.util.XmlUtil#parseXmlInputSource(org.xml.sax.InputSource)

Allocations:
============
org.jbpm.db.hibernate.StringMax 149
org.jbpm.db.hibernate.ConverterEnumType 49
org.jbpm.configuration.AbstractObjectInfo 32
org.jbpm.calendar.Holiday 24
org.jbpm.calendar.Day 14
org.jbpm.configuration.FieldInfo 9


Conclusion

JBoss Profiler 2 is built on top of really cool technologies, such as JBoss AOP and JavaAssist, feel you free to contribute with bug-fixes, documentation or with whatever you think could be valuable for the project, it would be a great chance for joining at a JBoss Project as a contributor, as far the actual contributors: Jesper Pedersen, Clebert Succonic and I are not dedicated as a full-time developers for Profiler, the work you can see as the result is a really big effort that Jesper and Clebert are doing. Beyond simple CLI interface, we are planning 2 really cool news, one of that is a new JBoss Profiler console based on RichFaces and related technologies, besides a Plugin for JBoss Operations Network/RHQ Project as well.

Visit: http://www.jboss.org/jbossprofiler/

11 comments:

Unknown said...

Hey.. It seems to work ok. But if you are going through your walk-through, then you are missing the javassist.jar file when jboss start up. I just found it on sourceforge and put it into $JBOSS_HOME/bin dir and then it worked. :-)

Unknown said...

And by the way, where is it possible to find some good documentation for the jboss profiler 2.0?? I can right now only find doc for 1.x. And yes I know it is beta versions, but still.. I would like to know how to find mem. leaks etc.. Thanks in advance :-) /Steffen

Edgar Silva said...

Steffen,

We are still working in the documentation, sorry for awhile

Edgar

Sudhakar Pyndi said...

Thank you for your Blog. It's very helpful.
I got a .jps file and I'm unable to convert the file to a text file using the jboss-profiler-client.jar load "filename" command.
It's not throwing any exceptions at the same time it's not writing any Analysis reports. Please let me know if there is a way to troubleshoot this issue.
Sudhakar

PK said...

I'm getting error while starting up profiler/taking a snapshot.

Any Idea what may be wrong?? I am using JBoss 4.0.5.

java -jar jboss-profiler-client.jar snapshot
2009-02-05 10:56:36,847 ERROR [org.jboss.remoting.transport.socket.SocketClientInvoker] Got marshalling exception, exiting
java.net.SocketException: end of file
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:575)
at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
at org.jboss.remoting.Client.invoke(Client.java:1550)
at org.jboss.remoting.Client.invoke(Client.java:530)
at org.jboss.remoting.Client.invoke(Client.java:518)
at org.jboss.profiler.client.cmd.Client.main(Client.java:257)
2009-02-05 10:56:36,849 ERROR [org.jboss.profiler.client.cmd.Client] Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
java.net.SocketException: end of file
java.rmi.MarshalException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
java.net.SocketException: end of file
at org.jboss.remoting.transport.socket.SocketClientInvoker.handleException(SocketClientInvoker.java:122)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:654)
at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
at org.jboss.remoting.Client.invoke(Client.java:1550)
at org.jboss.remoting.Client.invoke(Client.java:530)
at org.jboss.remoting.Client.invoke(Client.java:518)
at org.jboss.profiler.client.cmd.Client.main(Client.java:257)
Caused by: java.net.SocketException: end of file
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:575)
... 5 more

SV said...

Hey iam using JBoss 4.0.5 and Jdk 5
i set up the environ ment as given in this article.I did not place javassist.jar as iam using 4.0.5(In the readme text with the profiler it is given that we need to place this in the jbossas\bin if the jboss version is 4.2 +).
i am getting the following error when i tried to invoke snapshot.

C:\artesia\jboss-profiler-2.0.Beta1>java -jar jboss-profiler-client.jar
Usage: Client [-h host] [-p port]
startProfiler : Start the profiler
stopProfiler : Stop the profiler
snapshot : Take a snapshot
getSnapshot : Get a snapshot
listSnapshots : List snapshots
clearSnapshots : Clear snapshots
gc : Trigger garbage collection
enable : Enable the profiler
disable : Disable the profiler
load : Load a snapshot
save : Save a snapshot
diff : Difference between snapshots
add : Add classes (repository must be enabled)
remove : Remove classes (repository must be enabled)

C:\artesia\jboss-profiler-2.0.Beta1>java -jar jboss-profiler-client.jar listSnapshots
2009-01-25 14:23:57,500 ERROR [org.jboss.remoting.transport.socket.SocketClientInvoker] Got marshalling exception, exiti
ng
java.net.SocketException: end of file
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:575)
at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
at org.jboss.remoting.Client.invoke(Client.java:1550)
at org.jboss.remoting.Client.invoke(Client.java:530)
at org.jboss.remoting.Client.invoke(Client.java:518)
at org.jboss.profiler.client.cmd.Client.main(Client.java:264)
2009-01-25 14:23:57,515 ERROR [org.jboss.profiler.client.cmd.Client] Failed to communicate. Problem during marshalling/
unmarshalling; nested exception is:
java.net.SocketException: end of file
java.rmi.MarshalException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
java.net.SocketException: end of file
at org.jboss.remoting.transport.socket.SocketClientInvoker.handleException(SocketClientInvoker.java:122)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:654)
at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
at org.jboss.remoting.Client.invoke(Client.java:1550)
at org.jboss.remoting.Client.invoke(Client.java:530)
at org.jboss.remoting.Client.invoke(Client.java:518)
at org.jboss.profiler.client.cmd.Client.main(Client.java:264)
Caused by: java.net.SocketException: end of file
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:575)
... 5 more


Please help on this how to fix this.
Also how can we take snapshots and from jmx-console?
What are the settings we need to make to profile jboss which is running on different port.For Example my jboss runs on port XXXXX and is placed(customised) some thing like {jboss-home}\AAA\bin,{jboss-home}\AAA\deploy,etc.

Anonymous said...

Hi,

I seem to be getting this error after following your steps. I am using jboss-profiler-2.0.Beta3.SP1 on jboss4.2.2

C:\apps\jboss-profiler-2.0.Beta3.SP1>java -jar jboss-profiler-client.jar listSnapshots
2009-05-05 13:56:55,579 ERROR [org.jboss.profiler.client.cmd.Client] Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket:/
/localhost:5400/]
org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://localhost:5400/]

H2KINFOSYS said...

Can you please provide steps for jboss-profiler-2.0.0.Beta5 on JBOSS 5.1.0.GA ?

I tried the steps in users guide.
When I tried to start the profiler, it is not starting, not displaying any errors. just coming back to command prompt.

Marian said...

i had the same error like PK and SV, with jboss 5.1
[code]...
Caused by: java.net.SocketException: end of file
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:575)
[/code]

I fi ged rid of it by adddind jboss-profiler.jar and jboss-profiler-plugins.jar to jboss server classPath
In "Run - Create, manage and run configurations" window, select Classpath tab from server configuration and add mentioned jars to user entries.

AbsoluteCodeMakers said...

Is it possible to use JBoss profiler as a stand-alone profiler, profiling java applications/tests which are not running in JBOSS AS.

I was wondering if there were any command line arguments to start the java application ca do the trick...

Swetadri said...

Hi, I am using this .But when I am profiling my application, its not giving result for some methods which I am sure I am using in the application and running.Can you help me?Is it may be for some methods are throwing some exceptions?