2 Replies Latest reply on Oct 15, 2012 7:46 AM by Hwang ar

    jboss root vfile bug?

    Hwang ar Newbie

      I want to load some static resources in the root of my EAR file in a windows env with this code

       



      final VirtualFile vfile = VFS.getChild("content/"+Resources.getEarName()+".ear");


      log.info("--------------------- {} {}", vfile, vfile.getChildren().size());


      for (final VirtualFile vf : vfile.getChildren()) {


        log.info(">>>> {} {}", vf, vf.getChildren().size());


      }

       

      Contents of my EAR file as it's deployed are:

      • lib (jars)
      • META-INF
      • res (my resource files)
      • my_ejb.jar (a module ejb)
      • test.war (arquillian webapp)

       

      But the result of my code is:

       

      09:34:15,456 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) --- oip.core.app -- "/C:/workspace/com.foundation.core.ejb/content/oip.core.app/res"

      09:34:15,465 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) --------------------- "/C:/workspace/com.foundation.core.ejb/content/my-ear" 29

      09:34:15,466 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\002\footer.rpi" 0

      09:34:15,469 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/oip.foundation.core.ejb.jar" 2

      09:34:15,470 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\report-category.xml" 0

      09:34:15,476 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\002\header.rpi" 0

      09:34:15,476 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\002\header.tmx" 0

      09:34:15,477 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\report-category.xml" 0

      09:34:15,485 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\report-category.tmx" 0

      09:34:15,487 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/META-INF" 2

      09:34:15,488 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\002\env-vars.rpi" 0

      09:34:15,489 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\002\000test02.rpt" 0

      09:34:15,492 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/lib" 148

      09:34:15,492 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\002\000test02.tmx" 0

      09:34:15,494 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\002\presets.rpi" 0

      09:34:15,495 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/test.war" 1

      09:34:15,496 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) >>>> "/C:/workspace/com.foundation.core.ejb/content/my-ear/res\reports\002\.svn\entries" 0

      09:34:15,497 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) --------------------- "/C:/workspace/com.foundation.core.ejb/content/my-ear/res/reports/002" 0

      09:34:15,498 INFO  [oip.foundation.core.ejb.report.ReportTest] (http--127.0.0.1-8080-1) --------------------- "/C:/workspace/com.foundation.core.ejb/content/my-ear/res/reports/002/header.tmx" 0

       

      As you can see it seems to load resources with Windows slash and later when I try to detect size trying to load for example "content/"+Resources.getEarName()+".ear/res\reports\002\header.tmx", you can see in VFS.getChild() there is code to escape Windows slash and convert into '/'...

       

      is this a bug?

      is there any way to load some resource inside an EAR file?

       

      Thank you in advance

      Juan Arias

        • 1. Re: jboss root vfile bug?
          Stephen Coy Master

          I'm not sure VFS could be considered to be a public API. What you're doing above could conceivably break between one minor revision and the next.

           

          If the resources are completely static then you should jar them up and place the jar in the EAR/lib directory, where they can be accessed from a classloader.

           

          Alternatively, you could use the module solution described in How to put an external file in the classpath.

          • 2. Re: jboss root vfile bug?
            Hwang ar Newbie

            Thank you for your response Stephen, but I mean it might be a bug in vfs library because if I do the same with the files inside a zip/jar file everything works.  Could it be a bug in windows env of vfs lib?

             

            I need to use vfs as I need to ask for "tell me the files under a resource directory inside EAR file", and basic api of getResource cannot answer me, that's why I'm trying vfs

             

            Thank you anyway!