Recent Posts
Archives

Archive for the ‘en-US’ Category

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/default.properties
    • in the property bootdelegation-packages, add the JProfiler packages:

[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 variable PATH.
  • 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)

PostHeaderIcon 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!

PostHeaderIcon 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.

PostHeaderIcon “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]

PostHeaderIcon 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.

PostHeaderIcon 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!

PostHeaderIcon Jonathan LALOU recommends… Denis PIHAN

I wrote the following notice on Denis PIHAN‘s profile on LinkedIn:

I worked under Denis’ indirect management. Denis is one of the most valuable professionals I have worked with. His knowledge is wide and impressive. Developer, architect, team leader, COO… He has gone up all the stairs. Nothing can stop him. His skills are numerous. Denis inspires trust. His pieces of advice are searched and followed by the tens of peoples who have worked with him. And do not let me forget to mention the enjoyment of listening to Denis’ Aussie accent!

PostHeaderIcon When WebLogic always routes on the same node of the cluster…

Case

Since a couple of days I have met the following issue on my WebLogic server: one application is deployed on a cluster, which references two nodes. Load-balancing (in Round-Robin) is activated for JMS dispatching.

  • Yet, all JMS messages are received only by one node (let’s say “the first”), none is received by the other (let’s say “the second”).
  • When the 1st node falls, the 2nd receives the messages.
  • When the 1st node is started up again, the 2nd keeps on receving the messages.
  • When the 2nd node falls, the 1st receives the messages
  • and so on

Fix

In WebLogic console go to JMS Modules. In the table of resources, select the connection factory. Then go to the tab Configuration and Load Balance. Uncheck “Server Affinity Enabled“.

Now it should work.

Many thanks to Jeffrey A. West for his help via Twitter.

PostHeaderIcon MissingResourceException / Mule / i18n

The following error is among of the most hated ones in Mule ESB:
[java]java.util.MissingResourceException: Can’t find bundle for base name META-INF.services.org.mule.i18n.core-messages, locale en_US[/java].

I am not going to describe how to fix it, since several and various reasons may induce it. Anyway, here is an action plan to track and isolate the bug when it happens.

