The invocation exception is generally an indication of some exception in the Java code. When calling a Java method, make sure it's public and any exceptions are caught and dealt with in your code.
In my case, the above exception occurs only in Safari (Firefox works well, and I am not sure if the type cast is done by the browser). The last line of Java console shows that a String has been returned from the Java method, which is passed to my Javascript method. However, I need to convert that Java.lang.String to Javascript object first, i.e., add the following line.
var myJSString = new String(stringsReturnedFromJavaMethods);
And voila, no exceptions any more.