2 Replies Latest reply on Aug 14, 2014 11:15 AM by gurupm

    HTTP 404 for dynamically added HTML files to exploded DIR

    gurupm

      I am stuck with a strange problem. There is a war which gets deployed all fine. When browser sends an HTTP request for a non-existing HTML file, Server sends back 404 - which is what I expect. However, even after I add the particular html file to the exploded WAR directory manually, server keeps sending back 404 for client requests.

       

      It looks like Server has cached the exploded dir and doesn't update its cache when I add/change something in the exploded DIR.

       

      Am I trying to do something which is impossible? Or is it a bug? Or is there some setting which I have missed?

       

      Server: Wildfly 8.1.0 Final

      Java: 1.8 on Unix

        • 1. Re: HTTP 404 for dynamically added HTML files to exploded DIR
          jaysensharma

          With the default configuration  of "Wildfly 8.1.0 Final", If you place an exploded WAR suppose "Test.war" inside the "wildfly-8.1.0.Final/standalone/deployments" which contains "test.html".  Then you should be able to access it using :

           

          http://localost:8080/Test/test.html  -----> Should Work

          http://localost:8080/Test/testA.html  ----->  should cause 404 Not Found.

           

          Then if you try to access a non existing resource  like "testA.html"  then you should get 404 error "Not Found".

           

          If then you place a html file "testA.html" inside the  "wildfly-8.1.0.Final/standalone/deployments/Test.war" directory then immediately you should be able to access the following URL successfully:

          http://localost:8080/Test/testA.html

           

          So your regarding your following queries i can say:

            1.  Am I trying to do something which is impossible?    --->  No, you are not trying to achieve something impossible.   This is possible to add a new html file in the deployed exploded war and to access it without a server / application restart.  (i tested with fresh WildFly 8.1.o Final installation and it works for me)

            2. Or is it a bug?   --->  No, it is not a bug in wildfly as it can be tested easily. I have tested the same and it works for me without any issue.

            3. Or is there some setting which I have missed?       -->  Take a fresh WildFly 8.1.0 configuration and check once again.  Try refreshing the browser (Press F5) to send a fresh request to the newly added resource..

           

           

          WildFly by default scans the changes in the "deployments" directory due to the "deployment-scaner" defined inside the

           

                  <subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
                      <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>
                  </subsystem>
          
          

           

          Which will cause the directory to be scanned every 5 seconds.

           

          {code}
          17:32:01,748 TRACE [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) Scanning directory /PATH/TO/wildfly-8.1.0.Final/standalone/deployments for deployment content changes
          17:32:01,749 TRACE [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) Executing "read-children-resources" []
          17:32:01,761 TRACE [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) Prepared response is {
              "outcome" => undefined,
              "result" => {"A.war" => {
                  "content" => [{
                      "path" => "deployments/A.war",
                      "relative-to" => "jboss.server.base.dir",
                      "archive" => false
                  }],
                  "enabled" => true,
                  "name" => "A.war",
                  "persistent" => false,
                  "runtime-name" => "A.war",
                  "subdeployment" => undefined,
                  "subsystem" => {"undertow" => undefined}
              }}
          }
          17:32:01,761 TRACE [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) Scan complete
          17:32:06,762 TRACE [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) Scanning directory /PATH/TO/wildfly-8.1.0.Final/standalone/deployments for deployment content changes
          17:32:06,762 TRACE [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) Executing "read-children-resources" []
          17:32:06,775 TRACE [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) Prepared response is {
              "outcome" => undefined,
              "result" => {"A.war" => {
                  "content" => [{
                      "path" => "deployments/A.war",
                      "relative-to" => "jboss.server.base.dir",
                      "archive" => false
                  }],
                  "enabled" => true,
                  "name" => "A.war",
                  "persistent" => false,
                  "runtime-name" => "A.war",
                  "subdeployment" => undefined,
                  "subsystem" => {"undertow" => undefined}
              }}
          }
          17:32:06,776 TRACE [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) Scan complete
          {code}
          
          

           

          So make sure to check if your deployment-scanner is enabled or disabled.

          • 2. Re: HTTP 404 for dynamically added HTML files to exploded DIR
            gurupm

            Thanks for your detailed answer Jay. I can confirm that it works fine for a war file. But I missed out a crucial point in the original post - that is, my war is packaged in an ear. In this case when I add/change html files in the exploded DIR - in my case wildfly-8.1.0.Final/standalone/tmp/vfs/deployment/deployment2d6b47ad0524c4c5/warname.war/ it does not update.

             

            One thing which I noted is: WAR files are exploded in /wildfly-8.1.0.Final/standalone/tmp/vfs/temp/temp11a57c61053dd067 whereas EAR files are not. Anyway where I can make it work for a war within an ear?

             

            Thanks in advance.