2 Replies Latest reply on Jan 2, 2007 1:22 PM by Eric Ray

    @Depends annotation doesn't work with Jboss 4.0.3SP1 Ejb3.0

    Mark Nebrat Newbie

      Hello all
      @Depends annotation doesn't work with Jboss 4.0.3SP1 Ejb3.0 RC6-PFD release
      We use it to inject service into another service
      (it works in Ejb3.0 RC5-PFD release)
      Following is my code:

      TestServiceMbean.java:

      import java.util.Date;
      import org.jboss.annotation.ejb.Service;
      
      @Service(objectName = "com.telrad.oss.gaia.ejb.srv:service=TestService")
      public class TestServiceMBean implements TestService{
      
      
       private String msg = "No msg";
       private int counter = 0;
       public void start() throws Exception
       {
       System.out.println("Service 1 Started" + getMsg());
       }
      
       public void connectToServer(int seconds, String serviceName)
       {
      
       System.out.println("-------- Test Call");
      
       }
       public String getMsg() {
       return msg;
       }
       public void setMsg(String msg) {
       this.msg = msg;
       }
       public void create() throws Exception
       {
       System.out.println("TestServiceMBean created");
       //msg="Test Service";
       }
      
      }
      

      TestServiceMBean2.java:
      import org.jboss.annotation.ejb.Depends;
      import org.jboss.annotation.ejb.Service;
      
      @Service
      public class TestServiceMBean2 implements TestService2 {
      
       private TestService service1;
      
       @Depends ("com.telrad.oss.gaia.ejb.srv:service=TestService")
       public void setTestService(TestService service1)
       {
       this.service1=service1;
       }
      
      
      
       public void start() throws Exception {
       // TODO Auto-generated method stub
       service1.connectToServer(7,"Service2");
      
       }
      
       public void create() throws Exception {
       // TODO Auto-generated method stub
       System.out.println("Service 2 created");
       }
      
       public TestService getService1() {
       return service1;
       }
      
       public void setService1(TestService service1) {
       this.service1 = service1;
       }
      
      }
      
      


      Deployment failed with following exception:
      Caused by: java.lang.NullPointerException
      at com.telrad.oss.gaia.ejb.srv.TestServiceMBean2.start(TestServiceMBean2
      .java:32)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
      java:109)
      at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invok
      e(TransactionScopedEntityManagerInterceptor.java:54)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
      java:98)
      at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsI
      nterceptor.java:47)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
      java:98)
      at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)