Hi!
Do not use RemoteException but your a new one you create.
        throw MyException("blablabla");
RemoteException is considered System is catch by the server and rethrown.
A custom Exception is also catched but rethrown the same.
Vincent.

-----Message d'origine-----
De : [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]De la part de fractals
Envoyé : mardi 6 mars 2001 16:11
À : [EMAIL PROTECTED]
Objet : [JBoss-user] exception handling


Let's consider the following remote method implementation (this is the
implementation of a method defined in a remote interface of an EJB):

    public UserSession getSession ( String sessionId, String requestId,
String requestIdentifier )
        throws RemoteException, CreateException, FinderException
    {
        UserSessionHome home = ( UserSessionHome ) getHome
("gatekeeper/UserSession",     UserSessionHome.class);
        UserSession session = home.findByLastRequest ( sessionId, requestId,
requestIdentifier );
        if ( session.timedOut () )
        {

            System.out.println ( "session timed out" );
            throw new RemoteException ( "Session Timed Out" );
        }
        session.setNew ( false );
        session.setRequestId ( forgeId ( 30 ) );
        session.setLastAccessedDate ( new java.sql.Timestamp
 System.currentTimeMillis () ) );
        return session;
    }


Now, this is a code that's executed by a client

        try {
            session = gatekeeper.getSession ( session.getSessionId (),
                                              session.getRequestId (),
                                              "get session again test" );
            textarea.append ( "sessionId: " + session.getSessionId () +
"\n" );
            textarea.append ( "requestId: " + session.getRequestId () +
"\n" );
            textarea.append ( "isNew: " + session.getNew () + "\n" );
        } catch ( java.rmi.RemoteException e ) {
            textarea.append ( "Remote Exception: " + e.getMessage () );
        } catch ( Exception e ) {
            textarea.append ( "couldn't get the same session\n" );
            stackTrace ( e );
        }

I *would* like to catch a RemoteException with my message (ie "Session Timed
Out" ) but instead I get my exception nested in another RemoteException:

Remote Exception: RemoteException occurred in server thread; nested
exception is:
 java.rmi.RemoteException: Session Timed Out

That is, Ideally, I would create a custom exception, TimedOutException,
which I'd like to catch appropriately, but that's apparently impossible, and
for the very moment, it is quite annoying for me.

Does someone know how to solve this problem ?

Thanks in advance,

candide kemmler


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to