Skip to main content


Showing posts from 2008

Changing the root web application in Tomcat 6

These days I am very busy developing a large and complex web application, which is nearing its first release. This web based product runs on Tomcat 6 and will be deployed on
But if I deploy my web application on Tomcat 6, I need to specify the context root. Well this is no good, why will the users of this website be willing to remember the context root. What if the context root changes. In other words the users would not be interest in typing the following - to visit this site.
Hence it is necessary that I change the default / root web application of Tomcat and point it to my application. I wanted to try and test this on localhost first. As always I Googled and found a number of posts and none seem to work. I also read the documentation it was helpful in understanding the concepts but was not effective as I could not get it working. Finally after few hours of trial and error one of my colleague Joyeeta Majumdar found the so…

Consuming a JMS Message from ActiveMQ using Spring Message Driven POJO

In my last post, I had shown how you can post a JMS message to a ActiveMQ queue. In this post I will show the reverse process. I will not try to consume this message using a Spring Message Driven POJO. I assume your familiarity with Spring MDP. If not you can look here -
The operation that I intend to carry out is depicted in Figure 1.

Step 1 - Create the message listener.
Listing 1 -

Step 2 - Wire up the bean in Spring configuration
Listing 2 - spring-activemq-config.xml

Step 3  - Test
Finally you can see the results of message produced and consumed in the Admin web console as shown in Figure 2.

Sending JMS message to ActiveMQ using Spring 2.5 from a web application

Last Updated 04/16/2017

In this post, I will show how you can send JMS message to ActiveMQ from your Spring web application. I have a Spring 2.5 + JBOSS Richfaces based web application that runs on Tomcat 6 running on JDK 5. Figure 1. depicts what I intend to do.

Step 1: Drop in the following jars to WEB-INF/lib
activemq-core-5.2.0.jarjms.jargeronimo-j2ee-management_1.0_spec-1.0.jarStep 2: Create the destination/Queue using the ActiveMQ admin web application.

Launch your browser and point it to - http://localhost:8161/admin/

Click on 'Queues' to navigate to queue list and create screen. You will need to supply the queue name and click on 'Create' to create a new queue destination on ActiveMQ server. This is shown in Figure 3.

Step 3. Create a message producer interface.
This may not be necessary, but since I prefer to implement Program to Interface in my application I define a message producer interface.

This interface defines a single method(can have more, but for now th…

Initializing static fields of Spring beans

New Solution - Updated 4/16/2017

The old solution shown below is very cumbersome. So here is the new solution which is much easier.

Old solution

This solution is courtesy Chris Harris UK.
Step 1: Create a bean factory post processor. Step 2 : Create the simple test classStep 3 : Finally wire up everything in Spring configuration file