0 Replies Latest reply on Oct 9, 2007 11:37 AM by trippstowe

    @EJB in a web service

    trippstowe

      I am having some problems with dependency injection of an ejb in a webservice on jboss 4.0.5. What am i doing wrong?

      The below code i have also tried @EJB without any parameters:
      Also i could not get the setter to work either. it never entered the setter and displayed the logs.

       @EJB(name="LookupTest/remote",
       beanInterface=RemoteLookupTest.class)
       RemoteLookupTest ps;
      
      /* public void setPersonService(RemoteLookupTest newPs){
       log.info("injecting new personService: "+newPs);
       this.ps = newPs;
       log.info("injected personService: ps="+ps);
       }
      */
       @WebMethod
       public Person queryPerson(long personId) throws RemoteException{
       System.out.println(ps.getName());
       }
      

      this code gives me a null pointer exception at the ps.getName();


      this next code snippet is the next function in the web service and it works fine. this makes me think that the bean is deployed correctly.

       @WebMethod
       public void testLookupBean() throws RemoteException{
       try{
       Context ctx = new InitialContext();
       String jndiName = "LookupTest/remote";
       RemoteLookupTest obj = (RemoteLookupTest)ctx.lookup(jndiName);
       System.out.println(obj.getName());
      


      thanks in advance

      -==-