6

I'm interested in the Wildfly Swarm project to create fat-jar JavaEE application but can't figure out how to "hot deploy" changed classes from the IDE.

Whenever I change a line of code or a JSF xhtml file I currently have to restart the whole application which takes 7s or so. That's not very productive.

Spring Boot offers a spring-boot-devtools that reloads at least some classes, traditional app servers offer hot-deploy protocols. Is there anything similar for Wildfly Swarm? Would JRebel help here?

user140547
  • 7,750
  • 3
  • 28
  • 80
lathspell
  • 3,040
  • 1
  • 30
  • 49

4 Answers4

6

You can run WildFly Swarm as a Java Application directly from sources in your favorite IDE, by calling your own Main class or the org.wildfly.swarm.Swarm class. This saves you the packaging step.

As for hot class reloading, as usual, the JVM will be able to reload non-structural changes, but will have to be restarted whenever you "break" a class signature. I haven't tried it but it's very likely JRebel might be able to help there.

If you're an Eclipse user, you can give wildfly-hive a try. It tries to autodetect swarm apps and creates matching servers in the servers view. You just have to click start/debug/stop, similar to standard servers in Eclipse.

Fred Bricon
  • 5,369
  • 1
  • 31
  • 45
  • I tried using org.wildfly.swarm.Swarm on my Eclipse project using wildfly swarm. And it works! But the problem is that the war file it generated is different. So for example my project name is Test.war but during debug deployment it creates something like, 507ac020-cc98-4956-9c88-418869842dcf.war... so what happens is that my bean lookup will fail. – Artanis Zeratul Sep 12 '17 at 00:37
  • I use JRebel to debug my WildFly Swarm applications and it works great – gastaldi Jun 08 '18 at 11:55
1

My solution was to use IntelliJ IDEA and create an exploded WAR artifact from my sources. Don't include any of the WildFly Swarm dependencies, but do include everything else.

Then you can use regular old WildFly Standalone with the JBoss run configuration, and IntelliJ will deploy the exploded war. From there you can hot swap, debug, etc.

For development, run your code on WildFly Standalone. For production, use the WildFly Swarm jar. This works perfectly for me, and I've been using this method for months without many problems.

Mitch Talmadge
  • 4,638
  • 3
  • 26
  • 44
  • 1
    I'm trying to achieve the exact same thing, but have no idea where to start. How do you deal with exclusion of swarm-related dependencies? – Nicolas Nov 30 '16 at 11:14
1

I know it's a bit late but when using IntelliJ IDEA we are using the org.wildfly.swarm.Swarm class, which can be started from the IDE and it gives you the ability to hot reload classes in Debug mode. You can make a run config with that, make sure you set the Working directory and the Use classpath of module configs.

-3

I would suggest using IntelliJ Idea. Its JavaEE project template work with hot deploy on most application servers.

Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
  • 1
    Wildfly Swarm is not an application server. It just bundles the Wildfly libraries into a fat jar. As far as I know it does not open a hot deploy port for the IDE to use (but maybe could do so, that's what I wanted to know). – lathspell Mar 23 '16 at 09:54