6 Replies Latest reply on Aug 22, 2003 10:15 AM by Raja

    EJB spec violation

    petbos Newbie

      I get always an EJB spec violation in the jboss log :
      14:35:56,907 WARN [verifier] EJB spec violation:
      Bean : Phone
      Method : public abstract void remove() throws RemoveException, RemoteException
      Section: 12.2.9
      Warning: Each home method must match a method defined in the entity bean class.

      My home interface looks likes this :

      public interface PhoneNumberHome extends EJBHome {

      public PhoneNumber create(Integer phoneId,
      String firstName,
      String lastName,
      String phoneNumber)
      throws RemoteException, CreateException;

      public PhoneNumber findByPrimaryKey(Integer phoneId)
      throws FinderException, RemoteException;

      public void remove()
      throws RemoveException, RemoteException;

      }

      The remove method in my entity bean look like this :

      public void ejbRemove() throws RemoveException {

      System.out.println("in ejbRemove");

      try {
      deleteRow(this.phoneId);
      } catch (Exception ex) {
      throw new EJBException("ejbRemove: " + ex.getMessage());
      }
      System.out.println("leaving ejbRemove");
      }

      What is wrong. Can anybody help or give me a hint.

      Many thanks,

      Peter

        • 1. Re: EJB spec violation
          Adrian Brock Master

          remove(Object primaryKey)

          Regards,
          Adrian

          • 2. Re: EJB spec violation
            bbbear Newbie

            Hi I get this too, but I couldn't tell what is wrong with it, please shed some light? Thanks!

            11:51:01,511 WARN [verifier] EJB spec violation:
            Bean : LogMsg
            Method : public void ejbCreate() throws Exception
            Section: 15.7.3
            Warning: The ejbCreate() method must define no application exceptions.

            My LogMsgBean is like below:

            public class LogMsgBean
            implements MessageDrivenBean, MessageListener {

            ...
            ...
            ...

            public void ejbCreate () throws Exception
            {
            try {
            Context ctx = new InitialContext ();
            ds = (DataSource) ctx.lookup ("java:comp/env/jdbc/DSDefault");
            }
            catch (NamingException ne) {
            ne.printStackTrace ();
            }

            CommFactoryParm cfp = CommFactoryParm.getInstance ();
            cfp.addParm (CommFactoryParm.JMS_FACTORY, "SGConFactory");
            cfp.addParm (CommFactoryParm.JMSMSGTYPE,
            CommFactoryParm.JMSMSGTYPEOBJECT);

            try {
            comm = CommFactory.getInstance (CommFactory.DYNAMICJMSQUEUE, cfp);
            comm.connect ();
            cHdr = new CommDataHdr ();
            }
            catch (Exception e) {
            throw new Exception (e);
            }

            }

            ...
            ...
            ...

            }

            Regards,
            Karen

            • 3. Re: EJB spec violation
              Jon Barnett Master

              You probably need to throw a specific Exception implementation. The necessary declaration for ejbCreate is:
              public void ejbCreate() throws javax.ejb.CreateException

              • 4. Re: EJB spec violation
                bbbear Newbie

                Hi,

                I've changed ejbCreate() to throw javax.ejb.CreateException it still gives this error

                17:12:11,520 INFO [EjbModule] Created
                17:12:11,911 WARN [verifier] EJB spec violation:
                Bean : LogMsg
                Method : public void ejbCreate() throws CreateException
                Section: 15.7.3
                Warning: The ejbCreate() method must define no application exceptions.

                17:12:11,941 ERROR [MainDeployer] could not create deployment: file:/C:/JBOSS3/server/test/tmp/deploy/tmp38532test.ear-contents/Testing.jar
                org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
                at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:490)
                at org.jboss.deployment.MainDeployer.create(MainDeployer.java:776)
                at org.jboss.deployment.MainDeployer.create(MainDeployer.java:768)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:631)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:550)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy7.deploy(Unknown Source)
                at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
                at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:200)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:273)
                at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
                at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:550)
                at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
                at $Proxy0.start(Unknown Source)
                at org.jboss.system.ServiceController.start(ServiceController.java:394)
                at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:550)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy5.start(Unknown Source)
                at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
                at org.jboss.deployment.MainDeployer.start(MainDeployer.java:824)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:632)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:550)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy6.deploy(Unknown Source)
                at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:383)
                at org.jboss.system.server.ServerImpl.start(ServerImpl.java:290)
                at org.jboss.Main.boot(Main.java:150)
                at org.jboss.Main$1.run(Main.java:388)
                at java.lang.Thread.run(Thread.java:534)

                Here's my code, any clue??

                public void ejbCreate () throws javax.ejb.CreateException
                {
                try {
                Context ctx = new InitialContext ();
                ds = (DataSource) ctx.lookup ("java:comp/env/jdbc/DSDefault");
                }
                catch (NamingException ne) {
                ne.printStackTrace ();
                }

                CommFactoryParm cfp = CommFactoryParm.getInstance ();
                cfp.addParm (CommFactoryParm.JMSFACTORY, "SGConactory");
                cfp.addParm (CommFactoryParm.JMSMSGTYPE,
                CommFactoryParm.JMSMSGTYPEOBJECT);

                try
                {
                comm = CommFactory.getInstance (CommFactory.DYNAMICJMSQUEUE, cfp);
                comm.connect ();
                cHdr = new CommDataHdr ();
                }
                catch (CommFactoryException e)
                {
                throw new CreateException(e.getMessage());
                }
                catch (CommException ce)
                {
                throw new CreateException(ce.getMessage());
                }

                }


                Regards,
                K.

                • 5. Re: EJB spec violation
                  Jon Barnett Master

                  I see.

                  You are not to throw any exceptions in the method. Since this method contract is between the container and the EJB during the creation phase of the EJB lifecycle it should not be interfered with by explicitly generating/throwing any exceptions.

                  • 6. Re: EJB spec violation
                    Raja Master

                    why do u need a remove() on the ejbhome? There is a
                    remove(Object primarykey) defined in ejbhome interface.