JSP Dynamic Change in JBoss AS 7.1

2

Hello.

As far as I'm working with JSP I find it very bad to have to pause and start the application every time you need to see a change. Do you have any way to update page changes without doing all of this?

    
asked by anonymous 24.07.2014 / 19:25

2 answers

3

You can make a modification to use HotDeploy in Jboss 7 as well.

This configuration is in the jboss-service.xml file located in the conf / partition folder (all / default / etc) used ...

Below is an excerpt from the file where the scanning settings are specified.

<!-- ==================================================================== -->  
<!-- Deployment Scanning                                                  -->  
<!-- ==================================================================== -->  

<!-- An mbean for hot deployment/undeployment of archives.  
-->  
<mbean code="org.jboss.deployment.scanner.URLDeploymentScanner"  
name="jboss.deployment:type=DeploymentScanner,flavor=URL">  

<!-- Uncomment (and comment/remove version below) to enable usage of the  
 DeploymentCache  
<depends optional-attribute-    name="Deployer">jboss.deployment:type=DeploymentCache</depends>  
-->  
 <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends>  

 <!-- The URLComparator can be used to specify a deployment ordering  
    for deployments found in a scanned directory.  The class specified  
    must be an implementation of java.util.Comparator, it must be able  
    to compare two URL objects, and it must have a no-arg constructor.  
    Two deployment comparators are shipped with JBoss:  
      - org.jboss.deployment.DeploymentSorter  
        Sorts by file extension, as follows:  
          "sar", "service.xml", "rar", "jar", "war", "wsr", "ear", "zip",  
          "*"  
      - org.jboss.deployment.scanner.PrefixDeploymentSorter  
        If the name portion of the url begins with 1 or more digits, those  
        digits are converted to an int (ignoring leading zeroes), and  
        files are deployed in that order.  Files that do not start with  
        any digits will be deployed first, and they will be sorted by  
        extension as above with DeploymentSorter.  
  -->  
  <attribute name="URLComparator">org.jboss.deployment.DeploymentSorter</attribute>  

  <!--  
  <attribute    name="URLComparator">org.jboss.deployment.scanner.PrefixDeploymentSorter</attribute>  
   -->  

  <!-- The FilterInstance specifies a URLLister.URLFilter for scanned  
    directories. This DeploymentFilter is initialized with the given  
    prefixes, suffixes and matches that define which URLs should be  
    ignored.  
  -->  
  <attribute name="FilterInstance"  
  attributeClass="org.jboss.deployment.scanner.DeploymentFilter"  
  serialDataType="javaBean">  
  <!-- Files starting with theses strings are ignored -->  
  <property name="prefixes">#,%,\,,.,_$</property>  
  <!-- Files ending with theses strings are ignored -->  
  <property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>  
  <!-- Files matching with theses strings are ignored -->  
  <property     name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</prope     rty>  
  </attribute>  

 <!-- Frequency in milliseconds to rescan the URLs for changes -->  
 <attribute name="ScanPeriod">5000</attribute>  

 <!-- A flag to disable the scans -->  
 <attribute name="ScanEnabled">true</attribute>  

<!-- URLs are comma separated and resolve relative to the server home URL  
  unless the given path is absolute. If the URL ends in "/" it is  
  considered a collection and scanned, otherwise it is simply deployed;  
  this follows RFC2518 convention and allows discrimination between  
  collections and directories that are simply unpacked archives.  

  URLs may be local (file:) or remote (http:). Scanning is supported  
  for remote URLs but unpacked deployment units are not.  

  Example URLs:  
     deploy/  
          scans ${jboss.server.url}/deploy/, which is local or remote  
          depending on the URL used to boot the server  
     ${jboss.server.home}/deploy/  
          scans ${jboss.server.home}/deploy, which is always local  
     file:/var/opt/myapp.ear  
          deploy myapp.ear from a local location  
     file:/var/opt/apps/  
          scans the specified directory  
     http://www.test.com/netboot/myapp.ear  
          deploys myapp.ear from a remote location  
     http://www.test.com/netboot/apps/  
          scans the specified WebDAV location  
  -->  
  <attribute name="URLs">  
    deploy/  
  </attribute>  

  <!-- Indicates if the scanner should recursively scan directories that  
  contain no "." in their names. This can be used to group applications  
  and services that must be deployed and that have the same  
  logical function in the same directory i.e.  
  deploy/JMX/  
  deploy/JMS/  
  ...  
 -->  
  <attribute name="RecursiveSearch">True</attribute>  

</mbean>  
    
24.07.2014 / 20:18
2

Make an exploded deploy (that is, with a folder and not the war / ear). How to do this depends on your deploy mechanism and artifact type. For a web project managed by maven for example you would do this with mvn war:exploded . I also needed to change my build so that the generated folder ends in .war , but I do not know if this is specific to my version of JBoss.

projeto/target/meu-war-versao.war/ 

In addition, most IDEs can be configured to update features when saving (I'm using IDEA, but I know Netbeans does this, and I believe Eclipse as well). This way you do not even have to invoke the command in maven to update the features.

Finally, magic happens in your settings. If you use JBoss 7 in standalone mode, change the file standalone.xml and add the following configuration:

<configuration>
   <jsp-configuration development="true" check-interval="1" modification-test-interval="1" recompile-on-fail="true"/>
</configuration> 

Within the tag subsystem ( xmlns=":urn:jboss:domain:web:1.1" ).

Warning : As per this post in the JBoss community There is a bug in version 7.1.1 that prevents hot deploy , use version 7.1.2 or higher.

    
24.07.2014 / 20:19