Saturday, April 12, 2014

Configure and run Hadoop 2 mapreduce job history server

#1 - Create the yarn pid dir

#2 - Enable log aggregation

#3 - Add defult yarn pid dir to the

# default pid directory 
if [ "$YARN_PID_DIR" = "" ]; then

#4 - After you start your dfs (<HADOOP_HOME>/sbin/ and yarn (<HADOOP_HOME>/sbin/ start your yarn mapreduce history server
[hduser@hostname sbin]$ ./ start historyserver
starting historyserver, logging to <HADOOP_HOME>/logs/mapred-hduser-historyserver-step-cca-sjc-lnx-lab9.out
[hduser@hostname sbin]$ 

For a nice hadoop 2 multi cluster quick installation click here

Thursday, February 14, 2013

Apache camel trace enabling from spring XML log4j

Wondering why your apache camel trace is not working and you are not seeing the camel route trace.

Add the following dependencies to your pom.xml
    <artifactId> slf4j-log4j12<artifactId>

Enable apache camel tracer
<camelContext trace="true" xmlns="">

Thats all. Enjoy your camel ride !

Sunday, July 15, 2012

couchdb running multiple instances and data replication

Running multiple instance of couchdb:

The following has to be changed in the instance-x.ini:

database_dir = some_location/couchdb-x (data location for the couchdb instance)

view_index_dir = some_location/couchdb-x
port = new-port-no (assume instance1 runs on 5984 and instance2 runs on 5985)

file = some_location/log/couch-x.log

Assuming that both the instances are going to run on the same host. Running first instance of couchdb 

couchdb -a some_location/instance1.ini  -p

Running second instance of couchdb
couchdb -a some_location/instance2.ini  -p

Make sure that both the instance of the database is running using the 'ps -ef | grep couch' command.

Data Replication:

Run the following command to replicate the data between multiple instances (in our case from instance1 to instance2 and the other way).

Replication from instance1 to instance 2

curl -X POST -H "Content-Type: application/json" -d '{"source":"http://localhost:5984/test-db", "target":"test-db", "continuous":true, "doc_ids":["doc1", "doc2"]}' http://localhost:5985/_replicate

Reverse the port no's in the above command (change 5984 to 5985 and viceversa) for the replication from instance 2 to instance1. Optional parameter "continuous":true tells couchdb to replicate continuously whenever there is a change in the db. Leaving this parameter would do the replication once when the command is executed. Couchdb is famous for filtered replication. There are multiple ways to do filtered replication.  In the above command the optional parameter "doc_ids":["doc1", "doc2"] tells couchdb to replicate only the doc1 and doc2 documents. If there are other documents for eg: doc3, doc4, etc they won't be replicated. Couchdb is very powerful in filtered replication and works very nicely on the mobile devices which might go online and offline very frequently due to coverage issues.

Some useful considerations for couchdb:

1 - Lightweight (around 23M resident size)
2 - MVCC - Multi Version Concurrency Control - would be a natural fit for the products that need to track multiple updates to the same document
3 - Filtered data replication
4 - NoSQL,Document based,schema-free design - No relational data and the data could vary during updates at various intervals
5 - For a embeddable solution take a look at touchdb
6 - Offline web applications - pouchDB
7 - Clustering Big Couch

Cassandra vs MongoDB vs CouchDb vs Redis vs Riak vs HBase vs Membase vs Neo4j

The above are some of the main features apart from plethora of benefits couchdb provides.

Couchdb is supported by cloudant team -

couchdb doesn't stop here ... there are lot more ....

Tuesday, July 3, 2012

JBoss 7 - Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory

Simple solution to fix this issue:

If you do not want to read the above URL, which is really not giving the straight forward solution:
1 - Open {your war}/META-INF/MANIFEST.MF
2 - Add this line at the end - Dependencies: org.dom4j export

You do not need to do any of the following:
1 - jboss-deployment-structure.xml - exclussions
2 - Adding subsystem to include org.dom4j as global modules
3 - Remove your dom4j-1.6.1.jar from your WEB-INF/lib directory

Most of the time you hit this problem when you try to deploy a war that has hibernate 4 included in it. In this case you may want to do the following for JBoss 7:
To your persistence.xml add the following properties, which is not need for tomcat (assuming you are using oracle > 10g).
 <properties >
    <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/ >
    <property name="hibernate.listeners.envers.autoRegister" value="false"/ >
