Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Kepler and JBoss Wildfly hot deployment

Tags:

I am trying to use eclipse kepler for Java EE 7.I already installed JBoss Tools and added JBoss Wildfly successfully as a server. However my changes are not automatically deployed. Is there anyway the app can be deployed automatically just as when using glassfish?

like image 470
zulqarnain Avatar asked Nov 26 '13 09:11

zulqarnain


People also ask

What is a WildFly deployment?

Description: Deploys the application to the WildFly Application Server. If force is set to true, the server is queried to see if the application already exists. If the application already exists, the application is redeployed instead of deployed. If the application does not exist the application is deployed as normal.

Can WildFly be used in production?

WildFly was formerly known as the JBoss Application Server, or JBoss AS. It is an open-source application server released under the GNU Lesser General Public License (LGPL), which means it is free to use and distribute. It is managed by Red Hat. We can use WildFly for both development and production purposes.

Can we deploy jar file in WildFly?

With Wildfly, you can deploy file types such as EJB-JAR, WAR, EAR, or any kind of standard archive (such as RAR).


2 Answers

Using Eclipse, click twice on your WildFly Server to edit the following properties:

  1. Publishing: choose "Automatically publish after a build event". I like to change the publishing interval to 1 second too.
  2. Application Reload Behavior: check the "Customize application reload ..." checkbox and edit the regex pattern to \.jar$|\.class$

That's it. Good luck!

like image 158
Valdemar Avatar answered Nov 05 '22 05:11

Valdemar


Both @varantes and @Sean are essentially correct, but these answers are not full.

Unfortunately the only way in a Java server environment to have full, zero-downtime hot deployment is to use paid JRebel or free spring-loaded tool.

But for small project there are some ways to speed up work by partial hot-deployment. Essentially:

  1. When enabled option Automatically publish when resource change then changes inside *.html, *.xhtml files are immediately reflected as soon as you refresh the browser.
  2. To make hot deployment work for *.jsp files too, then you should inside ${wildfly-home}/standalone/configuration/standalone.xml make following change:
    <jsp-config/>
    replace with:
    <jsp-config development="true"/>

restart the server and enjoy hot deployment of web files.


But when modifying *.java source files, then only partial hot deployment is possible. As @varantes stated in his answer, enabling Application Reload Behavior with regex pattern set to \.jar$|\.class$ is an option, but has serious downside: whole module is restarted, thus:

  1. It takes some time (depending on how big is a module).
  2. Whole application state is lost.

So personally, I discourage this solution. JVM supports (in debug mode) code-swapping for methods' bodies. So as long as you are modifying only bodies of existing methods, you are at home (zero downtime, changes are reflected immediately). But you have to disable automatic publishing inside server settings otherwise the application's state will still be destroyed by that republish.

But if you are heavily crafting Java code (adding classes, annotations, constructors) then unfortunately I can only recommend set publishing into Never publish automatically (or shutdown server) and when you finish your work in Java files, then restart by hand your module (or turn-on server). Up to you.


It works for small Java projects, but for bigger ones, JRebel is invaluable (or just spring-loaded), because all approaches described above are not sufficient. Also because of such problems, solutions like Rails/ Django /Play! Framework gained so huge popularity.

like image 29
G. Demecki Avatar answered Nov 05 '22 05:11

G. Demecki