User exception sometimes wrapped with UndeclaredThrowableException
mikasch Mar 3, 2010 12:08 PMI am using JBoss AS 4.2.3.GA (a short time ago migrated from 4.0.5) and a separate Tomcat.
There are cases where the JBoss is throwing a ValidationException in a Stateless Session Bean (EJB2) to show the user, that he has to fill the forms on the GUI correctly.
So now when working with the tomcat running on the same machine as the jboss it occurs very often - but not always! - that the thrown ValidationException is wrapped by an UndeclaredThrowableException. At the GUI a can save the same (wrongly filled) form 10 times and get about 7 times an UndeclaredThrowableException and about 3 times the unwrapped ValidationException.
I noticed that the communication between tomcat and jboss has changed between 4.0.5 and 4.2.3. Where in 4.0.5 it was RMI over port 4444 it is now Remoting Service over port 4446.
What puzzles me: how does it come that the ValidationException is sometimes wrapped and sometimes not by the UndeclaredThrowableException, and does it have anything to do with the migration to 4.2.3?
Additionally what is also interesting: I don't see this problem when the tomcat and the jboss run on different machines.
I saw many postings regarding the UndeclaredThrowableException, but nowhere I could read "sometimes".
First I thought that this could be a ClassLoader issue. I checked the jars that are deployed in the tomcat and in the jboss. There is only one jar file that contains the ValidationException.class and both jar files (one in jboss and on in tomcat) do have the same md5 check sum.
The ValidationException implements Serializable but not RemoteException.
Does someone has an idea, what is going wrong?
A few lines from the logs:
handleUnexpectedException() - got unexpected exception:
java.lang.reflect.UndeclaredThrowableException
at $Proxy23.saveFeaturePackage(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1344.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
[...]
Caused by: [...].ValidationException