0 Replies Latest reply on Apr 11, 2018 7:50 AM by vineet jain

    Unable to use/load custom service provider in JBOSS

    vineet jain Newbie

      Hello,

      We have a WAR application which uses custom FileSystem and CharSet providers, implemented in the “test.jar”. However, when this web application deployed in JBoss AS 7.1.1 web server, application failed to load the these providers.

      When we execute the following code in JBOSS 7,

      String scheme = "XYZ";

      FileSystems.getFileSystem( new URI( scheme, "/", null ) ).provider();

      we get the following exception,

           java.nio.file.ProviderNotFoundException: XYZ provider not found.

      where “XYZ” is the custom file system, and its implemented in test.jar file.

      When we list the file provider in JBOSS environment using web application,

      List<FileSystemProvider> list = FileSystemProvider.installedProviders();

      for (FileSystemProvider fsp : list) {

      System.out.println("list " + fsp.toString());

      }

      The zip and windows FileSystem are listed, however our custom file system (com.myapp.xyz.fs.CpFileSystemProvider) is not listed.

      17:25:46,968 INFO  [stdout] (default task-1) list sun.nio.fs.WindowsFileSystemProvider@63b216fb

      17:25:46,969 INFO  [stdout] (default task-1) list com.sun.nio.zipfs.ZipFileSystemProvider@374dad36

       

      When we execute similar code (with test.jar in class path) under Oracle standalone JVM, the file system “com.myapp.xyz.fs.CpFileSystemProvider@5caf905d” is listed correctly.

       

      We have configured JBOSS as suggested in documentations;

      • Added “test.jar” as module in the jboss directory, and content of %JBOSS_HOME%/Module/com/myapp/xyz/main/module.xml as below

      <?xml version="1.0" ?>

      <module xmlns="urn:jboss:module:1.1" name="com.myapp.xyz">

      <resources>

          <resource-root path="test.jar"/>       

      </resources>

      </module>

       

      • test.jar has java.nio.file.spi.FileSystemProvider  file under /META_INF/services/ and content being “com.myapp.xyz.fs.CpFileSystemProvider”.
      • We have added the “com.myapp.xyz” as dependencies in META-INF/MANIFEST.MF of the war application.
      • Also created JBOSS-deploymetn-structrure.xml as below

      <?xml version="1.0" encoding="UTF-8"?> 

      <jboss-deployment-structure> 

           <deployment> 

                <dependencies>

                     <module name="com.myapp.xyz" /> 

                </dependencies> 

           </deployment> 

      </jboss-deployment-structure> 

      Followed suggestions provided in

      https://github.com/Upplication/Amazon-S3-FileSystem-NIO2/issues/39

      and have placed META-INF/services/java.nio.file.spi.FileSystemProvider in WEB-INF/classes directory. We were not able to succeed in TOMCAT , JBOSS nor Glassfish.

      We are not sure what configuration we are lacking currently. We are open to any guidance related to this issue.

       

      Regards

      Vineet