Kohei Nozaki's blog 

Exploded deployment for WildFly on development


Posted on Tuesday Jan 20, 2015 at 07:25PM in Technology


I used archive deployment for long time on development because of this problem: http://stackoverflow.com/questions/24725644/intellij-idea-artifact-xxxxwar-exploded-has-invalid-extension

Archive deployment needs redeploy for reflect updates of every resource even if I updated only static content such as html, css, xhtml and jsp. it’s very annoying but finally I found a solution to use exploded deployment with WildFly and IntelliJ IDEA for WAR application so I leave some notes about it. my environment is WildFly 8.2.0.Final and IntelliJ IDEA 14.0.2.

First, specify webappDirectory which ended with .war to pom.xml in your project so that make WildFly to stop complaining that there’s no suffix to application directory.

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <webappDirectory>${project.build.directory}/exploded/${project.build.finalName}.war</webappDirectory>
    </configuration>
</plugin>

According to https://youtrack.jetbrains.com/issue/IDEA-86484, this should be worked for EAR deployments:

<workDirectory>${project.build.directory}/myapp.ear</workDirectory>

Set following attributes to WildFly with jboss-cli for JSP hot-deployment:

/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=development, value=true)
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=check-interval, value=1)
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=modification-test-interval, value=1)
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=recompile-on-fail, value=true)
:reload

Set following parameters to web.xml for JSF(XHTML) hot-deployment:

<context-param>
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>0</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

REFRESH_PERIOD should be 2 (default) or something for production environment (filtering with maven might help). also it’s better to specify PROJECT_STAGE in JNDI.

Then configure your IDE.

for IntelliJ IDEA

  1. Click the empty drop down list on upper right then select Edit Configurations…​

    84aac7bd fd1b 4157 b840 3d2aacaf7f6b
  2. Click "+" button on upper left then select JBoss Server ⇒ Local

    74253f62 b95c 4a4d 8b00 72deac5a570b
  3. Click "Fix" on the lower right then select an artifact which ended with "exploded"

    fc2afc60 995d 4668 8840 9c3b241dd5a7
  4. Back to server tab and select desirable actions. I prefer "Update resources" for On frame deactivation because it enables that I can check modified JSP/XHTMLs with just press Command+Tab to switch to browser and reload immediately. I can trigger redeploy by hand with Command+F10 shortcut when I update some classes.

    1ff45e5f ec93 4a4c a379 7bf73ff1b138
  5. Now you can launch WildFly with the button on the upper right.

    0a5a41bc 98a8 45ab b08a db3e31e725d8

Refer http://jrebel.com for hot deployment of classes. it also offers free https://my.jrebel.com for personal, non-commercial use.



Comments:

Fantastic tips, thank you very much for sharing.

Posted by Alexandre on March 28, 2015 at 10:01 AM JST #


Hi, thanks for the article!

I need to enable hot swap of my static resources. I have no JSPs but only files such as html, css, and Javascript (its a SPA). When I followed your directions and then tried to access my app I keep getting a FORBIDDEN response from the server. Any ideas how I can fix this?

Thanks!

Posted by Jeff Mitchell on December 23, 2015 at 11:14 PM JST #


Thank you very much man

Posted by FELIPE on May 18, 2017 at 05:13 AM JST #


Leave a Comment

HTML Syntax: NOT allowed