2 Replies Latest reply on Jan 10, 2008 2:51 AM by francis1970

    [Beginner] Remote Client Dependency Injection doesn't work..

    francis1970

      Hi all !
      I have found an EJB 3 example from Oracle site, it uses dependency injection to invoke the EJB. Unfortunately it doesn't work on JBoss....I get a "NullPointerException" when I invoke the sayHello method.

      Added also Context information but still doesn't work.

      Do I need to add some configuration file to the EJB's jar file so that dependency injection works ???

      This is the EJB

      package oracle.ejb30;
      
      import javax.ejb.Remote;
      @Remote
      public interface HelloWorld {
       public void sayHello(String name);
      }
      
      -----------------------------------------------------
      package oracle.ejb30;
      
      import javax.ejb.Stateless;
      
      @Stateless
      public class HelloWorldBean implements HelloWorld {
       public void sayHello(String name) {
       System.out.println("Hello " + name
       + " from your first EJB 3.0 component ...");
       }
      }
      -------------------------------------------------------
      package oracle.ejb30;
      
      import javax.ejb.EJB;
      import java.util.*;
      import javax.naming.*;
      
      public class HelloWorldClient {
       @EJB
       private static HelloWorld helloWorld;
      
       public static void main(String[] args) throws NamingException {
       Properties env = new Properties();
       env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
       env.setProperty("java.naming.provider.url", "localhost:1099");
       env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
       Context ctx = new InitialContext(env);
      
       System.out.println("Using Dependency Injection .. invoking sayHello ");
       helloWorld.sayHello("Debu Panda!");
       }
      }