Usually, this MissingResourceException hides the actual error, instead of encapsulating and throwing it. For instance, consider the following stacktrace:
[java]Can’t find bundle for base name META-INF.services.org.mule.i18n.core-messages, locale en_USjava.util.MissingResourceException: Can’t find bundle for base name META-INF.services.org.mule.i18n.core-messages, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1427)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1250)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:952)
at org.mule.config.i18n.MessageFactory.getBundle(MessageFactory.java:211)
at org.mule.config.i18n.MessageFactory.getString(MessageFactory.java:181)
at org.mule.config.i18n.MessageFactory.createMessage(MessageFactory.java:108)
at org.mule.config.i18n.MessageFactory.createMessage(MessageFactory.java:59)
at org.mule.config.i18n.CoreMessages.initialisationFailure(CoreMessages.java:400)
at org.mule.module.scripting.expression.AbstractScriptExpressionEvaluator.getScript(AbstractScriptExpressionEvaluator.java:93)
at org.mule.module.scripting.expression.AbstractScriptExpressionEvaluator.evaluate(AbstractScriptExpressionEvaluator.java:54)
at org.mule.expression.DefaultExpressionManager.evaluate(DefaultExpressionManager.java:274)
at org.mule.expression.DefaultExpressionManager.evaluate(DefaultExpressionManager.java:210)
at org.mule.expression.DefaultExpressionManager.evaluate(DefaultExpressionManager.java:170)
at org.mule.transformer.simple.MessagePropertiesTransformer.addProperties(MessagePropertiesTransformer.java:165)
at org.mule.transformer.simple.MessagePropertiesTransformer.transformMessage(MessagePropertiesTransformer.java:93)
at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:145)
at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:93)
at org.mule.DefaultMuleMessage.applyAllTransformers(DefaultMuleMessage.java:1305)
at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1265)
at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1258)
at org.mule.transformer.AbstractTransformer.process(AbstractTransformer.java:118)
at org.mule.processor.ExceptionHandlingMessageProcessor.process(ExceptionHandlingMessageProcessor.java:25)
at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:185)
at org.mule.transport.AbstractReceiverWorker$1.doInTransaction(AbstractReceiverWorker.java:126)
at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:116)
at org.mule.transport.AbstractReceiverWorker.doRun(AbstractReceiverWorker.java:149)
at org.mule.transport.AbstractReceiverWorker.run(AbstractReceiverWorker.java:64)
at org.mule.work.WorkerContext.run(WorkerContext.java:309)
at org.mule.work.SyncWorkExecutor.doExecute(SyncWorkExecutor.java:41)
at org.mule.work.MuleWorkManager.executeWork(MuleWorkManager.java:251)
at org.mule.work.MuleWorkManager.doWork(MuleWorkManager.java:175)
at org.mule.transport.jms.MultiConsumerJmsMessageReceiver$SubReceiver.onMessage(MultiConsumerJmsMessageReceiver.java:326)
at com.ibm.mq.jms.MQMessageConsumer$FacadeMessageListener.onMessage(MQMessageConsumer.java:399)
at com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl$JmsProviderMessageListener.onMessage(JmsMessageConsumerImpl.java:1023)
at com.ibm.msg.client.wmq.internal.WMQAsyncConsumerShadow.honourNoLocal(WMQAsyncConsumerShadow.java:566)
at com.ibm.msg.client.wmq.internal.WMQAsyncConsumerShadow.consumer(WMQAsyncConsumerShadow.java:400)
at com.ibm.mq.jmqi.remote.internal.RemoteAsyncConsume.driveConsumer(RemoteAsyncConsume.java:1527)
at com.ibm.mq.jmqi.remote.internal.RemoteDispatchThread.run(RemoteDispatchThread.java:395)
at com.ibm.msg.client.commonservices.workqueue.WorkQueueItem.runTask(WorkQueueItem.java:209)
at com.ibm.msg.client.commonservices.workqueue.SimpleWorkQueueItem.runItem(SimpleWorkQueueItem.java:100)
at com.ibm.msg.client.commonservices.workqueue.WorkQueueItem.run(WorkQueueItem.java:224)
at com.ibm.msg.client.commonservices.workqueue.WorkQueueManager.runWorkQueueItem(WorkQueueManager.java:298)
at com.ibm.msg.client.commonservices.j2se.workqueue.WorkQueueManagerImplementation$ThreadPoolWorker.run(WorkQueueManagerImplementation.java:1220)V.
[/java]

In IntelliJ IDEA, do Analyse > Analyse Stacktrace... > paste the trace (I have been shown the same tool for Eclipse, somewhere in the Console view). Now you can navigate easily in the code. Then you can notice, line #11, that the Exception you receive is raised by AbstractScriptExpressionEvaluator.
The corresponding piece of code is:
[java] try
{
script.initialise();
}
catch (InitialisationException e)
{
throw new MuleRuntimeException(
CoreMessages.initialisationFailure("An error occurred initialising script."), e);
}[/java]

Add a breakpoint at the level of the throw. Start the debugger, reproduce the bug. In the debugger, you can see the actual error, that is hidden in the stacktrace. In my case, it was a:
[java]org.mule.api.lifecycle.InitialisationException: Scripting engine ‘groovy’ not found. Available engines are: [com.sun.script.javascript.RhinoScriptEngineFactory@3d2227][/java]. Without the debugger, it would have been hard to guess that the original MissingResourceException was linked to a missing Groovy resource ;-).

PostHeaderIcon Sonar / Synchronization on interned XYZ could lead to deadlock

How to fix the Sonar’s following report?
[java]Multithreaded correctness – Synchronization on interned String could lead to deadlock [/java]

Replace lock on String with a lock on an immutable and/or non-serializable object, ie a simple Object.
Eg:
Replace:
[java] synchronized ("myString") {…}[/java]
With:
[java] synchronized (myObject) {…}[/java]