4

Static contents such as HTML, CSS, JavaScript changes does not effect on page refresh. It needs a server - restart for the changes to apply. But interestingly, only for the first two times the changes are applied on page reload. But from the third time change, the changes are not seen, only the second time changed content can be seen. The contents are present in war folder. What do i need to change in the standlone.xml ? I tried "static-content" and added a handler as mentioned in the jboss forum, but it doesnot seem to be working. Kindly let me know if further information needed.

Bala Krishnan
  • 374
  • 3
  • 18

1 Answers1

6

You need to enable auto deployment of exploded content. The option is available in standalone.xml configuration file as auto-deploy-exploded attribute of deployment-scanner element:

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

To successfully achieve this, do the following:

  1. Start the server
  2. Put your WAR folder (e.g. foo.war) into deployments folder. It must be an unzipped directory structure not a single WAR file
  3. The server should deploy the contents
  4. Modify any contents in the folder
  5. The server should redeploy the contents

Please be warned (and server will warn you too) that this is unstable behavior, IMHO unsuitable for production environment.

Edit

You could also use custom handler for specific path, see configuration below (unrelated parts were omitted). This way you don't have to redeploy on every change.

     <subsystem xmlns="urn:jboss:domain:undertow:1.2">
         <buffer-cache name="default"/>
         <server name="default-server">
             <http-listener name="default" socket-binding="http"/>
             <host name="default-host" alias="jboss.local">
                 <location name="/" handler="welcome-content"/>
                 <location name="/static" handler="static"/>
             </host>
         </server>
         <handlers>
             <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
             <file name="static" path="/Users/miso/static-files" directory-listing="false"/>
         </handlers>
     </subsystem>
Mišo Stankay
  • 339
  • 1
  • 8
  • Thanks. As you mentioned this is unstable behavior. Enabling auto-deployment exploded is deploying the entire application for every "Save" i hit in eclipse. Which i dont want. For example I'm changing a small html attrib and it deploys the entire application! I'm thinking of a way to set selected directory path (which contains html,css,js files) to deploy after every change i do in them, instead of deploying the entire application. Is there any possibility? – Bala Krishnan Oct 31 '16 at 10:31