-
1. Re: Adding a custom java FileSystemProvider to an ear / ejb
xdury Apr 15, 2016 6:54 AM (in response to dbrodski)Hi,
I have more or less the same problem as you: I am trying to use a custom ClasspathFileSystemProvider in my application to make it easier to resolve resources in various XML apis (like URIResolver...).
I have put the FQCN in META-INF/services/java.nio.file.spi.FileSystemProvider in the jar that contains my FS classes and this jar is embedded in a webapp (WEB-INF/lib).
As soon as I try to resolve a Path with the classpath scheme, I get the following error: java.nio.file.FileSystemNotFoundException: Provider "classpath" not installed (although it works without any problem in unit tests).
Did you find a solution?
Thanks,
Xavier
-
2. Re: Adding a custom java FileSystemProvider to an ear / ejb
dbrodski Apr 15, 2016 7:22 AM (in response to xdury)Hi,
I could not fix it yet, at the moment I just filter it by hand and create the provider then by calling it directly. I did not find any way to inject the module by hand, too.
I'm thinking of creating a bug in Jira, since the other Jiras indicate that it should work / is working when using spring and somehow WEB-INF.
Thanks,
David
-
3. Re: Adding a custom java FileSystemProvider to an ear / ejb
xdury Apr 15, 2016 8:25 AM (in response to dbrodski)+1 for a JIRA
I've tried to replace Paths.get(myUri) with something like FileSystems.newFileSystem(myUri, Collections.emptyMap(), Thread.currentThread().getContextClassLoader()).getPath(myUri.getSchemeSpecificPart()) but that does not work either and I get the following error: java.util.ServiceConfigurationError: java.nio.file.spi.FileSystemProvider: Provider com.sun.nio.zipfs.ZipFileSystemProvider not found.
I suppose the ServiceLoader discovers all META-INF/services/java.nio.file.spi.FileSystemProvider and tries to load com.sun.nio.zipfs.ZipFileSystemProvider but this class is not visible to my application and the wildfly "sun.jdk" module.xml does not export classes from com.sun.nio.*
Other people having the same problem:
-
5. Re: Adding a custom java FileSystemProvider to an ear / ejb
ctomc Apr 20, 2016 9:52 AM (in response to xdury)Xavier Dury wrote:
I've tried to replace Paths.get(myUri) with something like FileSystems.newFileSystem(myUri, Collections.emptyMap(), Thread.currentThread().getContextClassLoader()).getPath(myUri.getSchemeSpecificPart()) but that does not work either and I get the following error: java.util.ServiceConfigurationError: java.nio.file.spi.FileSystemProvider: Provider com.sun.nio.zipfs.ZipFileSystemProvider not found.
If you add jboss-deployment-structure.xml to your deployment and add com/sun/nio/zipfs to addiational system paths does it work?
-
6. Re: Adding a custom java FileSystemProvider to an ear / ejb
xdury Apr 22, 2016 8:59 AM (in response to ctomc)Tomaz Cerar wrote:
Xavier Dury wrote:
I've tried to replace Paths.get(myUri) with something like FileSystems.newFileSystem(myUri, Collections.emptyMap(), Thread.currentThread().getContextClassLoader()).getPath(myUri.getSchemeSpecificPart()) but that does not work either and I get the following error: java.util.ServiceConfigurationError: java.nio.file.spi.FileSystemProvider: Provider com.sun.nio.zipfs.ZipFileSystemProvider not found.
If you add jboss-deployment-structure.xml to your deployment and add com/sun/nio/zipfs to addiational system paths does it work?
Thanks, I added the following jboss-deployment-structure.xml and it was working with FileSystems.newFileSystem(...) :
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<dependencies>
<system export="true">
<paths>
<path name="com/sun/nio/zipfs" />
</paths>
</system>
</dependencies>
</deployment>
</jboss-deployment-structure>
-
7. Re: Adding a custom java FileSystemProvider to an ear / ejb
dbrodski Apr 22, 2016 11:39 AM (in response to xdury)Strangely I don't have any problems with the jre integrated zipfs. I do have the problem with a FileSystemProvider that is defined the ejb or in an additional lib. Adding a jboss-deployment-structure.xml to it did no help me, but maybe I do something wrong.