Eclipse Kepler and JBoss Wildfly hot deployment
Asked Answered
K

5

21

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?

Kevinkevina answered 26/11, 2013 at 9:28 Comment(0)
R
31

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!

Robi answered 25/2, 2014 at 18:30 Comment(2)
+1 but unfortunatelly second option has serious downside: whole applicaton state is lost.Parrisch
One thing that made it work for me: do not deploy as compressed files. In eclipse Wildfly properties, do NOT check the option "Deploy projects as compressed archives"Pyrargyrite
P
23

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.

Parrisch answered 10/9, 2014 at 9:7 Comment(4)
Even with Play! Framework, if the project grows up to a decent size, you'll encounter the same issues again.Carnegie
@AntonArhipov I don't understand why. Do you mean problems with code hot replacement? I don't think so (although never seen so big Play! project). Or do you mean just long startup?Parrisch
Specifically, hot code replacement. I'm on JRebel team (for the record) and we never considered implementing JRebel support for those fancy frameworks. But now the users start asking about the support more and more - the applications got large and the native framework reloading doesn't keep up.Carnegie
@G.Demecki That's twice you've helped me now. I just found this answer and realized I had found and upvoted it before already! Sorry I can't upvote you twice :) Thanks!Italianate
T
8

I am assuming you are using the latest version of Wildfly (8.0 Beta 1 as of writing).

In the standalone.xml config file, look for <jsp-config/>. Add the attribute development="true" and it should hot-deploy. The resulting config will look like this:

<jsp-config development="true"/>
Troopship answered 1/12, 2013 at 23:49 Comment(1)
Hi @Sean I did this but when I changed a java source file I don't notice the changes. However if I change an xhtml it is reflected.Kevinkevina
F
4

Add attributes (development, check-interval, modification-test-interval, recompile-on-fail) in configuration file in xPath = //servlet-container/jsp-config/

<servlet-container name="default" default-buffer-cache="default" stack-trace-on-error="local-only">
    <jsp-config development="true" check-interval="1" modification-test-interval="1" recompile-on-fail="true"/>
</servlet-container>

(It works in WildFly-8.0.0.Final)

Fertilize answered 12/2, 2014 at 15:22 Comment(0)
C
0

Start server in debug mode and It will track chances inside methods. Other changes It will ask to restart the server.

Conditional answered 21/1, 2017 at 15:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.