</properties >

Monday, December 1, 2008

My First RichFaces & Java Server Faces (JSF) Web Application


1 - Java SE Development Kit (JDK) 6 Update 11

Download Java SE 6

To install Java double click on the executable jdk-6u11-windows-i586.exe and follow the wizard instructions.

2 - Apache Tomcat 6.0.18

Tomcat is needed to deploy and run your RichFaces web application.

Download Tomcat 6.0.18

To install Tomcat, double click on the apache-tomcat-6.0.18.exe and follow the wizard instructions. You need to use the Java 6 home in the 'Java Virtual Machine' page.

3 - Eclipse Enterprise Edition 3.4 Ganymede

Download eclipse-jee-ganymede-SR1-win32

4 - Java Server Faces (JSF) libraries

Download JSF 1.2

5 - Java Standard Tag Library (JSTL) libraries

Download JSTL 1.2

6 - Facelets libraries

Download Facelets 1.1.14

7 - RichFaces libraries

Download RichFaces 3.2.2

8 - Apache Commons libraries

RichFaces needs the following apache commons jars:



Extract all the zip files to any directory (My extract directory C:\canjur\downloads).

Iam going to refer this directory (C:\canjur\downloads) as your DOWNLOADS_EXTRACT_HOME hereafter.


Step 1:

Go to <your eclipse home>\eclipse & Launch eclipse enterprise edition (eclipse.exe)

Step 2:

Create a workspace. Say C:\workspace-jee\richfaces-demo-1


Step 3:

In eclipse, go to Window->Preferences and choose Web->JavaServer Faces Tools->Libraries

Step 4:

You need to define the following new JSF libraries which is needed to create a JSF 1.2 with RichFaces web application
  • SUN_RI_1.2
  • JSTL
Lets do it one by one.


Click 'New ...' in the 'Libraries' page. Input the following :

Library Name: SUN-RI-1.2
Version Supported: v1_2

Click 'Add' under 'Library Jars'. The Browser for Jars/Zips pops up.

Go to your <DOWNLOADS_EXTRACT_HOME>\jsf-1_2\jsf-1.2-b20-FCS\lib (in my machine it is C:\canjur\jsf-1_2\jsf-1.2-b20-FCS\lib).

Select jsf-api.jar & jsf-impl.jar and click 'Open'.

Check 'Is JSF Implementation' in the Create JSF Library popup and click 'Finish'.


Repeat the same steps listed under SUN-RI-1.2 to add the JSTL library.

Note: Do not Check the 'Is JSF Implementation' for JSTL.

Library Name : JSTL
Version Supported : v1_2

Jar Name(s) : jstl-api-1.2.jar


Repeat the same steps listed under SUN-RI-1.2 to add the FACELETS library.

Note: Do not Check the 'Is JSF Implementation' for FACELETS.

Library Name : FACELETS
Version Supported : v1_2

Jar Location : <DOWNLOADS_EXTRACT_HOME>\facelets-1.1.14\facelets-1.1.14
Jar Name(s) : jsf-facelets.jar


Repeat the same steps listed under SUN-RI-1.2 to add the RICHFACES library.

Note: Do not Check the 'Is JSF Implementation' for RICHFACES.

Library Name : RICHFACES
Version Supported : v1_2

Jar Location :

Jar Name(s) :


Repeat the same steps listed under SUN-RI-1.2 to add the COMMONS library.

Note: Do not Check the 'Is JSF Implementation' for COMMONS.

Library Name : COMMONS
Version Supported : v1_2

Jar Location :
<DOWNLOADS_EXTRACT_HOME> (for commons-beanutils-1.7.0.jar)

Jar Name(s) :

Finally, Click OK button in the Preferences->Web->JavaServer Faces Tools popup.

You are ready to create a RichFaces web application. Lets rock !


Step 5:

Create a new Dynamic Web Project in eclipse.

Click File->New->Dynamic Web Project

