Friday, May 21, 2010

Unix commands

Search in all directories and subdirectories for stringToFind
find . | xargs grep -s stringToFind

Cron jobs are located in /var/spool/cron/crontabs
crontab -l

Search for files

find . -name "filename.ext" -print 2> /dev/null

Create Axis Web Service stubs/artifacts using soapUI

It is very easy to generate Axis web service stubs (artifacts) using soapUI tool. NOTE: This can also be done using the commands

Put file in C:\Projects\Jars\axis-1_4\lib
cd C:\Projects\Jars\axis-1_4\lib
java -cp %AXISCLASSPATH% org.apache.axis.wsdl.WSDL2Java -p<packageName> <WSDLFileName/ URL>

soapUI is a web service, SOA, SOAP testing tool which provides a GUI for generating these stubs for those who do not like the command line. soapUI is a free open source desktop application for inspecting contract, invoking, developing, testing (functional, load, compliance, simulation) web services.

First in File-> Preferences->Tools tab set the Axis 1.x directory where you have downloaded the library files. Axis libraries can be downloaded out here :


Tools->Axis 1.0 Artifacts


Put in the WSDL and the directory where you want the stubs to be located


In the Advanced tab you can specify the package where stubs should be placed


Generate button will start the task of generating stubs




In the following articles I will demonstrate how I called the web service using these stubs.

Tuesday, May 18, 2010

dwr 3.0 with Spring 3.0

