1 Reply Latest reply on Jul 3, 2006 8:42 AM by Carlo de Wolf

    Can Jboss auto-generate remote interfaces?

    Flush Newbie

      Hi, I'm reading the article at the following path:


      http://www.javaworld.com/javaworld/jw-08-2004/jw-0809-ejb-p2.html

      which says that the following signature for a slsb:

      @Stateless
      @Remote
      public class HelloWorldBean {
      public String sayHello() {
      return "Hello World!!!";
      }
      }

      should be enough to have the EJB container to auto-generate a remote interface for us.

      I tried and got the following problems at deployment time:


      java.lang.RuntimeException: Use of empty @Remote on bean class and there are no valid business interfaces
      at org.jboss.ejb3.ProxyFactoryHelper.getRemoteInterfaces(ProxyFactoryHelper.java:354)
      at org.jboss.ejb3.ProxyDeployer.initializeRemoteBindingMetadata(ProxyDeployer.java:134)
      at org.jboss.ejb3.SessionContainer.instantiated(SessionContainer.java:70)
      at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:573)
      at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:555)
      at org.jboss.ejb3.Ejb3Deployment.deployUrl(Ejb3Deployment.java:536)
      at org.jboss.ejb3.Ejb3Deployment.deploy(Ejb3Deployment.java:508)
      at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:463)
      at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:125)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
      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:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
      at $Proxy0.create(Unknown Source)
      at org.jboss.system.ServiceController.create(ServiceController.java:330)
      at org.jboss.system.ServiceController.create(ServiceController.java:273)
      ...etc


      The question is: is it possible to have remote interface auto-generated for us? If so, which object could be access from outside the container in order to interact with our session bean? I know it sounds a bit out of the spec, since no client should interact directly with an EJB, but if somehow we could get back a remote object which could be cast to our session bean type, exposing only public methods...then life would be much easier, since I wouldn't have to write an interface for each sb I create.

        • 1. Re: Can Jboss auto-generate remote interfaces?
          Carlo de Wolf Master

          Yes, it is possible to generate an interface ( / remote proxy) with only the public methods expesed. But it would be nameless and leave the client clueless. You could get to the methods via introspection, but then you're shifting the complexity to the client side.

          It would be easy to create a tool to generate an interface before compilation. Look at Eclipse (select a class, Refactor -> Extract Interface...)