-
1. Re: UndeclaredThrowableException when setting value on remot
lisa_r Oct 29, 2001 3:24 AM (in response to banigreyling)Hi BANIGREYLING,
I have the exact same problem that you have/had. If you see this can you please tell me how you solved it.
Thanks!!!!
/Lisa -
2. Re: UndeclaredThrowableException when setting value on remot
glote Oct 29, 2001 4:32 AM (in response to banigreyling)This happens because the container tries to invoke the method, but get a checked exception that the that's not declared in the method you're calling. If you declare the method in the remote interface of the entitybean as throws SomeException the UndeclaredThrowableException should go away.
BTW you can get the exception that caused UndeclaredThrowableException to be thrown by calling the getUndeclaredThrowableException method on the UndeclaredThrowableException
See the javadoc for more info on UndeclaredThrowable:
http://java.sun.com/j2se/1.3/docs/api/index.html -
3. Re: UndeclaredThrowableException when setting value on remot
glote Oct 29, 2001 4:33 AM (in response to banigreyling)Sorry about including the wrong link, it should have been
http://java.sun.com/j2se/1.3/docs/api/java/lang/reflect/UndeclaredThrowableException.html -
4. Re: UndeclaredThrowableException when setting value on remot
lisa_r Oct 29, 2001 5:52 AM (in response to banigreyling)Hi glote,
Thanks for your reply!
EJB is very new to me so I am not sure that I understand what you mean. In which method sould I declare an extra Exception?
I call a set method in my entity bean which only do the following:
public void setSystemLanguage(String systemLang)
{
this.systemLang = systemLang;
}
In the remoteinterface the method is declared like this:
public void setSystemLanguage( String systemLang )
throws RemoteException;
When I for instance try to set a value that has to many characters to fit into the databasefield the ejbStore method throws an EJBexception that wraps a SQLException. The client only gets an UndeclaredThrowableException.
Thanks!
/Lisa -
5. Re: UndeclaredThrowableException when setting value on remot
banigreyling Oct 31, 2001 6:56 AM (in response to banigreyling)Hi,
Thanks for the reply. The UndeclaredThrowableException originates from the proxy instance on the client side, because the error thrown by the container is not a subclass of the RemoteException (which is the onlydeclared exception on the remote interface). According to section 12.3.1 of the EJB1.1 Spec, the container should throw RemoteException in the case when an Exception other than an AppException occured in the implementation.
To put it differently. If I do not declare any exceptions in my EntityBean subclass, I should not get an UndeclaredThrowableException on the client side, but rather a RemoteException. To put it frankly, I think it is a bug in JBoss. The container is not throwing a RemoteException as it is required to do. -
6. Re: UndeclaredThrowableException when setting value on remot
banigreyling Oct 31, 2001 9:35 AM (in response to banigreyling)To be more exact:
case1: Bean Participating in existing transaction
When an exception occurs in the container which is not thrown by the EnityBean subclass (i.e. your cmp bean) the container should throw javax.transaction.TransactionRolledBackException (which extends java.rmi.RemoteException), and not javax.transaction.RollbackException as it is currently doing. If javax.transaction.TransactionRolledBackException is thrown, you will 1) Not get UndeclaredThrowableException ,2) Be able to check the root exception (e.g. SQLException) on the client and try to recover from it.
case2: Bean Creating new transaction
When an exception occurs in the container which is not thrown by the EnityBean subclass (i.e. your cmp bean) the container should throw java.rmi.RemoteException.
With javax.transaction.TransactionRolledBackException you will alse be able to check the root exception, which was an issue on another forum thread.
But then again, maybe I am just a bad spec reader:) -
7. Re: UndeclaredThrowableException when setting value on remot
lisa_r Oct 31, 2001 11:37 AM (in response to banigreyling)Hi BANIGREYLING,
Thanks for your reply! :)
I use bmp and JBoss 2.2.2. What can I do so that I don´t get UndeclaredThrowableException? -
8. Re: UndeclaredThrowableException when setting value on remot
banigreyling Nov 1, 2001 2:07 AM (in response to banigreyling)I would think a feasable (and temporary!) workaround will be to add javax.transaction.RollbackException to the throws clause of all the set methods on your Remote Interfaces. This will allow the incorrect (IMHO) exception thrown by the container to be propagated to the client. Note however that this is not an elegant solution.
PS I would appreciate it if one of the lead developers can comment on my postings in this thread, as I think it may result in a bugfix. Or can someone tell me I am wrong and why!?