JBoss Community

Re: META-INF/services for module extensions - question/issue

created by Brian Stansberry in JBoss AS7 Development - View the full discussion

Here's my guess at to what is going on. If this doesn't describe what you're doing, then never mind. ;)

 

You have a class ModuleExtensionClass that's in your ModuleExtension module. And another class ServiceAPIClass that's either in ModuleExtension or Module.

 

In ModuleExtensionClass.initialize(ExtensionContext) you are calling

 

ServiceLoader.load(ServiceAPIClass.class)

 

If that call is failing with a CNFE, it's a sign that the module dependencies aren't set up right. But my theory is that's not what's happening.

 

If I'm correct so far, does using this call work?

 

ServiceLoader.load(ServiceAPIClass.class, ModuleExtensionClass.class.getClassLoader())

 

The single arg variant of ServiceLoader.load is the same as calling ServiceLoader.load(Class c, Thread.currentThread().getContextClassLoader()); In AS 7.0.0/7.0.1 when Extension.initialize is called the TCCL is null, so you're not going to get the correct classloader.

 

We have changed this in master, so in 7.0.2 when Extension.initialize is called, the TCCL will the defining classloader of the Extension impl (i.e. ModuleExtensionClass.class.getClassLoader()). So, if my theory is right you should find this works in a current build of master but not in 7.0.1.

Reply to this message by going to Community

Start a new discussion in JBoss AS7 Development at Community