-
15. Re: URL-Protocol Handler doesn't work
skoure Apr 11, 2012 10:01 AM (in response to dmlloyd)David,
If I understand you correctly jboss.protocol.handler.modules requires a
URLStreamHandlerFactory.
The jcifs package does not include a
URLStreamHandlerFactory since
java.protocol.handler.pkgs only requires a URLStreamHandler.
Hence, I created a seperate jar with a URLStreamHandlerFactory and placed it in the modules/jcifs/main directory. (see code below)
In the META-INF/services directory of this jar contains a text file named java.net.URLStreamHandlerFactory which contains the fully-qualified name of this factory.
In the module.xml file I added this new jar as a resource-root and removed the service-loader-resources directory from the resources list.
the org.jboss.as.standalone module still has a dependency on the jcifs module.
I am still getting the same MalformedURLException unknown protocol: smb.
I put a break point on the createURLStreamHandler method, but it never seems to be called.
public class SmbStreamHandlerFactory implements URLStreamHandlerFactory { @Override public URLStreamHandler createURLStreamHandler(String protocol) { if((protocol != null) && ("smb".equals(protocol.toLowerCase()))) { return new jcifs.smb.Handler(); } return null; } }
-
16. Re: URL-Protocol Handler doesn't work
dmlloyd Apr 11, 2012 10:24 AM (in response to skoure)Stephen Kouretas wrote:
David,
If I understand you correctly jboss.protocol.handler.modules requires a
URLStreamHandlerFactory.
Correct.
Stephen Kouretas wrote:
The jcifs package does not include a
URLStreamHandlerFactory since
java.protocol.handler.pkgs only requires a URLStreamHandler.
Hence, I created a seperate jar with a URLStreamHandlerFactory and placed it in the modules/jcifs/main directory. (see code below)
In the META-INF/services directory of this jar contains a text file named java.net.URLStreamHandlerFactory which contains the fully-qualified name of this factory.
In the module.xml file I added this new jar as a resource-root and removed the service-loader-resources directory from the resources list.
the org.jboss.as.standalone module still has a dependency on the jcifs module.
I am still getting the same MalformedURLException unknown protocol: smb.
This is after you added your module name to jboss.protocol.handler.modules?
-
17. Re: URL-Protocol Handler doesn't work
skoure Apr 11, 2012 11:49 AM (in response to dmlloyd)Stephen Kouretas wrote:
The jcifs package does not include a
URLStreamHandlerFactory since
java.protocol.handler.pkgs only requires a URLStreamHandler.
Hence, I created a seperate jar with a URLStreamHandlerFactory and placed it in the modules/jcifs/main directory. (see code below)
In the META-INF/services directory of this jar contains a text file named java.net.URLStreamHandlerFactory which contains the fully-qualified name of this factory.
In the module.xml file I added this new jar as a resource-root and removed the service-loader-resources directory from the resources list.
the org.jboss.as.standalone module still has a dependency on the jcifs module.
I am still getting the same MalformedURLException unknown protocol: smb.
This is after you added your module name to jboss.protocol.handler.modules?
Both the jcifs.jar and my jar with the URLStreamHandlerFactory (jcifs_wrapper.jar) are in the jcifs module directory.
module.xml references both jar resources.
<module xmlns="urn:jboss:module:1.1" name="jcifs" > <resources> <resource-root path="jcifs_wrapper.jar"/> <resource-root path="jcifs-1.3.15.jar"/> </resources> </module>
standalone.conf.bat still contains:
set JAVA_OPTS=%JAVA_OPTS% -Djboss.protocol.handler.modules=jcifs
boot.log confirms this settng:
jboss.protocol.handler.modules = jcifs
-
18. Re: URL-Protocol Handler doesn't work
skoure Apr 11, 2012 4:28 PM (in response to dmlloyd)David,
I downloaded the source for the Module loader system and was stepping through the code and discovered the following:
When the ModuleURLStreamHandlerFactory loads the jboss.protocol.handler.modules, jcifs is in the list.
When ModuleURLStreamHandlerFactory attempts to load the Module, the ModuleLoader.loadModuleLocal attempts to use Module.log which is null and hence causes an Exception and the jcifs module does not get loaded and does not get added to the list of modules.
I'm not sure why Module.log is null.
Is there some configuration that needs to be set first so that Module.log will be properly set?
-
19. Re: URL-Protocol Handler doesn't work
dmlloyd Apr 11, 2012 4:57 PM (in response to skoure)Interesting. Sounds like a simple bug; I can check into it.
-
20. Re: URL-Protocol Handler doesn't work
dmlloyd Apr 11, 2012 5:04 PM (in response to dmlloyd)I've created this issue to track the problem: https://issues.jboss.org/browse/MODULES-131
Can you try building this revision of jboss-modules and replacing your jboss-modules.jar with the result? http://github.com/dmlloyd/jboss-modules/commit/98d546c
-
21. Re: URL-Protocol Handler doesn't work
skoure Apr 12, 2012 11:05 AM (in response to dmlloyd)Thanks David,
I built the code and the logger is no longer null.
However, I am now getting a NPE at line 881 of org.jboss.modules.Module when it is linking my jcifs module. It appears the classFilterStack is null.
-
22. Re: URL-Protocol Handler doesn't work
dmlloyd Apr 12, 2012 11:49 AM (in response to skoure)Hmm, that's odd. Can you get a stack trace?
-
23. Re: URL-Protocol Handler doesn't work
dmlloyd Apr 12, 2012 11:50 AM (in response to dmlloyd)Never mind, I see: it's a class initialization order problem again. A constant field is not yet initialized. I think I'll have to do some reshuffling here.
-
24. Re: URL-Protocol Handler doesn't work
dmlloyd Apr 12, 2012 12:35 PM (in response to dmlloyd)Can you please try this commit: http://github.com/dmlloyd/jboss-modules/commit/c8eb426 - I examined the complete init order of the Module class (and uncovered another issue or two in the process). Now Module should be fully initialized before URL handler modules are loaded.
-
25. Re: URL-Protocol Handler doesn't work
skoure Apr 12, 2012 1:01 PM (in response to dmlloyd)David,
This version seems to work.
Thanks for all your help and quick responses to my issues.