Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing with Wildfly Swarm in IDE without restarts - "hot deploy" somewhere?

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?

like image 212
lathspell Avatar asked Mar 22 '16 21:03

lathspell


3 Answers

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.

like image 54
Fred Bricon Avatar answered Nov 02 '22 18:11

Fred Bricon


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.

like image 43
Mitch Talmadge Avatar answered Nov 02 '22 18:11

Mitch Talmadge


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.

like image 33
Nándor Holozsnyák Avatar answered Nov 02 '22 19:11

Nándor Holozsnyák