To enable JGroups on ubuntu system

While you are using jgroups on ubuntu you might get this exception

INFO: JGroups version: 2.6.16.GA
org.jgroups.ChannelException: failed to start protocol stack
	at org.jgroups.JChannel.startStack(
	at org.jgroups.JChannel.connect(
	at org.jgroups.demos.Draw.go(
	at org.jgroups.demos.Draw.main(
Caused by: java.lang.Exception: problem creating sockets (bind_addr=shekhar/, mcast_addr=
	at org.jgroups.protocols.UDP.start(
	at org.jgroups.stack.Configurator.startProtocolStack(
	at org.jgroups.stack.ProtocolStack.startStack(
	at org.jgroups.JChannel.startStack(
	... 3 more
Caused by: bad argument for IP_MULTICAST_IF: address not bound to any interface
	at Method)
	at org.jgroups.protocols.UDP.createSockets(
	at org.jgroups.protocols.UDP.start(

To solve this you need to disable ipv6 on ubuntu. To do that do the following

java -classpath /home/shekhar/JB431/opt/jboss-soa-p-5/jboss-as/lib/concurrent.jar:/home/shekhar/JB431/opt/jboss-soa-p-5/jboss-as/common/lib/commons-logging.jar:/home/shekhar/JB431/opt/jboss-soa-p-5/jboss-as/server/all/lib/jgroups.jar org.jgroups.demos.Draw

Introducing Spring Roo, Part 3: Developing Spring Roo add-ons

Spring Roo is a RAD tool that lets you build applications (mainly web) quickly and easily. Under the hood, Spring Roo is based on OSGI add-on architecture, which makes it easy to extend Spring Roo by adding add-ons. Spring Roo provides commands to create add-ons that can be very easily made available to the Spring Roo user community. In this article, we first talk about Spring Roo architecture, talking about how Spring Roo leverages its own add-on architecture to provide different features, then we will create add-ons using the Roo shell and modify them to suit our needs. Please read the third article at IBM DeveloperWorks.

Java Puzzler : They just find me !!

Couple of days back I wrote a piece of code which was behaving in an unexpected manner. I was confused what was happening. Take a look at the sample code below and predict its behavior

package com.shekhar;

public class JavaPuzzler {

	public static void main(String[] args) {
		JavaPuzzler javaPuzzler = new JavaPuzzler();

	public void doSth() {
		float f = 1.2f;
		if (f >= 1.0) {
			f = 0.9999999999999f;
		InnerClass innerClass = new InnerClass(f);

	private class InnerClass {

		private float value;

		public InnerClass(float value) {
			if (value >= 1.0f) {
				throw new IllegalArgumentException(
						"Value can't be greater than 1.0f");

			this.value = value;

		public float getValue() {
			return value;

My initial expectation was that I would get value 0.9999999999999f as answer.Try it and find the answer. Share your answer and reasoning in comments.

How to exclude a sub package from Spring component scanning?

Suppose you are using Spring component scanning and you don’t want to scan classes in the sub-package you should use <context:exclude-filter> subtag of <context:component-scan> tag as shown below

<context:component-scan base-package="">
	<context:exclude-filter type="aspectj" expression="*" />

Here we have defined a aspectj pointcut which will exclude all the classes in the sub-package.