(long tweet) JOnAS / no security manager: RMI class loader disabled
On server side:
an EJB2 packaged in a JAR within an EAR, deployed on JOnAS 5.
On client side:
java.lang.ClassNotFoundException: org.ow2.jonas_gen.com.clam.indice.api.interfaces.JOnASHelloWorldService150707405Home_Stub (no security manager: RMI class loader disabled)]
Explanation:
This means there is some kind of issue with generated Stubs on client side. Should check whether the Stubs depended on are available in classpath.
Problems when invoking main method from GenIC … error in fastrmic
Case
Trying to deploy an EAR on JOnAS, I got the following error:
[java]Problems when invoking main method from GenIC: java.lang.RuntimeException: error in fastrmic (null)[/java]
More detail:
[java]JOnASEJBService.__checkGenIC : Cannot apply GenIC on the file ‘C:\jonathan\jonathan_2012.05.11-13.47.29.ear\jonathan-server.jar’ with the args ‘[-classpath, C:\jonathan\jonathan_2012.05.11-13.47.29.ear\jonathan-server.jar, -protocols, jrmp, -invokecmd]’.
org.ow2.jonas.service.ServiceException : Problems when invoking main method from GenIC: java.lang.RuntimeException: error in fastrmic (null)
at org.ow2.jonas.generators.genic.wrapper.GenicServiceWrapper.callGenic(GenicServiceWrapper.java:79)
at org.ow2.jonas.ejb2.internal.JOnASEJBService.__callGenic(JOnASEJBService.java:2017)[/java]
Quickfix
Edit $JONAS_BASE/conf/jonas.properties
.
The properties jonas.services
and jonas.service.ejb2.auto-genic
must be consistent.
Especially, if GenIC is enabled (jonas.service.ejb2.auto-genic true
), then check ejb2 is among the services pointed at by jonas.services
, eg:
jonas.services jtm,db,security,resource,
ejb2
,web,ear
.
IntelliJ IDEA / Unsupported classpath format eclipse
Case
The project on which I work is built on Eclipse and Ant. I am trying to migrate it to Maven 3.0. I thought to do this within IntelliJ IDEA.
Once the pom.xml
was created, I wanted to revert to a configuration based on Eclipse’s .classpath
file.
Then IntelliJ IDEA crashes. On starting up again, I get the following error
[java]Cannot load module file ‘jonathanModule’ Unsupported classpath format eclipse[/java]
Quick Fix
For a reason I ignore, Eclipse integration plugin was disabled. To restore Eclipse compatibility, simply do enable Eclipse integration in the plugin preference menu of IntelliJ IDEA.
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:
[java]FINEST: RMI TCP Connection(5)-10.76.35.25: [10.76.35.25: 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)-10.76.35.25: [10.76.35.25: sun.rmi.transport.DGCImpl[0:0:0, 2]: java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)][/java]
(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 😉
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 asJPROFILER_HOME
. - edit
%JONAS_ROOT%/bin/setEnv.bat
:- set:
JAVA_OPTS=-agentlib:jprofilerti=port=8849 "-Xbootclasspath/a:C:\win32app\jprofiler5\bin\agent.jar" %JAVA_OPTS%
- set:
- edit
%JONAS_ROOT%/conf/osgi/default.properties
- in the property
bootdelegation-packages
, add the JProfiler packages:
- in the property
[java]
bootdelegation-packages com.sun.corba, \
com.sun.corba.*, \
(…)
com.jprofiler, \
com.jprofiler.*, \
com.jprofiler.agent, \
com.jprofiler.agent.*[/java]
- add
JPROFILER_HOME\bin\windows
to your environment variablePATH
. - startup JOnAS, you should see the following block in standard output:
[java]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 …[/java]
- run JProfiler, follow the wizard, take caution to set JProfiler port at 8849 (or remain consistent with the port set in JOnAS config file)
Starting a new position at Amundi AM
This week I have started a new position as transverse architect at Amundi Asset Management in Paris (France).
I have to manage the project of Stabilization and Reliability of the platform (tens of JOnAS servers, EJB2 to migrate to EJB3, JVM tuning, etc.). I will have to face hard technical challenges.
I wish I’ll spend a nice time with my new team!
Difference between wait() and sleep() in Java
Today in interview I have also been asked the following question: in Java, what is the difference between the methods wait()
and sleep()
?
First of all, wait()
is a method of Object
, meanwhile sleep()
is a static method of Thread
.
More important: Thread.sleep()
freezes the execution of the complete thread for a given time. wait()
, on its side, gives a maximum time on which the application is suspended: the waiting period may be interrupted by a call to the method notify()
on the same object.
“Synchonized” in a block vs on a method
Today, in recruting interview, I have been asked the following question: what is the difference between the Java reserved word synchronized
used on a method and this very word in a block? Happily I have known the answer:
Indeed, synchronized
uses an Object to lock on. When a methid is synchronized
, this means the current object is the locker.
Eg: this piece of code:
[java] public synchronized void foo(){
System.out.println("hello world!!!");
}
[/java]
is equivalent to that:
[java] public void foo(){
synchronized (this) {
System.out.println("hello world!!!");
}
}
[/java]
Besides, when synchronized
is used on a static method, the class itself is the locker.
Eg: this piece of code:
[java] public static synchronized void goo() {
System.out.println("Chuck Norris");
}
[/java]is equivalent to that:
[java] public static void goo() {
synchronized (MyClass.class) {
System.out.println("Chuck Norris");
}
}
[/java]
Jonathan LALOU recommends… Ronan PIERRE
I wrote the following notice in Ronan PIERRE‘s profile on LinkedIn:
I have reported to Ronan for more than two years as I was software architect at BNP Paribas. Ronannot only holds title: he *is* an actual team leader and project director. Efficient, skilled, open-minded, you can trust him: as a provider, he is used to following requirements and keep delays ; as a manager, he will do all that is necessary and sufficient to keep his commitments and find solutions if, ever, an issue appears. I strongly recommend Ronan as a very valuable professional.
Jonathan LALOU recommends… Ludovic MAURILLON
I wrote the following notice on Ludovic MAURILLON‘s profile on LinkedIN:
I had reported to Ludovic for more than two years. Ludovic gathers eclectic skills: functionnal, technical and managerial. Ludovic is as fluent in Java as in prime brokerage. As a good leader, Ludovic always listens to his teammates. He is able to create trust and confidence between him and the people he works with. This trust creates strong synergy within and between teams: this is one of the factors that explain the successes Ludovic has encountered in all the projects he was involved in and/or led since I have met him. Shall I recommend Ludovic? Of course! Hire Ludovic, he is among the most valuable professionals you may work with!