Friday, 12 September 2014


Wirble is a set of enhancements for ruby(irb). Wirble enables several items mentioned on the RubyGarden "Irb Tips and Tricks" page, including tab-completion, history, and a built-in ri command, as well as colorized results and a couple other goodies.

Wirble even works with rvm , lets hack the trick to do so:

Step 1:
When we start irb prompt it first checks for .irbrc file in home folder. ~/.irbrc.

Step 2 :
To enable wirble in irb prompt, Open the ~/.irbrc file (Create a new one if Not present.), and Paste the contents of the below code.
require 'irb/completion'
 require 'irb/ext/save-history'
 require 'rubygems'
 unless Gem::Specification.find_all_by_name('wirble').any?
   puts "Installing Wirble"
   %x{gem install 'wirble' --no-ri --no-rdoc}
 require 'wirble'
# Initializing Wirble
# Customize according to your will.
colors = Wirble::Colorize.colors.merge({
  :object_class => :purple,
  :symbol => :purple,
  :symbol_prefix => :purple
Wirble::Colorize.colors = colors

Step 3:
Move out of the blog for a colourfull irb prompt and Njoy Coding in Ruby. Thanks to Santosh for writing this post .

Tuesday, 2 September 2014

Mule SFTP : Verify false Error

The following error might occur while using SFTP inbound or outbound endpoint in mule :
Error during login to x@ verify: false Error during login to x@ verify: false
 at org.mule.transport.sftp.SftpClient.logAndThrowLoginError(
 at org.mule.transport.sftp.SftpClient.login(
 at org.mule.transport.sftp.SftpConnectionFactory.createClient(
 at org.mule.transport.sftp.SftpConnector.createSftpClient(
 at org.mule.transport.sftp.SftpConnector.createSftpClient(
 at org.mule.transport.sftp.SftpReceiverRequesterUtil.getAvailableFiles(
 at org.mule.transport.sftp.SftpMessageReceiver.poll(
 at org.mule.transport.AbstractPollingMessageReceiver.performPoll(
 at org.mule.transport.PollingReceiverWorker.poll(
 at java.util.concurrent.ThreadPoolExecutor.runWorker(
 at java.util.concurrent.ThreadPoolExecutor$
Mule SFTP uses JSch to connect to SFTP location . This error occurs with particular Java JDK updates . You might get this error If you are using following versions of jdk :
This error does not occur if we use JDK version < java7u6 .

For more information please read this link.

Post Comments And Suggestions !!

Wednesday, 20 August 2014

JAXB Error : FWK005 parse may not be called while parsing

org.xml.sax.SAXException: FWK005 parse may not be called while parsing.
Above Error occurs because you might have SchemaFactory instance , which is shared by multiple threads. Like declaring it at class level , and using it in methods .
private SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
The SchemaFactory is not thread safe . It should always be initialized and accessed in local scope. So whenever you need SchemaFactory instance , just create it locally instead of using it at instance level.

Post Comments And Suggestions !!

Tuesday, 19 August 2014

How To Link Git Tag with Rails app

I use Git tags to manage the version numbers of my Rails apps.

Every time a new version is ready, I tag the current commit like this :
git tag -a v1.10 -m "FIXED PC-43/67/78"
I have created a ruby file in initializers which defines a constant to hold this information (in this case “v1.10”):
APP_VERSION = `git describe --always` unless defined? APP_VERSION
This constant simply contains the output of Git describe.
Now I can use it anywhere in my app where I would like to display the version number.

This post is written by Santosh.

Post Comments And Suggestions

Sunday, 17 August 2014

How to Print Full Stack Trace In Mule Flow

To print full exception stack trace in mule , you need to add a grrovy scripting element like this :
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:scripting=""
 xmlns:http="" xmlns="" xmlns:doc="" xmlns:spring="" version="CE-3.3.1" xmlns:xsi="" xsi:schemaLocation=" ">
    <flow name="muleMavenSampleFlow1" doc:name="muleMavenSampleFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
        <catch-exception-strategy doc:name="Catch Exception Strategy">
         <scripting:transformer doc:name="Print StackTrace">
    <scripting:script engine="Groovy">
                    <scripting:text><![CDATA[org.apache.log4j.Logger.getLogger("").error("Error Trace is : \n",exception)]]></scripting:text>

Post Comments And Suggestions !!

Wednesday, 16 July 2014

Mule Cron Job : Job Name Can Not be Empty Error

Writing cron job is very easy in mule.You might get error like this in mule application start up :
Caused by: org.mule.api.lifecycle.LifecycleException: Failed to start inbound endpoint "endpoint.quartz.test.job"
 at org.mule.endpoint.DefaultInboundEndpoint.start(
 at org.mule.construct.AbstractFlowConstruct.startIfStartable(
 at org.mule.construct.AbstractPipeline.doStart(
 at org.mule.construct.AbstractFlowConstruct$2.onTransition(
 at org.mule.construct.AbstractFlowConstruct$2.onTransition(
 at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(
 at org.mule.construct.FlowConstructLifecycleManager.fireStartPhase(
 at org.mule.construct.AbstractFlowConstruct.start(
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(
 at java.lang.reflect.Method.invoke(
 at org.mule.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(
 at org.mule.lifecycle.RegistryLifecycleManager$RegistryLifecycleCallback.onTransition(
 at org.mule.lifecycle.RegistryLifecycleManager.invokePhase(
 at org.mule.lifecycle.RegistryLifecycleManager.fireLifecycle(
 at org.mule.registry.AbstractRegistryBroker.fireLifecycle(
 at org.mule.registry.MuleRegistryHelper.fireLifecycle(
 at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(
 at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(
 at org.mule.lifecycle.MuleContextLifecycleManager.invokePhase(
 at org.mule.lifecycle.MuleContextLifecycleManager.fireLifecycle(
 at org.mule.DefaultMuleContext.start(
 at org.mule.module.launcher.application.DefaultMuleApplication.start(
 ... 4 more
Caused by: org.mule.api.lifecycle.LifecycleException: Failed to start Quartz receiver
 at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(
 at org.mule.transport.ConnectableLifecycleManager.fireStartPhase(
 at org.mule.transport.AbstractTransportMessageHandler.start(
 at org.mule.transport.AbstractConnector.registerListener(
 at org.mule.endpoint.DefaultInboundEndpoint.start(
 ... 27 more
Caused by: org.mule.api.endpoint.EndpointException: Failed to start Quartz receiver
 at org.mule.transport.quartz.QuartzMessageReceiver.doStart(
 at org.mule.transport.AbstractMessageReceiver.doStartHandler(
 at org.mule.transport.AbstractTransportMessageHandler$3.onTransition(
 at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(
 ... 31 more
Caused by: java.lang.IllegalArgumentException: Job name cannot be empty.
 at org.quartz.JobDetail.setName(
 at org.mule.transport.quartz.QuartzMessageReceiver.doStart(
 ... 34 more

Here's the xml file :
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:quartz="" xmlns="" xmlns:doc="" xmlns:spring="" version="CE-3.3.1" xmlns:xsi="" xsi:schemaLocation=" ">
    <flow name="crontestFlow1" doc:name="crontestFlow1">
        <quartz:inbound-endpoint jobName="test_job" cronExpression="0 0/100 * * * ?" responseTimeout="10000" doc:name="Price File Report Quartz Job" >
        <logger level="INFO" doc:name="Logger"/>

Notice that your jobName is not empty . The issue is with underscore . you can not have underscore in jobName property. Just remove underscore from jobName and it will run fine.You can not have white space characters in job name either

Here's the bug.

Post Comments And Suggestions !!

Wednesday, 25 June 2014

Mule File Inbound And Threads

Requirement : File inbound endpoint should pick only limited number of files , once these files are processed then only file inbound should pick other files in the directory .

For this situation , we can use processing strategy as synchronous in our flow . This strategy will pick only one file at a time which is not good .

If we set receiver threading profile on file inbound , it also does not work because file poller keeps acquiring the files after the time period, while some files are still being processed . The other solution is to use fork and join pattern of mule which is explained below .

First we create a custom file component which will give us the list of required number of files .Number of files will be configurable.
package com.javaroots;
import java.util.ArrayList;
import java.util.List;

import org.mule.api.MuleEventContext;
import org.mule.api.lifecycle.Callable;

public class FilePollerComponent implements Callable

 private String pollDir ;
 private int numberOfFiles;
 public String getPollDir()
  return pollDir;

 public void setPollDir(String pollDir)
  this.pollDir = pollDir;

 public int getNumberOfFiles()
  return numberOfFiles;

 public void setNumberOfFiles(int numberOfFiles)
  if(numberOfFiles < 1 )
   throw new RuntimeException("Number of files can not be less than 1");
  this.numberOfFiles = numberOfFiles;

 public Object onCall(MuleEventContext eventContext) throws Exception
  File f = new File(pollDir);
  List filesToReturn = new ArrayList(numberOfFiles);
   File[] files = f.listFiles();
   int i = 0;
   for(File file : files)
     break ;
   throw new Exception("Invalid Directory");
  return filesToReturn;

And the flow will be like this :
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:vm=""
 xmlns="" xmlns:doc="" xmlns:spring="" version="CE-3.3.1" xmlns:xsi="" xsi:schemaLocation=" ">

<spring:bean id="filePoller" class="com.javaroots.FilePollerComponent">
<spring:property name="pollDir" value="E:/fileTest"></spring:property>
<spring:property name="numberOfFiles" value="3"></spring:property>



<flow name="fileInboundTestFlow" doc:name="fileInboundTestFlow" processingStrategy="synchronous">
     <poll frequency="200000">
      <component doc:name="File Poller">
       <spring-object bean="filePoller"/>
     <logger message="Size of payload is : #[message.payload.size()]" level="INFO"/>
       <choice doc:name="Choice"> 
                <when expression="#[message.payload.size() &gt; 0]"> 
       <request-reply >
      <vm:outbound-endpoint path="out" >
        <collection-splitter />
      <vm:inbound-endpoint path="response">
        <add-message-property key="MULE_CORRELATION_GROUP_SIZE" value="3" />
     <logger />
    <flow name="processor" >
     <vm:inbound-endpoint path="out"/>
      <component class="com.javaroots.SleepComponent" doc:name="sleep"/>
      <vm:outbound-endpoint path="response"/>


In the flow , first we put our custom file poller component which will give us list of files not more than 3 . Then we create request reply which will process this list , and it will wait untill all three files are processed . The actual processing of each individual file will happen in another flow , where i have put a sleep component .Request reply passes each payload to vm outbound and at the same vm , the other flow will listen .

Once the flow completes its processing , it returns the response to request reply flow . Collection aggregator blocks untill response from all the three files comes back .So in this way we can control number of files to be processed .

make sure that MULE_CORRELATION_GROUP_SIZE is equal to numberOfFiles which we want to be processed concurrently.

This solution is provided by David Dossot on my stack overflow question

You can see the full source code here

Post Comments and Suggestions !!!