[jboss-dev-forums] [JBoss AS7 Development] - Re: META-INF/services for module extensions - question/issue
Brian Stansberry
do-not-reply at jboss.com
Thu Sep 8 11:49:26 EDT 2011
Brian Stansberry [http://community.jboss.org/people/brian.stansberry] created the discussion
"Re: META-INF/services for module extensions - question/issue"
To view the discussion, visit: http://community.jboss.org/message/625561#625561
--------------------------------------------------------------
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
[http://community.jboss.org/message/625561#625561]
Start a new discussion in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20110908/1c8ef08e/attachment.html
More information about the jboss-dev-forums
mailing list