May 2017
« Sep    
Your widget title

Posts Tagged ‘JProfiler’

PostHeaderIcon Sniffing RMI Traffic… Rather log it!

Suspecting a thread leak, there is some traffic I’d like to track on my JOnAS server: most of all, the calling IPs, with the methods and parameters sent. Actually, I lack some tools, so I tried to snif the network traffic.
Two softwares may make the job:

I discarded these solutions for several reasons. First, there are some issues with Windows Seven compatibility. Moreover, traffic on RMI protocol is SSL-encrypted… therefore not easy to read.

At least, I withdrew from this idea to snif, and I decided to intercept calls thanks to loggers.
In order to enable RMI logs, add the following properties to your JVM (to JAVA_OPTS parameters):

  • on client side: -Dsun.rmi.client.logCalls=true
  • on server side: -Djava.rmi.server.logCalls=true

More details and options are available in Oracle’s documentation: RMI Implementation Logging.

By default, the logs look like this:

FINEST: RMI TCP Connection(5)- [ sun.rmi.transport.DGCImpl[0:0:0, 2]: java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)]
2012-05-03 15:35:51,053 : Log$LoggerLog.log : RMI TCP Connection(5)- [ sun.rmi.transport.DGCImpl[0:0:0, 2]: java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)]

(Don’t be fool: this is Java logging, but not Log4J!)

By the way, a very interesting result I got is the following: monitoring and profile tools such as JVisualVM or JProfiler “ping” the RMI server, disturbing the measurements. Let’s consider that as “the Heisenberg uncertainty principle” applied to softwares 😉

PostHeaderIcon Configure JProfiler 5 to work with JOnAS 5

JOnAS 4 (and older) and JProfiler 4 (and older) were used to working smoothly. JOnAS 5 makes a large use of OSGi libraries… which may “blind” JProfiler.

Here is a workaround, slightly different from former version, to bypass this issue, in order to make JProfiler 5 work with JOnAS 5:

  • let’s assume you have installed JOnAS in a folder, let’s say JONAS_ROOT
  • install JProfiler 5 with default options, set the JDK, licence key, etc., let’s say in a folder C:\win32app\jprofiler5\ also known as JPROFILER_HOME.
  • edit %JONAS_ROOT%/bin/setEnv.bat:
    • set: JAVA_OPTS=-agentlib:jprofilerti=port=8849 "-Xbootclasspath/a:C:\win32app\jprofiler5\bin\agent.jar" %JAVA_OPTS%
  • edit %JONAS_ROOT%/conf/osgi/
    • in the property bootdelegation-packages, add the JProfiler packages:
bootdelegation-packages com.sun.corba, \
                              com.sun.corba.*, \
                              com.jprofiler, \
                              com.jprofiler.*, \
                              com.jprofiler.agent, \
  • add JPROFILER_HOME\bin\windows to your environment variable PATH.
  • startup JOnAS, you should see the following block in standard output:
JProfiler> Protocol version 25
JProfiler> Using JVMTI
JProfiler> 32-bit library
JProfiler> Listening on port: 8849.
JProfiler> Native library initialized
JProfiler> Waiting for a connection from the JProfiler GUI ...
JProfiler> Using dynamic instrumentation
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
JProfiler> Hotspot compiler enabled
JProfiler> Starting org/ow2/jonas/commands/admin/ClientAdmin ...
  • run JProfiler, follow the wizard, take caution to set JProfiler port at 8849 (or remain consistent with the port set in JOnAS config file)