Application level exception and Serializable interface

Discussions

EJB programming & troubleshooting: Application level exception and Serializable interface

  1. Hi

    I am newbie to EJB. I was reading doc of EJB and in FinderException it says that it is an Application level Exception.

    I know the meaning of application level exception.

    My question is this, is it necessary to implement Serializable interface for app level exception?
    If yes then WHY?
    If no then why FinderException is implementing it?

    Thanks in advance.
  2. All Throwables, including all types of exceptions, are Serializable. Your application exceptions should be runtime-serializable, meaning they should either reference only other runtime-serializable objects or define their own serialization mechanism. In my expirience this is hardly ever an issue. I don't recall ever having to deal with serialization of exceptions myself.

    The reason exceptions (application and system) should be serializable is that when they are thrown from a method, they are passed back to the client. The way to pass them, like method parameters and return values, is serialization. This is a general RMI (and RMI-IIOP) rule, not an EJB-specific rule.

    Gal
  3. thanks !

    I never noticed that Throwable implements Serializable.