Wildfly is a Java application server for developing and deploying enterprise Java applications, web applications, and portals. Wildfly can be run as a Windows Service using FireDaemon Pro, which allows you to have the script start automatically at boot prior to login, start multiple instances of the script and more. This HOWTO will show you how to set it up. You can also use FireDaemon Fusion to manage FireDaemon and other Windows services via a web browser.
Wildfly Setup under FireDaemon Pro
Download the latest Wildfly files from the Wildfly website. You'll probably want the full version.
You need a JDK (Java Development Kit) to run Wildfly. If you don't already have a JDK, you can download Oracle's JDK from their website here. For the purposes of this HOWTO the JDK is installed in C:\Program Files\Java\jdk1.8.0_91\bin. Adjust the path to suit your installation.
Download and install FireDaemon Pro into the directory of your choice, typically C:\Program Files\FireDaemon.
Now open FireDaemon Pro by double clicking the FireDaemon desktop icon. Create a new service by clicking on the Create a new service definition button in the toolbar or typing Ctrl+N. The New Service Definition dialog will be displayed. Fill out the fields in the Program tab as follows. Adjust paths to suit your installation. Note the required parameters.
- Executable: the path to your Java file. Here we've used C:\Program Files\Java\jdk1.8.0_91\bin\javaw.exe
- Working Directory: the path to your Wildfly bin directory. Here we've used C:\Program Files\wildfly-10.0.0.Final\wildfly-10.0.0.Final\bin
The most important field on the tab is the Parameters. The Parameters define the initial setup of your server. Here’s the full parameter list you should have:
%JAVA_OPTS% "-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%" -classpath "%JBOSS_RUNPATH%" org.jboss.Main
Note: If you do want to see Wildfly running in a console window, specify java.exe instead of javaw.exe in the Executable field.
Now click on the Settings tab. Uncheck the Interact with Desktop check box unless you want to see Wildfly running in a console window. Be sure Job Type is set to Global Job.
Now click on the Logging tab. Set up debug logging and stdout/stderr capture. Adjust logging paths to suit your installation as follows:
Now click on the Environment tab. You need to specify a series of Environment variables that are used to startup Wildfly correctly. You will need to adjust the basic paths (i.e. JAVA_HOME and JBOSS_HOME) in order to suit your installation:
The environment variables to set are as follows. Note that their order must be maintained.
JAVA_HOME: e:\java\jdk1.5.0_06 JBOSS_HOME: e:\jboss-4.0.3SP1 RUNJAR: %JBOSS_HOME%\bin\run.jar JAVA: %JAVA_HOME%\bin\java.exe SHUTDOWNJAR: %JBOSS_HOME%\bin\shutdown.jar JAVAC_JAR: %JAVA_HOME%\lib\tools.jar JAVA_OPTS: -Xrs -Xms128m -Xmx512m JBOSS_ENDORSED_DIRS: %JBOSS_HOME%\lib\endorsed JBOSS_RUNPATH: %JAVAC_JAR%;%RUNJAR% JBOSS_SHUTDOWNPATH: %SHUTDOWNJAR%;%JBOSS_HOME%\client\jbossall-client.jar
Lastly click on the Pre / Post-Service tab. This is where we specify the commands to gracefully shut Wildfly down. Note, JBoss shutdown is asynchronous. Hence, once the shutdown is initiated FireDaemon needs to wait for the shutdown to complete prior to shutting down the service. Click on the Append button in the Post-Service Programs section and fill out the dialog as follows. Adjust paths to suit your installation:
java.exe or javaw.exe can be used in the Executable field. The Parameters line reads:
%JAVA_OPTS% -classpath "%JBOSS_SHUTDOWNPATH%" org.jboss.Shutdown --shutdown
Then click OK. Now add the second Post-Service Program. Click on the Append button in the Post-Service Programs section and fill out the dialog as follows:
What this does is simulate a 10 second delay by pinging the loopback adapter at a rate of one packet per second. This allows Wildfly to shut down before FireDaemon commences on its shutdown and cleanup tasks. Then, click OK:
Now click the OK button to start the service and Wildfly. Now this is where it can go all horribly wrong. If you started Wildfly with java.exe, checked Interact with Desktop set and you DIDN'T set any stdout/stderr logs, expect to see a dialog box like this:
To prove that Wildfly is running point your browser to http://localhost:8080/web-console/
Example log file. For example (editing the file with Vim):
When stopping the service, you also need to make sure Wildfly is being shut down correctly. The stderr/stdout log should contain something similar to: