0 Replies Latest reply on Aug 8, 2014 6:26 AM by trondgzi

    JNDI lookup from a ServiceActivator implementation

    trondgzi

      Hi all!

       

      I'm in the process of upgrading from JBossAS 7.1.2 (built from source) to WildFly 8.1. My project uses a few cluster-ha-singleton services that has previously been "bootstrapped" from an ejb:

       

      @Singleton
      @Startup
      public class SingletonServiceStartup {
       @EJB
       private MyHelper fromSameModule;
       @EJB
       private MySecondHelper fromOtherModule;
      
        @PostConstruct
        public void installServices() {
          ...
          SingletonService<UUID> singleton = new SingletonService<UUID>(service, serviceName);
      
          ...
      
        }
      
      }
      

       

      This code fails in WildFly and the cluster-ha-singleton quick start shows that I need to implement a ServiceActivator instead:

       

      public class SingletonServiceActivator implements ServiceActivator {
       public void activate(ServiceActivatorContext context) {
         MyHelper fromOtherModule = InitialContext.doLookup("java:global/my-ear-file/other-module/MyHelper"); // This works fine
         MySecondHelper fromSameModule = InitialContext.doLookup("java:global/my-ear-file/my-module/MySecondHelper"); // Throws NameNotFoundException
       }
      }
      

       

      My app is packaged with 2 jar files within an ear file like this:

       

      my-ear-file.ear
      |-- other-module.jar
      |-- my-module.jar
       |-- SingletonServiceActivator.class
       |-- META-INF
         |-- services
           |-- org.jboss.msc.service.ServiceActivator
      

       

      So basically I can perform JNDI lookups in SingletonServiceActivator of EJB's in other-module.jar, but not from my-module.jar.

       

      Bug or feature? Any suggestions of a workaround?

       

       

      Regards

       

      Trond