2 Replies Latest reply on Apr 7, 2017 8:53 AM by David Lloyd

    Remote EJB lookup and Invocation and Thread.interrupt() issues

    Sébastien Andre Newbie

      Hello,

       

      I have by example a daemon thread that works as follow

       

         while( running ) {

                doJob();

                try {

                     Thread.sleep( fewTimes );

                }

                catch(InterruptedException e) {}

         }

       

      This daemon thread do a specific task at interval delay.

      But when the users do some actions, i can wish to force the daemon thread to execute it's task, i call on the daemon thread a Thread.interrupt();

      If the daemon thread is on the sleep, it will be interrupted and will execute doJob()

       

      Issues comes from the doJob() method that can do some things like:

      - EJB lookup through the JNDI

      - EJB invocation on EJB remote stubs

       

      But it seems that theses operations take care in some way of the interrupted (that means they are interruptible methods ?)

      And i have spurious errors like

        - NameNotFoundException : can't invoke lookup , status=WAITING (on a lookup invocation)

        - EJBCLIENT000051: Cannot proceed with invocation since the locator StatefulEJBLocator  (on a stateful remote invocation)

       

       

      I called a Thread.interrupted() before lookups and invocations for testing purpose but it can't be a usable workaround since it's not thread safe

      I can't prevent the Thread.interrupt() after the flag was cleared and the lookup or invocation is executing.

       

      So, did you know a way to do lookups and method invocation without take cares about the Thread.interrupt ?

      If not, did you know a usable workaround ?

       

      i have theses issues on existing applications for which i migrate for using a WildFly server.

       

      Best regards,

      Sébastien.