1 Reply Latest reply on Jan 30, 2012 3:27 AM by Robert Panzer

    How to use java.util.ServiceLoader inside an ear

    Robert Panzer Newbie



      I am trying to use the java.util.ServiceLoader inside an ear, i.e. I have an application like this:



           +- A.jar


                +- META-INF/services/com.xyz.MyInterface


      Now a class that is in A.jar tries to get an implementation using

      ServiceLoader.load(MyInterface.class) and alternatively ServiceLoader.load(MyInterface.class, Thread.currentThread().getContectClassLoader()).

      But unfortunately both calls fail and return an empty iterator.


      In a test without a server it works fine, but as soon as I start this stuff on JBoss it fails.


      Has anyone already managed to get something like this running?


      I could imagine, that the jboss-modules refuses loading the services resources, but it should be possible to access it specifying some dependencies like for instance when you want to get th service of a module where you set Dependencies: MyModule service


      Does anyone have a good tip?


      Thanks & kind regards,