1 Reply Latest reply on Feb 11, 2009 2:13 AM by jaikiran pai

    Is it possible to inject a Remote bean in a client servlet?

    Ross Nicholson Apprentice

      I'm using a remote bean from a servlet to make a remote call. The code snippet below works. But I'm wondering is it possible to inject this bean without needing to do the remote JNDI lookup.

      When using JMS I setup a RemoteJMSProvider and can inject both the connection factory and destination queue from a servlet (I'm using the web 2.5 spec).

      Is something similar possible with EJB's? Or am I stuck with the JNDI lookup code. Maybe some kind of mbean provider where I can specify the remote machine IP?



      P.S. I've commented out the @EJB annotation as it does nothing.

      private MyTestBeanRemote remoteBean;
      protected void doGet(HttpServletRequest request,
       HttpServletResponse response) throws ServletException, IOException {
       try {
       Properties properties = new Properties();
       properties.put(Context.PROVIDER_URL, "jnp://");
       Context ctx = new InitialContext(props);
       remoteBean = (MyTestBeanRemote) ctx.lookup("TestEAR/MyTestBeanRemote/remote");
       } catch (Exception ex) {
       System.out.println("Could not create bean. "+
       if (remoteBean != null) remoteBean.doSomething();