HelloWorld for PhantomReference

PhantomReference allows a programmer to know that an object has been garbage collected. And hence the programmer can do something else when an object is collected. Today I was working on a code that was using PhantomReference. And since I had never worked with it so I decided to write some tests and see how it … Read more

Migrating from tomcat 6 to tomcat 7

Recently I was working on an application and we were using tomcat 6 as the web container. We were changing from tomcat 6 to tomcat 7. I wanted to do it very easy, so just copied the server.xml from tomcat 6 and pasted it into the tomcat 7 config folder. I did so that I … Read more

Eclipse Tips

Here are eclipse tips and tricks that I find useful in everyday use of eclipse. Eclipse shortcuts: Shortcuts I use everyday Ctrl+1 seems to be the most useful shortcut of eclipse. It shows the quick help. e.g. create getter and setter on a property or rename a property. If you see an error or warning … Read more

Thread safe caching of JAX-WS clientproxies

According to http://cxf.apache.org/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe? , clientproxies are not thread safe so I decided to create a Component which can pool the connections. I do it it by using Singleton design pattern. What is handled by this Singleton: This class creates the connections on the start and then caches them If the connection to the server is not available … Read more

GWT nocache.js cached by browser

Recently we faced an issue with the GWT deployment. Whenever we were doing a new deployment the users seemed to get errors as the gwt did not refresh the javascript files even when the user reloaded the page. Then the temporary solution was to reload all the files using Shift+F5.  All our pages had this … Read more

How should autocomplete work?

We were recently developing an application that has a fixed set of data. The data may change very little over time. And this application has one search box to search over all this data. The search page is quite like google page with one search box and search results showing on the page    So … Read more

migrate from maven2.x to maven3.x

Recently I migrated an application from maven2.x to maven3.x. And the only issue we faced was that profiles.xml was used in maven2. Here is the warning raised by maven3 while building. Since we had all the properties for building in profiles.xml so the first step we took was to copy these properties into pom.xml. And … Read more

maven properties in pom.xml converted to properties file

With maven 3.x profiles.xml is no longer supported. We had all our properties in the profiles.xml. So we changed to maven 3 and had to convert properties in profiles.xml to properties file. Here are the details about maven2.x to maven3.x migration   So here is the java utility class that reads the properties in pom.xml … Read more

Start background thread using spring on startup

In this tutorial we will start a thread on the application startup using spring bean.So we will start the thread using @PostConstruct annotation on the method. So this makes sure that the annotated method is called before the Spring bean is put into service.  And we will be using executor service to start a thread. … Read more

Properly Shutting down an ExecutorService

I was recently working on an application that used hibernate for db access and lucene for storing and searching text. This combination was really great. It made searching really fast. And tomcat was used as the application container.Sometimes I used to get this exception on redeploy: And also tomcat used to complain that it could … Read more