4 Replies Latest reply on Apr 15, 2009 1:02 AM by juergen.zimmermann

    VFS & Commons Configuration issue

    past

      Migrating our application to JBoss 5 from JBoss 4 caused the automatic reloading of configuration files in server/default/conf/ to stop working. The culprit appears to be that resolving the (relative) path through the context class loader results in a vfsfile: url, that Commons Configuration does not know how to handle. Is there any way to refer to these directories with relative paths, but without vfsfile urls? Messing with org.jboss.virtual.VFSUtils would make our code JBoss5-specific, while using absolute paths would present platform-compatibility issues.

        • 1. Re: VFS & Commons Configuration issue
          alesj

          If you work directly on URLs it should work.

          There are some cases where we were able to plug-in our VFS impl:
          * Seam
          * Spring
          * Drools
          * Camel

          Or I submitted a patch that did work explicitly on URLs,
          hence hiding the VFS underneath.
          * Facelets

          What's the code that fails?

          • 2. Re: VFS & Commons Configuration issue
            past

            Essentially the FileChangedReloadingStrategy from Commons Configuration was doing this:

            private File fileFromURL(URL url)
            {
             if (JAR_PROTOCOL.equals(url.getProtocol()))
             {
             String path = url.getPath();
             try
             {
             return ConfigurationUtils.fileFromURL(new URL(path.substring(0,
             path.indexOf('!'))));
             }
             catch (MalformedURLException mex)
             {
             return null;
             }
             }
             else
             {
             return ConfigurationUtils.fileFromURL(url);
             }
            }
            


            I extended it as follows and it's working now:

            private File fileFromURL(URL url)
            {
             if (VFSFILE_PROTOCOL.equals(url.getProtocol()))
             {
             String path = url.getPath();
             try
             {
             return ConfigurationUtils.fileFromURL(new URL("file:" + path));
             }
             catch (MalformedURLException mex)
             {
             return null;
             }
             }
             else if (JAR_PROTOCOL.equals(url.getProtocol()))
             {
             String path = url.getPath();
             try
             {
             return ConfigurationUtils.fileFromURL(new URL(path.substring(0,
             path.indexOf('!'))));
             }
             catch (MalformedURLException mex)
             {
             return null;
             }
             } else
             return ConfigurationUtils.fileFromURL(url);
            }
            


            Can you see anything wrong with this approach?

            • 3. Re: VFS & Commons Configuration issue
              alesj

              It might not always work if the resource is nested,
              but then so wouldn't the original version with jar protocol handling.

              • 4. Re: VFS & Commons Configuration issue
                juergen.zimmermann

                BTW, Jersey (reference impl. for JAX-RS) is patched using the same idea.