dwr 3.0 is still in development stages but after checking out dwr 2.0 which requires XML configuration I was willing to take the risk of diving into a release candidate library under heavy development.


  1:   <context-param>
  2:     <param-name>contextConfigLocation</param-name>
  3:     <param-value>/WEB-INF/applicationContext.xml</param-value>
  4:   </context-param>
  5:   <listener>
  6:     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  7:   </listener>
  8:   <servlet>
  9:     <servlet-name>dispatcher</servlet-name>
 10:     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 11:     <load-on-startup>2</load-on-startup>
 12:   </servlet>
 13:   <servlet-mapping>
 14:     <servlet-name>dispatcher</servlet-name>
 15:     <url-pattern>*.do</url-pattern>
 16:   </servlet-mapping>
 17:   <servlet-mapping>
 18:     <servlet-name>dispatcher</servlet-name>
 19:     <url-pattern>*.html</url-pattern>
 20:   </servlet-mapping>
 21:   <servlet-mapping>
 22:     <servlet-name>dispatcher</servlet-name>
 23:     <url-pattern>/dwr/*</url-pattern>
 24:   </servlet-mapping>

Notice there is no DwrServlet. Everything goes to Spring’s DispatcherServlet


  1: <?xml version="1.0" encoding="UTF-8"?>
  2: <beans xmlns=""
  3:   xmlns:xsi="" xmlns:p=""
  4:   xmlns:aop="" xmlns:tx=""
  5:   xmlns:context=""
  6:   xmlns:dwr=""
  7:   xsi:schemaLocation="
 15:   <!-- Annotation-based configuration-->
 16:   <context:annotation-config />
 18:   <!--
 19:     To remove the explicit bean definitions: Spring can scan package names
 20:     to find beans to manage as follows
 21:   -->
 22:   <context:component-scan base-package="*" />
 24:   <!-- Enable DWR AJAX functionality-->
 25:   <dwr:configuration />
 26:   <dwr:annotation-config />
 27:   <dwr:annotation-scan />
 28:   <dwr:url-mapping />
 29:   <dwr:controller id="dwrController" debug="true" />
 31:   <!--AnnotationMethodHandler-->
 32:   <bean
 33:     class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
 34:   <!-- bean
 35:     class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /-->

  • Note line number 6, 12, 13. This is to enable DWR namespace

  • Note the order of lines 25-29. If you miss annotation-scan your bean converters will not work and instead of the JSON output you will get the following error

  • I have commented line 9.  This issue has more to do with Spring configuration than DWR. Since you are specifying the AnnotationMethodHandlerAdapter the normally provided (by default) BeanNameUrlHandlerMapping is no longer provided (Spring does not provide it if another handler is specified. Error message thrown is :-

    • 2010-05-18 09:21:39,640 ERROR [dispatcher]:{} - Servlet.service() for servlet dispatcher threw exception

      javax.servlet.ServletException: No adapter for handler [org.directwebremoting.spring.DwrController@1352447]: Does your handler implement a supported interface like Controller?

          at org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(

          at org.springframework.web.servlet.DispatcherServlet.doDispatch(

          at org.springframework.web.servlet.DispatcherServlet.doService(

          at org.springframework.web.servlet.FrameworkServlet.processRequest(

          at org.springframework.web.servlet.FrameworkServlet.doGet(

          at javax.servlet.http.HttpServlet.service(

          at javax.servlet.http.HttpServlet.service(

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(


          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(

          at org.apache.catalina.core.StandardWrapperValve.invoke(

          at org.apache.catalina.core.StandardContextValve.invoke(

          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(

          at org.apache.catalina.core.StandardHostValve.invoke(

          at org.apache.catalina.valves.ErrorReportValve.invoke(

          at org.apache.catalina.core.StandardEngineValve.invoke(

          at org.apache.catalina.connector.CoyoteAdapter.service(

          at org.apache.coyote.http11.Http11Processor.process(

          at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(



          at org.apache.tomcat.util.threads.ThreadPool$


    • Read more here :


  1: package service.impl;
  3: import java.util.ArrayList;
  5: import org.directwebremoting.annotations.RemoteMethod;
  6: import org.directwebremoting.annotations.RemoteProxy;
  7: import org.springframework.beans.factory.annotation.Autowired;
  8: import org.springframework.stereotype.Service;
 10: import beans.Printer;
 11: import dao.jdbc.VmecsDaoJdbc;
 13: @Service
 14: @RemoteProxy
 15: public class DwrService {
 17: 	@Autowired
 18: 	private DaoJdbc db;
 21: 	@RemoteMethod
 22: 	public ArrayList<Printer> getPrinters() {
 23: 		return this.db.getPrinters();
 24: 	}
 25: }

Bean converter

  1: package beans;
  3: import org.directwebremoting.annotations.DataTransferObject;
  4: import org.directwebremoting.annotations.RemoteProperty;
  5: import org.directwebremoting.convert.BeanConverter;
  7: @DataTransferObject(converter = BeanConverter.class)
  8: public class Printer {
  9: 	@RemoteProperty
 10: 	private String printerName;
 11: 	@RemoteProperty
 12: 	private String queueName;
 14: 	/**
 15: 	 * @return the printerName
 16: 	 */
 17: 	@RemoteProperty
 18: 	public String getPrinterName() {
 19: 		return this.printerName;
 20: 	}
 22: 	/**
 23: 	 * @param printerName
 24: 	 *            the printerName to set
 25: 	 */
 26: 	public void setPrinterName(String printerName) {
 27: 		this.printerName = printerName;
 28: 	}
 30: 	/**
 31: 	 * @return the queueName
 32: 	 */
 33: 	@RemoteProperty
 34: 	public String getQueueName() {
 35: 		return this.queueName;
 36: 	}
 38: 	/**
 39: 	 * @param queueName
 40: 	 *            the queueName to set
 41: 	 */
 42: 	public void setQueueName(String queueName) {
 43: 		this.queueName = queueName;
 44: 	}
 46: }

Browse to the test page:-


Enter input (if required) and hit Execute. The output is JSON


I have not explained the annotations since they seem to be self-explanatory. If you have any questions leave a comment.

Monday, May 17, 2010

Change default Eclipse workspace

  1. Go to installed directory eg. c:\Program Files\Eclipse
  2. Go to configuration directory
  3. Look out for config.ini
  4. Change the value of osgi.instance.area.default

eg. osgi.instance.area.default=c:/Projects

Friday, May 14, 2010

Microsoft Office Live Workspace does not work for FireFox


Office Live Workspace is back…again?

Look what I received in my email today. Last time I used Offlice Live Workspace beta – My editing rights were removed without informing me that the beta period had expired. I found out the hard way. When I click on a word doc it used to prompt me to download!

