1 Reply Latest reply on Jul 4, 2009 10:44 AM by jaikiran

    Business Interface Pattern + Generics == EJB Spec Violation

      I'm working on an EJB 2.1 project where we are required to provide both local and remote interfaces to the EJBs. The team likes to use the Business Interface Pattern and we use generics to get around issue where remote interfaces are required to throw RemoteException while local interfaces are not. This technique worked fine under WebSphere 6.1 but we get an EJB spec violation error under JBoss AS 5.1.0.GA during deployment:

      "09:55:54,905 WARN [verifier] EJB spec violation:
      Bean : PersonEJB
      Method : public abstract void delete(Long) throws Exception, UnknownIdDeviation
      Section: 7.11.5
      Warning: The methods in the remote interface must include java.rmi.RemoteException in their throws clause."


      Our code looks similar to this:

      public interface AddressBeanBusinessInterface <E extends Exception>
      {
       public Long create( final Address address ) throws E;
       public Address read( final Long key ) throws E, UnknownIdDeviation;
       public void update( final Address address ) throws E, UnknownIdDeviation;
       public void delete( final Long key ) throws E, UnknownIdDeviation;
      }
      
      public interface AddressBeanLocal extends EJBLocalObject, AddressBeanBusinessInterface<RuntimeException>
      {
       // empty - see the business interface for the local EJB methods
      }
      
      public interface AddressBeanRemote extends EJBObject, AddressBeanBusinessInterface<RemoteException>
      {
       // empty - see the business interface for the remote EJB methods
      }


      I'm not an expert on generics but I thought that by the time everything got compiled all the typing modifications are done so I wouldn't expect JBoss' reflection code to get confused. Anybody have any ideas on what we might try to resolve this issue?

      Many Thanks,
      Ron



        • 1. Re: Business Interface Pattern + Generics == EJB Spec Violat
          jaikiran

          Consider this:

          public interface AddressBeanBusinessInterface <E extends Exception>
          {
          ...
           public void delete( final Long key ) throws E, UnknownIdDeviation;
          

          public interface AddressBeanRemote extends EJBObject, AddressBeanBusinessInterface<RemoteException>
          {
           // empty - see the business interface for the remote EJB methods
          ...


          and

          public interface AnotherInterface extends AddressBeanBusinessInterface<NullPointerException>
          {
           // empty - see the business interface for the remote EJB methods
          


          So there 2 interfaces which extend the AddressBeanBusinessInterface. One expects to throw a NullPointerException and the other a RemoteException. So what should the compiler "replace" the E in AddressBeanBusinessInterface? It doesn't. All it does is marks the method to throw an Exception (as marked by E extends Exception):

          public interface AddressBeanBusinessInterface <E extends Exception>
          {
          ...
           public void delete( final Long key ) throws Exception, UnknownIdDeviation;