8 Replies Latest reply on Aug 10, 2016 2:19 PM by Max Ozkin

    Referencing JNDI resource at quick SwitchYard app initialization causes deployment failure

    Max Ozkin Apprentice

      I observe really weird behaviour at SwitchYard application deployment and need your help. I was able to reproduce it in the simplest possible SwitchYard application which I attached here.

      In my SwitchYard application I implemented a distributed lock service using jgroups as suggested here Using jgroups CounterService with jboss's cluster channel. The service itself works fine.

      This service is referenced in my Bean class using Resource annotation like this:


      @Resource(lookup = "java:jboss/myapp/lock-service")

      private LockService lockService;


      Deployment of such lightweight application always fails with the exception:


      Caused by: javax.naming.NameNotFoundException: Error looking up myapp/lock-service, service service jboss.naming.context.java.jboss.myapp.lock-service is not started


      But if I put an artificial delay, say 3 seconds into a static initialization block of my Bean then the deployment goes fine as one would expect.

      I have no explanation why such delay is needed. In a complex application (my real application) where you have tens of Beans and other SwitchYard components, such delay is not needed at all, and deployment succeeds, and I think it is because the initialization of all SwitchYard application components takes some time and that time seems to be needed to make JNDI resource available. But in this example application, which has only one simplest dummy Bean, SwitchYard gets initialized pretty quickly and JNDI resource cannot be yet found... (still don't understand why).

      Could someone try to run it, observe the same and give any ideas what is wrong either in the code or maybe in JBoss setup?

      I attached the example application, the log of failed deployment and the log of successful deployment (when delay was set to 3000 ms).

      Environment: JBoss EAP 6.1.0, SwitchYard 1.1, JDK 7, Ubuntu 16