Home » Java » Enterprise Java » Hot Deployment with IntelliJ IDEA

About Oleg Varaksin

Hot Deployment with IntelliJ IDEA

Recently there was a voting in the PrimeFaces forum PrimeFaces IDE Poll for the best IDE used to develop PrimeFaces applications. The most people voted for NetBeans. NetBeans and Eclipse are free IDEs. My favorite IDE IntelliJ IDEA Ultimate is not free and I think this is a reason why there are less people using it on the job. I thought it would be a good idea to show some nice features in IntelliJ. This post will demonstrate how to configure IntelliJ for the hot deployment when developing web projects. Hot deployment means you can change web resources or classes at runtime and the changes will be recognized immediately without server restart. An useful feature during development process. In the example, I will take the application server JBoss 7, but any other server can be configured in the same manner as well. A good introduction to IntelliJ and JBoss there is in the IntelliJ Wiki. For a general information regarding working with application servers in IntelliJ please refer this help page.

We assume, the application server is already configured. The next step is to configure an exploded WAR artifact for the web project. An exploded WAR is a decompressed web application archive, a directory structure that is ready for deployment on an application server. IntelliJ creates it automatically, but nevertheless, you should go to File –> Project Structure –> Artefacts and ensure that the exploded web application ends with the extension .war. If you use Maven, the exploded WAR is created below the target folder. More info on the help page.

IntelliJ0

You should also check if the Hot Swap is enabled. Go to the File –> Settings –> Debugger –> HotSwap and ensure that all checkboxes are checked and the radio button “Reload classes after compilation” is set to “Always”.

intelliJ1

As next step, click on the ” Edit Configurations…” and go to the configured server. In the ” Run/Debug Configurations” dialog, select ” Update resources” in the drop-down ” On frame deactivation”. That means, when you switch to the browser, IntelliJ will copy resource files (JavaScript, CSS) from the source location (src/main/webapp) to the directory where it builds the exploded WAR to deploy.

intelliJ2

Hot deployment for changed Java classes is resticted by JVM. E.g. the hot deployment for classes with changed method signature(s) doesn’t work. But if you changed a method body, it will work. So, if you don’t use JRebel which allows the hot deployment for classes being structurally modified, you can still rely on IntelliJ. All what you need to do for changes in Java classes is to recompile them. For that, you can go to the menu Build –> Compile or simple hit Ctrl + Shift + F9. After that, go to the browser and refresh the page to see changes.

intelliJ3
 

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

and many more ....

 

4 comments

  1. thx for the article. would like to try intelliJ. i am avid eclipse user and not a fan of netbeans. but have you tried intellij also with glassfish? eclipse for example works like a charm with jboss but is absolutely not a friend of glassfish. this is also the reason why i prefer jboss :-)

  2. The advantage I find in IntelliJ is that a good bunch of plugins are shipped and supported by jetbrain.
    I found jetty much more stable and easier to configure in IntelliJ vs Eclipse vs (nearly impossible) NetBeans.

    I expect glassfish and co to be the same.

  3. Hello, i’m getting the message, whenever I update a xhtml:

    09:45:18 Cannot package file
    IO Error:
    java.io.FileNotFoundException: D:\Documents\NetBeansProjects\qevent\target\qEvent-1.0-SNAPSHOT.war\login.xhtml (The system cannot find the stated path)

    what to do?

  4. I want to deploy a SharedLibrary on weblogic using intellij. I can not manage to inform intellij I want it to be deployed as SharedLibrary not as an Application. Do you have an experience?

Leave a Reply

Your email address will not be published. Required fields are marked *

*


5 × three =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close