3 Replies Latest reply on Oct 19, 2005 1:10 PM by Bill Burke

    Embedded EJB3 Services

    Matt Johnston Newbie

      I am trying to learn EJB3, so I downloaded the Embedded version and I am running the samples through JUnit in Eclipse. I have the tutorial examples of entity beans working fine. But I can't get a @Service bean to load.

      Here is my service

      public interface IndexerMBean {
       public String getResults();
       void create() throws Exception;
       void start() throws Exception;
       void stop();
       void destroy();
      public class IndexerService implements IndexerMBean {
       protected static final Log log = LogFactory.getLog(IndexerService.class);
       private String indexDir;
       private String results = "my results";
       public String getResults() {
       return results;
       public void create() throws Exception
       System.out.println("ServiceOne - Creating");
       public void start() throws Exception
       System.out.println("ServiceOne - Starting");
       public void stop()
       System.out.println("ServiceOne - Stopping");
       public void destroy()
       System.out.println("ServiceOne - Destroying");

      When I run my junit test based on the tutorial examples, I get the error message

      java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.RangeCheck(ArrayList.java:547)
      at java.util.ArrayList.get(ArrayList.java:322)
      at org.jboss.ejb3.service.ServiceMBeanDelegate.register(ServiceMBeanDelegate.java:67)
      at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:303)
      at org.jboss.ejb3.service.ServiceContainer.start(ServiceContainer.java:70)
      at org.jboss.ejb3.service.ServiceManager.startService(ServiceManager.java:97)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:274)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:181)
      at org.jboss.ejb3.embedded.EJB3StandaloneDeployment.start(EJB3StandaloneDeployment.java:101)
      at org.jboss.ejb3.embedded.EJB3StandaloneDeployer.start(EJB3StandaloneDeployer.java:389)

      Does anyone know what causes this error?

        • 1. Re: Embedded EJB3 Services
          Bill Burke Master

          Haven't really tested @Service, @Consumer within embedded environment. @Management won't work because it is looking for a JBoss MBeanServer, but I think @Service without a @Management interface will work. I'll put this on the todo list.

          I do think the docs that come with the dist say that only SFSB, SLSB, and MDB have been testesd with embeddable stuff.

          Apologies. But it is an alpha release...

          • 2. Re: Embedded EJB3 Services
            Matt Johnston Newbie

            Thanks for the response. Since I am trying to learn EJB3, I thought the embedded version would make it quicker since I don't have to package, deploy, test everytime I make a change.

            Is there any other way to test EJBs outside of JBoss? Somehow through JUnit?

            • 3. Re: Embedded EJB3 Services
              Bill Burke Master

              @Service is a JBoss specific extension to EJB3. SFSB, SLSB, EM, MDBs still work in embedded EJB3. I will get it to work in the next release.

              If you don't use embeddable EJB3, you're gonna have to write a lot of mock objects.