4 Replies Latest reply on Aug 28, 2002 11:25 AM by Chandra Gottipati

    UndeclaredThrowableException

    Jason Robertson Newbie

      When I throw an EJBException in one of my business methods (from a SFSB, if it matters), I get an UndeclaredThrowableException back at the client. The exception it's wrapping is a java.rmi.ServerException, which in my one case seems to be wrappinga TransactionRolledbackException which is wrapping my EJBException.

      Shouldn't I be getting the EJBException in my client?

      I'm using a recent JBoss 3.0.x build.

        • 1. Re: UndeclaredThrowableException
          C. Daniel Mojoli-Boggino Newbie

          AFAIK the EJB2.0 spec classifies subclasses of RuntimeException as "System Exceptions". EJBException is a subclass of RuntimeException (unlike CreateException, FinderException et al, which are "Application Exceptions".)

          You shouldn't be throwing EJBException from your beans since "system exceptions" are reserved for problems in the underlying system. For example: I get an EJBException when using commit option A a create fails because of a duplicate key detected by the database (but unknown to the container because it was created by a commandline INSERT).

          • 2. Re: UndeclaredThrowableException
            cuenot Newbie

            Hello,

            I have the same problem, i throw an owner exception which extends java.rmi.RemoteException into a BMP bean.

            in the client, i can't catch my exception, i catch an UndeclaredThrowableException.

            Thanks for your Helps!

            This is my Server exception stack trace:

            [EjbC] create(1)
            [EjbC] [EjbAPK : [ id = 1 ]] setName(toto)
            [EjbC] TRANSACTION ROLLBACK EXCEPTION:null; nested exception is:
            com.prodaxis.sbcf.api.ejb.exception.ComponentException
            [EjbC] com.prodaxis.sbcf.api.ejb.exception.ComponentException
            [EjbC] at test.copy.EjbCBMP.setName(EjbCBMP.java:50)
            [EjbC] at java.lang.reflect.Method.invoke(Native Method)

            This is my Client exception stack trace:

            java.lang.reflect.UndeclaredThrowableException: java.rmi.ServerException: Remote
            Exception occurred in server thread; nested exception is:
            javax.transaction.TransactionRolledbackException: null; nested exception
            is:
            com.prodaxis.sbcf.api.ejb.exception.ComponentException
            javax.transaction.TransactionRolledbackException: null; nested exception is:

            • 3. Re: UndeclaredThrowableException
              Greg Greaves Newbie

              Much of the example code I've seen (specifically BMP), throws EJBException when something goes wrong. You can wrap up the original exception causing the problem or just construct it with a string. The container catches it and wraps it in a RemoteException that gets passed back to the client. You can unwrap the whole mess from there. Is your assertion about not throwing EJBException specific to EJB2.0?

              I'm having the same problem (UndeclaredThrowableException) when the EJBException is thrown from the ejbStore (on BMP). On finders and creates it works fine. Any insight into this would be greatly appreciated.

              -Greg

              • 4. Re: UndeclaredThrowableException
                Chandra Gottipati Newbie

                I am working with an EJB session bean and call a method on a java class to authenticate a user in LDAP. If there is an error I thorw a new RemoteExcpetion("Error Authenticating.")

                For the fron-end I am using Struts and catch the RemoteException. When I try to print the error message with
                System.out.println("Error Msg is : "+re.getMessage());
                I see this:
                Error Authenticating; nested exception is: java.rmi.RemoteException: Error Authenticating

                why is it nesting the exception??

                If I don't catch RemoteException and just catch Exception, and print the exception it says the exception type is java.rmi.ServerException!!!

                I am running JBoss 3.0.1 version.

                How do I un-wrap this on the client side. I don't want to do string parsing etc...