1 Reply Latest reply on Jul 2, 2006 6:21 AM by Flush

    Local and Remote interfaces - Do I really have to create two

    Flush Newbie

      Hi, I'm new to EJB3, so I'm probably missing something but here it goes...

      I developed a very simple slsb to manage Employees. Following the book I'm reading I created the business interface and implemented it from within the sb. So far so good. I'm studying EE 5 because I want to introduce the passage to EJB3 in the company I work for. So it happens that our architecture has got Apache HTTP/Tomcat on a front-end box and Jboss running on another box shielded from the outside world, and the front-end talks to the backend through Business Delegates. This means that our applications can use two types of interfaces: local (B2B) and remote (User interfaces). I declared the interface with the @Remote annotation to make it available remotely, but I would have expected that I could use the same business interface both locally and remotely. Unfortunately, when I declared by slsb as follows:

      @Stateless
      @Local({HelloService.class})
      @LocalBinding(jndiBinding="uk_co_jemos_ejb3.sessions_EmployeeServiceLocal")
      @Remote({HelloService.class})
      @RemoteBinding(clientBindUrl="socket://192.168.2.3:4173/", jndiBinding="uk_co_jemos_ejb3.sessions_EmployeeService")
      public class EmployeeServiceImpl implements EmployeeService {
      
      ...etc
      


      and I performed a remote lookup with the PortableRemoteObject.narrow I got a ClassCastException. This in my opinion happened because the JNDI resolved the same name to two different types: one was the pure, local interface, the other a stub of the interface.

      When I removed the local declarations, everything worked fine.

      The conclusion I get from the above is that I have to declare two interfaces (which do exactly the same thing) for local and remote access.

      Please tell me that's not true.