At present, I use Ms Office Live Workspace as a backup for my Google docs account. Should I try Ms again? That depends on whether it is beta and the “soon” factor

Microsoft Office Live 
Arrow icon

Your Office Live Workspace account will be upgraded for free.

Good news!

Your Microsoft Office Live Workspace beta account is about to become even better. You already know it’s a great way to store and share documents, and soon it will come together with Windows Live SkyDrive to become a great way to view, create, and edit documents from virtually anywhere.

In the coming months, you’ll receive notification when your Office Live Workspace account will be upgraded, along with further details. Until then, there’s no need for you to do anything.

With your SkyDrive account, you’ll get 25 GB of online storage for sharing both documents and photos. Your SkyDrive account is designed to work smoothly with other Windows Live services like Hotmail and Messenger. And you’ll be able to view and edit documents from virtually anywhere* using new Microsoft Office Web Apps.

Questions? Visit the Office Live Workspace upgrade center.

* An appropriate device, Internet connection, and Internet Explorer, Mozilla Firefox, or Safari browser are required.


©Microsoft Corporation. One Microsoft Way, Redmond, WA 98052-6399, USA
All rights reserved. Legal | Trademarks | Privacy

Wednesday, May 12, 2010

How to downgrade grails to previous version

  1. Manually delete the new Grails installation from c:\grails and override it with older grails installation
  2. Delete version related upgraded plugin zips from C:\grails\plugins. This is very easy to identify by the suffix eg. works for Grails version 1.2.2 and works for Grails version 1.3
  3. Delete zip and directory in C:\Documents and Settings\vsanzgiri\.grails\<old_version>\projects\<ProjectName>\plugins
  4. Delete zip from C:\Documents and Settings\vsanzgiri\.grails\<old_version>\plugins
  5. Delete directory C:\Documents and Settings\vsanzgiri\.grails\<new_version>

Replace all orange items with Project specific, version specific and system specific settings

You might have to uninstall and reinstall some plugins depending on the plugins that are complaining when you run clean, upgrade or run-app command.

grails –clean

“Resolve plugins” if you are using Netbeans

grails –upgrade

NOTE: This is not a foolproof way to downgrade grails version. These are just some notes I remember from my ordeal.

Tuesday, May 11, 2010

JavaScript:history.go(-1) not working in Firefox


If you want to go to the last page or referer application history.go(-1) works for IE but it does not work in FireFox.

<a href="javascript:void(0);" onClick="JavaScript:history.go(-1);">Back</a>

The fix is to use history.back(); return false; as shows below:-

<a href="javascript:void(0);" onclick="history.back(); return false;">Back</a>


Monday, May 10, 2010

Upgrade Grails

To upgrade grails on a project I download the latest distribution binary zip from and unzip it over my old installation on c:\grails to override my older installation.

On starting Netbeans it automatically downloads the updated dependencies:-

Welcome to Grails 1.3.0 -
Licensed under Apache Standard License 2.0
Grails home is set to: c:\grails

Base Directory: C:\Projects\ProjectEditor
Resolving dependencies...
Downloading: c:\grails\lib\gpars-0.9.jar ...
Download complete.
Downloading: c:\grails\dist\grails-docs-1.3.0.jar ...
Download complete.
Downloading: c:\grails\dist\grails-bootstrap-1.3.0.jar ...
Download complete.
Downloading: c:\grails\dist\grails-scripts-1.3.0.jar ...
Download complete.
Downloading: c:\grails\dist\grails-core-1.3.0.jar ...
Download complete.
Downloading: c:\grails\dist\grails-resources-1.3.0.jar ...
Download complete.
Downloading: c:\grails\dist\grails-web-1.3.0.jar ...
Download complete.
Downloading: c:\grails\lib\groovy-all-1.7.2.jar ...
Download complete.
Downloading: c:\grails\dist\grails-crud-1.3.0.jar ...
Download complete.
Downloading: c:\grails\dist\grails-gorm-1.3.0.jar ...
Download complete.
Downloading: c:\grails\dist\grails-spring-1.3.0.jar ...
Download complete.
Downloading: c:\grails\lib\junit-4.8.1.jar ...
Download complete.
Downloading: c:\grails\dist\grails-test-1.3.0.jar ...
Download complete.
Dependencies resolved in 63984ms.

