3 Replies Latest reply on Jun 27, 2013 11:59 AM by wdfink

    Hi, all, i meet a strange problem.

    terry261

      when i run the following test, it does not work and throw an exception "No EJB receiver available for handling". the service is a remote interface running in jboss 7.1.1Final

       

      private  class MyTimerTask extends TimerTask {

              DataPersistenceService ds;

       

       

              public MyTimerTask(DataPersistenceService ds) {

                  this.ds = ds;

              }

       

       

              /*

               * (non-Javadoc)

               * @see org.jboss.netty.util.TimerTask#run(org.jboss.netty.util.Timeout)

               */

              @Override

              public void run() {

                  while (true) {

                      try {

                          List<JobPackPropertyInfo> a = ds.getAllJPProperty();

                          for (JobPackPropertyInfo jobPackPropertyInfo : a) {

                              System.out.println(a);

                          }

                      } catch (SFServiceException e) {

                          // TODO Auto-generated catch block

                          e.printStackTrace();

                      }

                  }

              }

       

       

          }

       

       

          @Test

          public void timer() {

              Thread t = new Thread(new MyTimerTask(service));

              t.start();

          }

       

       

       

      but, when i run the other test method, it works, please see the following codes. what is difference between the two test method?

      @Test

          public void test() throws SFServiceException {

              List<JobPackPropertyInfo> a = service.getAllJPProperty();

              for (JobPackPropertyInfo jobPackPropertyInfo : a) {

                  System.out.println(jobPackPropertyInfo);

              }

          }

        • 1. Re: Hi, all, i meet a strange problem.
          wdfink

          I suppose 'DataPersistenceService' is a reference/proxy for a SLSB inside the server.

           

          But you have to provide more details that we are able to understand what you want to achieve and what is wrong.

          • 2. Re: Hi, all, i meet a strange problem.
            terry261

            yes, what you guess is right. the service is a slsb in jboss server. by the way, i found a workaround, inside the run method, i create a new context and lookup the remote service, it works. why?

            • 3. Re: Hi, all, i meet a strange problem.
              wdfink

              i create a new context and lookup the remote service, it works. why?

              That depends on the aproach you are using for lookup, it might be that, if you close teh context or it is desroyed by GC, the connetion to the server is closed.

              To get the exact answer you need to share more code.