Search
Calendar
November 2017
S M T W T F S
« Sep    
 1234
567891011
12131415161718
19202122232425
2627282930  
Your widget title
Archives

Posts Tagged ‘MissingResourceException’

PostHeaderIcon MissingResourceException / Mule / i18n

The following error is among of the most hated ones in Mule ESB:

java.util.MissingResourceException: Can't find bundle for base name META-INF.services.org.mule.i18n.core-messages, locale en_US

.

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:

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.

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:

            try
            {
                script.initialise();
            }
            catch (InitialisationException e)
            {
                throw new MuleRuntimeException(
                    CoreMessages.initialisationFailure("An error occurred initialising script."), e);
            }

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:

org.mule.api.lifecycle.InitialisationException: Scripting engine 'groovy' not found.  Available engines are: [com.sun.script.javascript.RhinoScriptEngineFactory@3d2227]

. Without the debugger, it would have been hard to guess that the original MissingResourceException was linked to a missing Groovy resource ;-).