1 Reply Latest reply on Mar 15, 2006 12:40 PM by raist_majere

    Strange: the exceptions in the Bean class isn`t the same as

    rafoul

      Hello! everyone !
      I`m new to EJB and encountered the problem when i was deploying my first BMP.
      I`m using JBoss 4.0.3 and JBoss IDE 1.5 with eclispe 3.1. When I try to deploy my ear file, JBoss kept saying the following:
      12:18:21,343 WARN [verifier] EJB spec violation:
      Bean : Account
      Method : public abstract void deposit(double) throws AccountException, RemoteException
      Section: 9.2.7
      Warning: All the exceptions defined in the throws clause of a matching method in the entity bean's class must be defined in the throws clause of the method of the remote interface.

      12:18:21,343 WARN [verifier] EJB spec violation:
      Bean : Account
      Method : public abstract void withdraw(double) throws AccountException, RemoteException
      Section: 9.2.7
      Warning: All the exceptions defined in the throws clause of a matching method in the entity bean's class must be defined in the throws clause of the method of the remote interface.

      12:18:21,343 ERROR [MainDeployer] Could not create deployment: file:/E:/jboss-4.0.3/server/all/tmp/deploy/tmp55218AccountApp.ear-contents/AccountEJB.jar


      But the exceptions threw by the corresponding methods are just the same, see in AccountBean.java:

      /**
      * Business method
      * @ejb.interface-method view-type = "both"
      */
      public void deposit(double amt) throws AccountException {
      // TODO Auto-generated method stub
      System.out.println("deposite (" + amt + ") called.");
      balance += amt;
      }
      /**
      * Business method
      * @ejb.interface-method view-type = "both"
      */
      public void withdraw(double amt) throws AccountException {
      // TODO Auto-generated method stub
      System.out.println("withdraw (" + amt + ") called.");
      if (amt > balance) {
      throw new AccountException("Your balance is ("
      + balance
      + "). You can`t with draw ("
      + amt
      + ").");
      }
      balance -= amt;
      }


      and in Account.java:
      public void deposit( double amt )
      throws account.ejb.AccountException, java.rmi.RemoteException;

      /**
      * Business method
      */
      public void withdraw( double amt )
      throws account.ejb.AccountException, java.rmi.RemoteException;


      Anyone can tell me why JBoss kept saying that ? I`m going crazy about this problem!


        • 1. Re: Strange: the exceptions in the Bean class isn`t the same
          raist_majere

          You have to declare the RemoteException in your bean:

          public void deposit(double) throws AccountException, RemoteException

          That's because the bean implements the Remote Interface and in that interface you declared that the method deposit (and others) throw this exception (well, is XDoclet who puts this for you, but in any case, you have to declare it on your bean).