Enabling CORS in tomcat

If you need to enable CORS in tomcat ( or alternatively just serve your response in JSON-P format) you will need version 7.0.41 or greater.

Simply add the following in your web.xml file


This will ensure that the client browser honors the response that is returned from your app server.
You only need this if the client domain is different from the server which is returning your response.

Maven builds without error but eclipse shows errors

If you use maven to build your eclipse projects, you may notice at times that your eclipse IDE would show errors ( especially if you modified your pom to pull in new dependencies) but maven builds without errors.

To fix this you run the following commands – make sure to close eclipse and reopen it

mvn clean eclipse:eclipse

What this does is that it blows aways all eclipse configs and recreates those.

OR you can alternatively not use maven and just use gradle :-)

Android ADB Screencapture

The following command will capture your android device’s screen using adb

adb shell screencap -p | perl -pe ‘s/\x0D\x0A/\x0A/g’ > MyScreen1.png

Recursively delete files and folder like .svn or .DS_Store

The following command would recursively delete files and/or directories on your *nix (+OSX) system

find . -type f -name .DS_Store -exec rm -rf {} \;

Since .DS_Store is a file I have used “f” flag in the find command.

If you need to delete directories then use the “d” flag like

find . -type d -name .svn -exec rm -rf {} \;

Python script for converting raw mac address

Recently I converted one of my perl scripts which converts a raw mac address list file to a well formatted mac address list to a python script.

(eg)convert 12ED7e7890 to 12:ED:7E:78:90


Here is the code snippet. – Input is the raw mac address list file.



import sys

inFile = sys.argv[1]

fileR = open(inFile, ‘r’)
fileW = open(inFile+”.final”,’w’)

for line in fileR:
fileW.write(‘:’.join(map(”.join, zip(*[iter(line.upper())]*2))) )


Mac OSX DNS failure on VPN

If you are connected to your corp VPN and DNS lookup fails for all your corp hosts, then try the below solution

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

This basically bounces the mDNSResponder

JAX-WS 2.2 on Java 6 – maven endorsed

If you create webservices stubs using apache CXF 2.5+, you will most likely run into the following error when you compile your app on Java 6. [Why still Java 6 :-( ]

You will probably run into the following error.

“This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 API jar”

In my case I was using maven to build my project. maven2+JAX-WS API 2.2 on Java 6 dont really play well with the default config. Add the following to your pom.xml to endorse JAX-WS 2.2


Get every new post delivered to your Inbox.