Project Name : RichFaces
Target Runtime : (Don't worry about it now. We will define it later.)
Dynamic Web Module Version : 2.5
Configuration : JavaServer Faces v1.2 Project

Click Next.
Click Next.

  1. Choose SUN_RI_1.2 under JSF Libraries:
  2. Add all the Component Libraries to Deploy (click >>)
  3. Remove /faces/* from URL Mapping Patterns and add *.jsf

Click 'Finish'. You will see the project tree similar to the one shown in the picture below.


Step 6:

Edit your RichFaces->WebContent->WEB-INF web.xml & faces-config.xml, go to src tab and type the contents shown in the images below:

web.xml (Iam not able to properly indend & color the XML file hence the picture. If you need the XML files write to me. I will mail it to you)

faces-config.xml (Iam not able to properly indend & color the XML file hence the picture. If you need the XML files write to me. I will mail it to you)

Save your web.xml & faces-config.xml.


Step 7:

Create index.html & iexplore.jsp under RichFaces->WebContent and copy paste the contents below.

(Iam not able to properly indend & color the file hence the picture. If you need the file write to me. I will mail it to you)

(Iam not able to properly indend & color the file hence the picture. If you need the file write to me. I will mail it to you)


Step 8:

Right click 'Java Resources: src' in you project tree and select New->Package to create a package called richfaces.managedbeans.

Create Java files named
The files listed above are available @

In case you are not seeing the files under the abover URL, then navigate to
  2. Click RichTrees in the Left panel bar
  3. Click Recursive Tree Adaptor
Once you are done copied the java files to your richfaces.managedbeans package you need to do the following :
  1. All the java files has package name as package org.richfaces.treemodeladaptor. Change it to 'richfaces.managedbeans'.
  2. Open and change the line private static String SRC_PATH = "/WEB-INF/src"; to private static String SRC_PATH = "/WEB-INF";
Your project tree should look like this :


We are going to create a properties file called under your RichFaces->Java Resources:src.

Step 9:

Right click Java Resources:src and choose New->Other. Choose General->File and click Next.

Select RichFaces->src folder. Input '' for the File name and click Finish.

Open, copy & paste the following line in the editor and save the file.

appname=File System Explorer


Lets run our RichFaces web application. Before we run you should know what the application is going to display in the browser window inside eclipse.

The index.html is going to navigate to iexplore.jsp file.

The iexplore.jsp is going to read the file structure under your deployed web application WEB-INF and display it using the RichFaces <rich:tree> and <rich:recursivetreenodesadaptor> components.

This application may sound too much for a beginer, but once you get it up and running you will learn everything you want to build a sophisticated RichFaces web application. That is my motto !

Step 10:

Right click on RichFaces->WebContent->index.html and select Run As->Run on Server

Under 'Select the server type' choose 'Tomcat v6.0 Server' and click Next.

Click on 'Browse' button under 'Tomcat installation directory'.

Choose you (on my system it is C:\Program Files\Apache Software Foundation\Tomcat 6.0)

Click Next. The wizard should look like the one shown below.

Click 'Finish'. Eclipse will start the tomcat server and deploy your RichFaces web application.

You should see the following in the eclipse browser.

CONGRATULATIONS ! You have learned all the technologies needed to develop RichFaces/JSF web applications.

Note 1: If you are stuck or if any of the download links are broken please write to me. I will fix it in this article.

Note 2: I didn't had time to explain in detail about the web.xml & faces-config.xml. I will explain them later on demand.

Thursday, October 9, 2008

Eclipse RCP Update Manager

Today, I did tried adding the update manager UI and setting up an update site for my eclipse RCP application. Everything went fine. I did set up the menu item Update->Software Updates. Added my update site and able to locate the new features :) I was happy and believe me its a cool feature eclipse provides. But the moment I selected my new feature under (Select the features to install), the 'Updates' dialog throws the following error :

Resulting configuration does not contain the platform

oops ! I tried debugging this issue for hours. Googled .... and found out that for your Update Manager to work properly you need to have everything as a feature and no-plugins. If you created a product file for your eclipse RCP application with 'plugins' turned on under 'The product configuration is based on:' tab of your product files 'Overview' section, you need to changed the option from 'plugins' to 'fetaures'. Hold on ! You have other things to do ....

I would suggest you to follow the Section 9 - Add Update-Manager to rcpmail of

I got this link from the eclipse RCP FAQ Page -

Don't give up. It worked for me and definitely it will work for you too.

Write to me if you still find it difficult to make it work. I will help you.

Wednesday, August 13, 2008

Attn SWT Developers !

Every SWT developer should browse before you decide to go with SWT. Iam not against SWT ! Iam actually an EClipse RCP programmer. You should know what you are doing before you start. Once started there is no way out !