I then run the upgrade command on individual projects:-

grails upgrade

Running script c:\grails\scripts\Upgrade.groovy

Environment set to development

                WARNING: This target will upgrade an older Grails application to 1.3.0.

                Are you sure you want to continue?

                                    (y, n)

NOTE: Your application currently expects grails version [1.2.2], this target will upgrade it to Grails 1.3.0 ...


   [delete] Deleting directory C:\Documents and Settings\vsanzgiri\.grails\1.3.0\projects\ProjectEditor\resources

     [copy] Copying 1 file to C:\Projects\ProjectEditor\web-app\WEB-INF

     [copy] Copying 1 file to C:\Projects\ProjectEditor\web-app\WEB-INF

     [copy] Copying 4 files to C:\Projects\ProjectEditor\web-app\WEB-INF\tld

Installing zip c:\grails\plugins\ ...

    [mkdir] Created dir: C:\Documents and Settings\vsanzgiri\.grails\1.3.0\projects\ProjectEditor\plugins\hibernate-1.3.0

    [unzip] Expanding: c:\grails\plugins\ into C:\Documents and Settings\vsanzgiri\.grails\1.3.0\projects\ProjectEditor\plugins\hibernate-1.3.0

Installed plugin hibernate-1.3.0 to location C:\Documents and Settings\vsanzgiri\.grails\1.3.0\projects\ProjectEditor\plugins/hibernate-1.3.0. ...

Resolving plugin JAR dependencies ...

Executing hibernate-1.3.0 plugin post-install script ...

Plugin hibernate-1.3.0 installed

Installing zip c:\grails\plugins\ ...

    [mkdir] Created dir: C:\Documents and Settings\vsanzgiri\.grails\1.3.0\projects\ProjectEditor\plugins\tomcat-1.3.0

    [unzip] Expanding: c:\grails\plugins\ into C:\Documents and Settings\vsanzgiri\.grails\1.3.0\projects\ProjectEditor\plugins\tomcat-1.3.0

Installed plugin tomcat-1.3.0 to location C:\Documents and Settings\vsanzgiri\.grails\1.3.0\projects\ProjectEditor\plugins/tomcat-1.3.0. ...

Executing tomcat-1.3.0 plugin post-install script ...

Plugin tomcat-1.3.0 installed

Plugin provides the following new scripts:


grails tomcat

Please make sure you view the README for important information about changes to your source code. ...

Project upgraded

Sunday, May 09, 2010

Install reCAPTCHA image verification for PHP

