ServiceLoader issue in WebLogic12c

855 Views Asked by At

I have been trying to refactor our Activiti implementation into using CDI but ran into a number of problems. I've spent way too much time trying to resolve this already, but I just can't let it go...I think I've pinned the problem down now, setting up a clean structured war without involving Activiti and have been able to reproduce what I think is the main problem.

Basically I have jar1 and jar2, both CDI enabled by including META-INF/beans.xml. Both jars specify a class in META-INF/services/test.TheTest pointing to implementations local to respective jar. jar1 depends on jar2. Also, both jars point to an implementation of javax.enterprise.inject.spi.Extension, triggering the scenario. In each implementation of Extension, I have a method like:

public void afterDeploymentValidation(
        @Observes AfterDeploymentValidation event, BeanManager beanManager) {


    System.out.println("In jar1 extension"); 
    ServiceLoader<TheTest> loader = ServiceLoader.load(TheTest.class);
    Iterator<TheTest> serviceIterator = loader.iterator();
    List<TheTest> discoveredLookups = new ArrayList<TheTest>();
    while (serviceIterator.hasNext()) {
        TheTest serviceInstance = (TheTest) serviceIterator.next();
        discoveredLookups.add(serviceInstance);
        System.out.println(serviceInstance.getClass().getName());
    }
}

Now, my problem is that the ServiceLoader does not see any implementations in either case when running WebLogic12c. The same code works perfectly fine in both Jboss 7.1.1 and Glassfish , listing both implementations of the test.TheTest interface.

Is it fair to assume that this is indeed a problem in WebLogic 12c or am I doing something wrong? Please bare in mind that I am simply trying to emulate the production setup we use when incorporating Activiti.

Regards, /Petter

1

There are 1 best solutions below

0
On

There is a Classloader Analysis Tool provided with WLS, have you seen if this will help with the diagnosis of your issue.

You can access this tool by going to ip:port/wls-cat/index.jsp Where port will be the port of the managed server where your application is deployed.