ClassCastException for same class on slim3 for Google App Engine

Bug: A class cast exception like the following is thrown – class x.y.z.MyClass cannot be cast to class x.y.z.MyClass

Reason: The class loaders for both these class instances are different. One of the classloader is the usual one used by AppEngine JVM, while other one is used by the hot reloader.

Solution: Remove the Filter and Filter-Mapping for HotReloadingFilter from web.xml.

jqGrid cell data disappears on clicking other cells

Bug: jqGrid cell data in a previously edited cell disappears on editing other rows. This usually occurs after a cell or row value is edited programmatically.

Reason: A cell could not reset its DOM to display mode from Edit mode.

Fix:  Fix is to restore an edited row/cell before doing further operations on its event handler functions ( like launching a new dialog to put in some processed value back to it using script).

UTF-8 encoding on J2EE

A 3 step method to apply UTF-8 encoding to J2EE applications.

1. Add the following directives to the page included in ALL jsps.

This will add request headers and meta-tags to every page served which will tell the browser that the page is utf-8 encoded.

2. Add a filter at server side to encode the request body received to UTF-8. A spring UTF-8 encoder (available in org.springframework.web*.jar of spring 3 distribution) if used, will have the following changes in web.xml:

3. Tell the container that the URLs too are to be encoded in UTF-8. In tomcat, this is done by adding the attribute URIEncoding=UTF-8 to the connector tag in server.xml. Else, this can also be done by setting useBodyEncodingForURI=true in the connector tag. This will tell the connector to use the same encoding used for the request body (set to UTF-8 in the previous steps.) This will make sure that the parameters received via GET requests too are properly understood by the application.


An MS DOS game where you shoot opponent fighter plane and save yourself from incoming missiles 😉

Download code here.

(Note/Disclaimer : Last successful compilation of most of the programs in this category were done from 2000 to 2002.)

C Chess

A simple Chess program written in C. Serves as an introduction to basics of programming the game.

Download code here.

(Note/Disclaimer :Given on as is basis (written by author during high school – 1999 to 2001))

Solution to Hibernate error: Unknown column ‘******’ in ‘order clause’

Bug: A above exception thrown when using hibernate.

Reason: This error occurs usually because of a misplaced “order by” clause.
If in a many to many mapping, the serial order is defined in the cross reference table, the order-by attribute should be provided in the “collection” node as below –

On other hand, if the collection is to be sorted by a column defined in the collection member, the order-by should be provided in the many-to-many or one-to-many node, as shown below.

Solution: Move the order-by attribute to appropriate node depending on which table holds the sorted field.

Solution to MySQLSyntaxErrorException: Unknown column ‘xxxxx_.elt’ in ‘field list’

Bug: The above exception thrown when using hibernate.

Reason: This usually occurs when column name is not mentioned in many-to-many node.
The correct mapping for a many to many relation is –

Solution: The mapped columns should be provided in the key and many-to-many nodes as above.

Spring security 3 – How to display login errors ?

Heres how we display different error messages for the different cases of authentication failures like bad credentials, credentials expired etc.

Step 1. Configure an authentication failure handler in the application context.

Step 2. Refer this handler in the form-login node of http namespace configuration.

Step3. Capture the different URL extensions configured in step 1 in the login controller. (The example below uses Spring MVC)

Step 4. Check the attribute error in the JSP and print appropriate message for each case.

Done !