The reCAPTCHA PHP Library provides a simple way to place a CAPTCHA image verification on your PHP website, helping you stop bots from abusing it. The library wraps the reCAPTCHA API.

  1. Download the reCAPTCHA Library, unzip it, and copy recaptchalib.php to the directory where your forms live.
  2. sign up for an API key.
  3. Add code to display the CAPTCHA:
    $publickey = "..."; // you got this from the signup page
    echo recaptcha_get_html($publickey);

  4. In the code that processes the form submission, you need to add code to validate the CAPTCHA. Otherwise, the CAPTCHA will appear, but the answers won't be checked. The validation code looks like:
    $privatekey = "...";
    $resp = recaptcha_check_answer ($privatekey,

    if (!$resp->is_valid) {
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
    "(reCAPTCHA said: " . $resp->error . ")");

This tip is when you use ssl (https). reCAPTCHA code by default is not for ssl and hence IE8 would show the following popup:-


Now if you click Yes – you will not get the reCAPTCHA code since it is http code and if you click No – you will see reCAPTCHA.

Code for reCAPTCHA looks like this :-

$publickey = "..."; // you got this from the signup page
echo recaptcha_get_html($publickey);

The reCAPTCHA website does not have any code to explain this. But if you go through the library you will see that you have to change the last line of the above code to say:-

echo recaptcha_get_html($publickey,null,true);

First parameter is your public key, second is your error string and third is whether ssl is enabled. We have used reCAPTCHA for our Asha for Education donation page

Wednesday, May 05, 2010

<form:label/> in Spring should have MessageSource support

If you have used any version of Spring upto 3.0 you would be surprised when using form:label tag:-

<form:label path=""/>  
does not render anything in HTML. You would not see the data in in the resultant HTML. In fact the html equivalent would be <label for=""></label>

For the text to show in your view use <form:label path="">The actual label</form:label>
eg. <form:label path="">${}</form:label>

There is already a Spring JIRA issue for the MessageSource support:

Monday, May 03, 2010

Toad for Oracle 10.5 upgrade

Toad for Oracle 10.5 released in mid-April 2010 and I decided to give the (not so easy) update a shot.

Help->Check for Updates on 10.1 said there was no upgrade available


Based on my prior experience you need to manually download the latest executable from their website  This requires a Site ID which validates your license and your profile.

After logging in search for ‘Toad for Oracle’


Click on the Downloads tab


You would need to know your licensed products. Quest allows you to download all executables if you are not licensed it will only show up as a trial version. I used the Toad for Oravle 10.5 Commercial Installer



Toad does not upgrade the previous version. After installing you will have to import settings from the older version and then uninstall the older version


I had to change the folder to make it work


The Quest SQL Optimizer for Oracle requires you to have .Net Framework. What’s weird about this is there is no version of .Net Framework named 2.1. I received this error message even after I installed 4.0






I love Toad and I am going to give its Toad for MySQL freeware a try :

Sunday, May 02, 2010

How to solve - SEVERE: Error listenerStart

Ever get the SEVERE: Error listenerStart and can't find the error? Logs don't seem to help since this is a container start up problem.

May 3, 2010 3:01:09 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_07\bin;C:\Program Files\Tomcat\5.5\bin;C:\oracle\ora10_2\BIN
May 3, 2010 3:01:10 PM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
May 3, 2010 3:01:10 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 984 ms
May 3, 2010 3:01:10 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
May 3, 2010 3:01:10 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.26
May 3, 2010 3:01:10 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
May 3, 2010 3:01:15 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
May 3, 2010 3:01:15 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/CameraProject] startup failed due to previous errors
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.

May 3, 2010 3:01:15 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 3, 2010 3:01:16 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /
May 3, 2010 3:01:16 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/63  config=null
May 3, 2010 3:01:16 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
May 3, 2010 3:01:16 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6391 ms

Start Tomcat
I'm using tomcat - and whilst I understand Jetty is meant to be good for development, it doesn't seem to yet support eclipse 3.2. You probably have a script to start and restart tomcat or using a plugin to restart it. I'm using sysdeo ( which seemed to me to be the most common. With the sysdeo plug in I can start my tomcat in eclipse which can link in to the debugger. In this case I have used MyEclipse to reproduce the error.

Attach the source
in your build path (project properties, java build path) select the libraries tab and the spring jar. Expand the + and click on source attachment, and edit the path to be the spring source 'src' directory. I manually downloaded spring 3.0 release with the sources and pointed to that jar file :

Set Breakpoint in ContextLoaderListener
In the spring jar on the build path, find org.springframework.web.context and the ContextLoaderListener class. Set a breakpoint at line which will read this.contextLoader.initWebApplicationContext(event .getServletContext()); This will be around line 47 (Spring 3.0)

find the error!
Now when you start tomcat from within an eclipe plugin it will stop at the above. Choose to 'step return' once and then wait for the container to load everything up and find an error. If there is an error you will now be at standardcontext.listenerstart and you can now look at the error in the variable window under 't'. There are 'cause' error, make sure you take a look at them all since some can be wrapped/hidden. If you're using hibernate, I find that this does show the hbm mapping file problems, but the actual bean which causes the error can be wrong - it seems to just take the first bean in its list!



In my case the error was :- class path resource [] cannot be opened because it does not exist