Kohei Nozaki's blog 

Using multiple instances of WildFly on shared home directory


Posted on Saturday Jan 24, 2015 at 10:34AM in Technology


Sometimes I need to use multiple instances of WildFly, but it’s annoying to copy whole WildFly package for every needs. also it consumes many diskspace (it’s over 100MB per instance!). an instance means a configuration (deployed applications, registered JDBC driver, datasource, job repository of batch and so on) in this entry.

I leave this entry as a my note of a way to use multiple instances that sharing the home directory (core modules of WildFly) except configuration.

Explode the tarball of WildFly.

tar zxvf ~/Downloads/wildfly-8.2.0.Final.tar.gz

Copy the standalone directory for numbers that you want to use.

cd wildfly-8.2.0.Final
cp -rpv standalone standalone-1
cp -rpv standalone standalone-2

Launch an instance on a specified base directory.

bin/standalone.sh -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone-1

Also -Djboss.socket.binding.port-offset=100 parameter is useful for using multiple instance at same time. it makes WildFly to apply a offset for all of number of ports to listen. for example, following instances can be running at the same time with its own configuration and same core modules:

bin/standalone.sh -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone-1 -Djboss.socket.binding.port-offset=100
bin/standalone.sh -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone-2 -Djboss.socket.binding.port-offset=200

Note that if you use port offset and when you want to use jboss-cli, you need to start jboss-cli with an additional parameter for each instances like following:

./jboss-cli.sh --controller=localhost:10090 --connect

Configuring IntelliJ IDEA.

  1. Open Edit Configurations…​ on the drop down list in upper right corner

  2. Add Local JBoss Server instance

  3. Press Configure…​

  4. Press + button in upper left corner of the window

  5. Enter /Users/kyle/servers/wildfly-8.2.0.Final and press OK twice

  6. Put -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone-1 to VM options

  7. Put 100 to Port offset

  8. Press OK

Now you can use same Application server for each Run Configuration. you only need to copy original standalone directory and specify jboss.server.base.dir and Port offset for each projects that needed to manage separately.

Note: the size of standalone directory is around 150K. so reasonable.

kyle-no-MacBook:wildfly-8.2.0.Final kyle$ du -sh standalone
136K	standalone

References