1 Reply Latest reply on Jan 4, 2007 2:42 PM by starksm64

    Interface exception checking seems broken

    starksm64

       

      "henke.eriksson" wrote:

      We ran into some trouble today when we tried to deploy an EJB with a
      Local interface on JBoss 4.0.4. The business interface had one method,
      which looked something like this:

      Object doStuff(Command c) throws Throwable;

      At deploy-time the verifier complained that we had a method in a local
      interface that threw a RemoteException violating section 7.11.7 of the
      EJB spec.

      We did some digging and stumbled across the bug report JBAS-1463. The
      fix for this "bug" basically disallows a method in a local interface
      to declare that it throws a RemoteException or any of its
      SUPERclasses. As the report mentions, the RMI spec says that a Remote
      method must declare that it throws a RemoteException or one of it
      superclasses. But as far as I know a remote method can still declare
      that it throws a subclass of RemoteException, right?

      Right now the verifier assumes that a method that declares that it
      throws Throwable is a remote method. And I can see in the code that
      fixes to allow Exception and IOException has been applied. But I still
      feel that this logic is a bit weird, or am I missing something?



        • 1. Re: Interface exception checking seems broken
          starksm64

          The rmi spec(which is hardly a spec) should not be dictating the exception checking, as its the ejb specs which define what is needed. Allowing superclasses of RemoteException is obvisously going to collide with generic application exceptions. The ejb spec is pretty clear about remote methods must be identified by a RemoteException, with any number of application exceptions.

          The current throwsRemoteException(Method) method is a confusion of checks that are mixing local and remote interface semantics:

           /**
           * Checks if the method includes java.rmi.RemoteException or its
           * subclass in its throws clause.
           *
           * See bug report #434739 and #607805
           */
           public boolean throwsRemoteException(Method method)
           {
           Class[] exception = method.getExceptionTypes();
          
           for (int i = 0; i < exception.length; ++i)
           {
           // Fix for bug #607805: an IOException is OK for local interfaces
           // Fix for bug #626430: java.lang.Exception is also OK
           if (exception.equals(java.io.IOException.class)
           || exception.equals(java.lang.Exception.class))
           {
           continue;
           }
          // Not true see bug report #434739
          // if (java.rmi.RemoteException.class.isAssignableFrom(exception))
           // According to the RMI spec. a remote interface must throw an RemoteException
           // or any of its super classes therefore the check must be done vice versa
          
           if (isAssignableFrom(exception, "java.rmi.RemoteException"))
           {
           return true;
           }
           }
          
           return false;
           }
          


          None of the methods in this interface should be valid:
          public interface X extends EJBObject
          {
           void m0() throws IOException;
           void m1() throws Exception;
           void m2() throws Throwable;
          }
          


          They are all valid for a local interface.