1 Reply Latest reply on Jan 8, 2008 4:42 AM by stfkbf

    EJB 2.1 client adapters not working

    stfkbf

      Hi

      I have attempted to create an EJB with a remote home interface as follows:

      public interface TestBeanRemote extends EJBObject {
       public int getId();
      }
      
      public interface TestBeanRemoteHome extends EJBHome {
       public TestBeanRemote create() throws CreateException, RemoteException;
      }
      
      public interface TestBeanEJB3 {
       public int getId();
      }
      
      @Stateful(name="TestBean")
      @Remote(TestBeanEJB3.class)
      @RemoteHome(TestBeanRemoteHome.class)
      public class TestBean implements TestBeanEJB3{
      
       private int id = 5;
      
       @Init
       public void create() throws CreateException, RemoteException{}
      
       public int getId() {
       return id;
       }
      
      
      }


      Basically following the tutorials here:

      https://glassfish.dev.java.net/javaee5/ejb/examples/Adapted.html

      and here:

      http://docs.jboss.org/ejb3/app-server/tutorial/ejb21_client_adaptors/ejb21_client_adaptors.html

      This however results in the following exception (using JBoss 4.2.0.GA_CP01):

      09:15:56,642 ERROR [STDERR] java.lang.IllegalStateException: Container null is not registered
      09:15:56,642 ERROR [STDERR] at org.jboss.ejb3.Ejb3Registry.getContainer(Ejb3Registry.java:149)
      09:15:56,642 ERROR [STDERR] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:70)
      09:15:56,642 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      09:15:56,642 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulHomeRemoteProxy.invoke(StatefulHomeRemoteProxy.java:110)
      09:15:56,642 ERROR [STDERR] at $Proxy105.create(Unknown Source)
      09:15:56,642 ERROR [STDERR] at dk.services.TestService.test(TestService.java:36)


      The code used to invoke the bean looks as follows:

      TestBeanRemoteHome t;
      Context context = new InitialContext();
      t = (TestBeanRemoteHome) context.lookup("TestBean/home");
      tr = t.create();


      The line that fails is the create call.

      Am i doing something obvious wrong?

      The reason for using EJB2.1 instead of EJB3 is that i need to obtain a EJB handle that can be returned by a web service. Serializing the EJB3 remote interface does not seem to work (see http://www.jboss.org/index.html?module=bb&op=viewtopic&t=73311).

      Hope someone can help :)

        • 1. Re: EJB 2.1 client adapters not working
          stfkbf

          I have now corrected the code to follow the samples that come with the JBoss source code:

          public interface TestBeanRemote {
           public int getId();
          }
          
          public interface TestBeanRemoteHome extends EJBHome {
           public TestBeanRemote create() throws CreateException, RemoteException;
          }
          
          @Stateful(name="TestBean")
          @Remote(TestBeanRemote.class)
          @RemoteHome(TestBeanRemoteHome.class)
          public class TestBean implements TestBeanRemote{
          ...
          }


          Using the above code (and switching to 4.2.2.GA) the bean can now be created and business methods be called. However the remote interface does not extend EJBObject and hence the getHandle method is not available.

          None of the samples that come with the JBoss source code illustrate how to get the serializable handle returned by getHandle. Is this a bug in the implementation? (as it seems the JBoss implementation differs from for instance the glassfish implementation)