Question

I know it's not optimal, but I have to work with it, a page making calls to the applet.

My problem is, when I do so, I recieve a rather cryptic error message:

"uncaught exception: Error calling method on NPObject!

[plugin exception: java.lang.reflect.InvocationTargetException]."

Can anyone decode this? Even multiple possibilities would be better than the junk I came up with. The basic call to the applet is from a javascript call:

document.getElementById('my_applet').passData("pass some data", someOtherData);

As you can see, the passData method is the exposed method I am trying to use. The applet itself works fine on the page, it's just when I try to call this, it doesn't do anything except throw that error.

If I ask the person working on the applet (it's not my portion) is it possible for them to add constructive error throwing or am I not even at the point of connecting to the applet yet?

Was it helpful?

Solution

InvocationTargetException indicates that the underlying method in your applet threw an exception. The Javascript to Java "boundary" uses reflection, so exceptions thrown by the Java code are wrapped like this. (This makes it possible to distinguish them from exceptions thrown before you got into your Java code. For example, if you tried to call a non-existant method.)

You can get the original exception by catching the InvocationTargetException and then calling its getTargetException() or getCause() method (they both do exactly the same thing).

OTHER TIPS

I'd suggest you look into what someOtherData is. If someOtherData isn't a correct type it could cause such an exception. It sounds like you're trying to pass a DOM object?

Take a look at this page in O'Reilly's JavaScript Guide to see available types.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top