4 Replies Latest reply on Sep 29, 2011 8:56 AM by oakleyx

    JBOSS 6: Exploded War - path not found

    oakleyx

      Hello,

       

      Here is my situation:  I'm using JBoss 6 and when I try and deploy my war, the war explodes and is stored in the Virtual File System. I have code thay when the application starts up, it tries to read an xml file in the the WEB-INF directory. I'm getting the following runtime exception:

       

      ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/].[ActionServlet]] Servlet.service() for servlet ActionServlet threw exception:

      java.lang.RuntimeException  C:\jboss-6.0.0\server\default\deploy\test.war\WEB-INF\classes\security.xml (The system cannot find the path specified)

       

      Now if I just explode the war manually and drop the contents in the deploy directory, the application works perfectly.

       

      So I think what i need to do, is some how figure out how to access the file in the VFS.

       

      Currently this is the code that i'm calling to return the path:

       

      ClassLoader loader = Thread.currentThread().getContextClassLoader();

      URL url = loader.getResource(this.filename);

      ..

      ..

      String path = url.getPath();

      repos = new File(path);

       

      ..

       

      Any Ideas on how I can find out how to get the virtual path?

       

      Could it be a configuration issue?

       

      Thanks

      -Dan

       

       

       

        • 1. Re: JBOSS 6: Exploded War - path not found
          esimioni

          I have the same problem, this behavior is the same at least since JBoss AS 5.1.

          Would be nice to have a solution for this annoying issue.

           

          Cheers,

           

          Eduardo.

          • 2. Re: JBOSS 6: Exploded War - path not found
            oakleyx

            I agree.

            • 3. Re: JBOSS 6: Exploded War - path not found
              jaikiran

              oakleyx wrote:

               

               

              Currently this is the code that i'm calling to return the path:

               

              ClassLoader loader = Thread.currentThread().getContextClassLoader();

               

              URL url = loader.getResource(this.filename);

              ..

              ..

              String path = url.getPath();

              repos = new File(path);

               

              ..

               

              You have done that partially right. You shouldn't be using the absolute file path while working in Java EE environment. Instead, what you (typically) need to do is:

               

              InputStream is = classLoader.getResourceAsStream(filename);

              // then use the inputstream for further processing.

               

              How do you use the "repos" later on in your code?

              • 4. Re: JBOSS 6: Exploded War - path not found
                oakleyx

                Thanks jaikiran pai, it worked!

                 

                Basicallly we pass it to an FileInputStream and it reads in parameters in a xml file.

                 

                I'm not sure why its was written this way to be honest.

                 

                Thanks Again!

                -Dan