The Method 1 is to use the WrapperSimpleApp helper class to launch the application.
This is by far the simplest way to integrate with the Wrapper, and where possible, it is highly recommended.
There are some things to be aware of when using this method however.
When the Wrapper shuts down the JVM, there is no direct call to an application requesting that it shutdown cleanly.
Rather, the Wrapper will exit the JVM by calling System.exit () from within the JVM.
If the application has registered its own Shutdown Hook, it will be invoked, giving the application a chance to shutdown cleanly.
If on the other hand, a Shutdown Hook is not
registered, then the application will suddenly exit like pressing CTRL-C in the console (command window).
Both cases, with and without a Shutdown Hook, provide the exact same behavior as if the application was running without the Wrapper.
When integrating with this Method 1 the
WrapperSimpleApp helper class replaces an application's main class.
This gives the WrapperSimpleApp class a chance to immediately initialize
the WrapperManager and register the JVM with the Wrapper.
The WrapperSimpleApp class then manages all interaction with the Wrapper as well as the life-cycle of an application.
When the Wrapper sends a start message to the JVM via the WrapperManager,
the main method of the application's actual main class is called.
The WrapperSimpleApp helper class is told how to launch the application by passing the application's
main class name, followed by any additional application parameters to the main method of the WrapperSimpleApp.
This section will walk you through a detailed explanation of how to configure
JBoss to run within the Wrapper.
Most other applications can be integrated by following the same steps.
This tutorial will start with a clean install of JBoss.
We used JBoss version 6.0.0.Final so the exact steps may be slightly different depending on the exact version installed.
JBoss was installed in the root directory, D:\,
resulting in a JBoss Home directory of D:\jboss-6.0.0.Final.
Installing Wrapper Files
There are four directories which are required to be configured in order to be able to use the Wrapper.
First, please copy the following files into the JBoss bin directory:
The wrapper.exe file is the actual Wrapper executable.
The three batch files are used to run JBoss in a console, and to install and uninstall it as a Windows Service.
These batch files should not require any modification.
They do assume that the wrapper.conf file will be located
within a conf directory one level up, ../conf/wrapper.conf.
If you wish to place the wrapper.conf file somewhere else,
then the three batch files will require appropriate modification.
Copy the native library into the JBoss bin\native\lib directory in case you plan
to run 32-bit version of JBoss and the Wrapper or bin\native\lib64 directory for 64-bit:
With version 6, JBoss is utilizing the HornetQ Project, hence to that,
the 2 bin\native\lib* directories are existing.
(Earlier versions of JBoss are not having those 2 directories.)
In this case, please copy the native library to JBoss's lib directory.
Finally you also need to copy the wrapper.jar file to JBoss's lib directory:
The wrapper.dll file is a native library
file required by the portion of the Wrapper which runs within the JVM.
The wrapper.jar file contains all of the Wrapper classes.
The Wrapper requires a configuration file
wrapper.conf for each application.
The standard location for this file is in a conf directory in the application's home directory.
JBoss does not have such a directory by default, so we will need to create one.
Please copy the following template file wrapper.conf.in
into the conf directory of JBoss.
Rename the file and be sure to remove the .in
extension as follows so that the file is named wrapper.conf.
You should now have:
If you wish to relocate the configuration file wrapper.conf, you are free to do so.
You will need to modify the batch files copied into the bin directory above, to reflect the new location.
The default configuration file wrapper.conf will place a
wrapper.log file in a logs directory under the application's home directory.
JBoss does not have such a directory by default, so we will need to create one.
You should now have the following directory:
If you wish to place the wrapper.log file in another location,
you will need to edit the wrapper.conf file and modify the
wrapper.logfile property to reflect the new location.
If you wish to place the *.mo files to another location, you will need
to edit the wrapper.conf file and modify the
wrapper.lang.folder property to reflect the new location.
Locate the Application's Java Command Line
Before the Wrapper can be configured to launch an Application, you will need to know the full Java command which is normally used.
Most applications make use of a batch file to build up the actual command line.
These batch files tend to get quite unwieldy but in fact, the featured ability to avoid
having to work with them is one of the benefits of working with the Wrapper.
JBoss is launched by default using a batch file called run.bat.
It is launched by first changing the current directory to the bin directory and then run from there.
If you open run.bat into an editor, you will notice the following line towards the end of the file:
The majority of the script has the task of collecting system specific information and storing that information into environment variables.
The lines above then expands all of the collected information into the final Java command which launches the application.
From looking at the source of the batch file, we hope you appreciate the complexity
and the desire to have to avoid completely writing such scripts yourself.
In order to configure the Wrapper, all that is really needed is the final expanded command line.
Rather than reading through the entire script and attempting to understand it,
we will use a simple trick to display the final command line in the console.
Edit the batch file run.bat by inserting ECHO at the beginning of the above line.
After doing so, you should have:
In order to be able to use the above Java command line with the Wrapper,
we need to break up the command line's components into a configuration file.
Open the wrapper.conf file into an editor and make the changes below.
Where properties are mentioned below, links are provided to their descriptions.
Please take the time to review the descriptions of any properties which are modified.
In many cases, there are further details on their usage which are not mentioned here.
For an easy configuration, it is recommended to store the HOME directory
of Jboss and Java into environment variables in the configuration file.
This will make the conf file easier to read and mantain in case a directory path gets changed.
The Java Service Wrapper will set these environment variables everytime it launches:
First is to extract the Java executable and assign the location path to the
Most applications provide a number of parameters to the Java executable when it is launched.
The Wrapper provides special properties for configuring things like memory, as well as class and library paths.
These will be covered below, however any other settings are configured using the
wrapper.java.additional.<n> series of properties.
The JBoss 6.0.0.Final command line has already 8 additional Java Argument.
# Initial Java Heap Size (in MB)
# Maximum Java Heap Size (in MB)
JBoss with version 6 is utilizing internally a MBeanServer Factory based on
However this one is incompatible to the default JVM MBeanServerBuilder
So when the Wrapper starts, it would create the MBeanServer using the JVM's default MBeanServer;
when JBoss starts, it also tries to register its MBeans to the MBeanServer, however because of
the incompatibility with the default JVM's MBeanServer, JBoss will fail to register any MBean.
If you will not need the Wrapper-sided MBeans provided by the Wrapper, the shortest resolution on
this incompatibility would be to deactivate the Wrapper-sided MBeans and thus the creation of the MBeanServer.
To disable please set this following property:
JBoss versions prior to 6 do not need this as they are not instrumenting an own MBeanServer Factory, so disabling is not necessary.
If you are running JBoss version 6.* but want to make use of the Wrapper's MBeans.
Please follow the discriptions on the JMX guide.
Notice that the full property was copied directly from the command line without any modifications.
See the property documentation about how to handle properties containing spaces.
Next, comes the classpath, which is configured using the
The Wrapper requires that the classpath be broken up into its individual elements.
Then, because we will also be making use of the Wrapper,
it is necessary to include the wrapper.jar file as well:
The final component of the command used to launch JBoss is the main class, org.jboss.Main.
The main class executed by Java when launched is specified by using the
As mentioned above; however, because the JBoss main class does not know how to communicate with the Wrapper,
we will set the main class to be the full class name of WrapperSimpleApp.
The JBoss main class is then specified as the first application parameter below.
Application parameters are set using the
Application parameters appear in the Java command line directly after the main class.
While JBoss does not have any such parameters, it is still necessary to set one of these properties.
This is because we are using the WrapperSimpleApp helper class and as described above.
Its first parameter is the main class name of the application being run, in this case org.jboss.Main:
In order to use the Wrapper, there is one more property which must be set.
The Wrapper makes use of a native library to control interactions with the system.
This library filewrapper.dll
needs to be specified on the library path supplied to the JVM.
JBoss 6 also has the native library from HornetQ in the
bin\native\lib* directories for 32/64-bit architectures.
As the wrapper.dll file should have been copied there as well, there is only one definition necessary.
If you are using another native library file sometimes you have to define it here subsequently.
The library path is set using the
The final step is to set the Windows Service Properties properties.
We will just set the properties which should be changed.
But there are several others available.
See the documentation for details on their usage.
Suggested values for these variables are shown below.
wrapper.ntservice.displayname=JBoss Application Server
wrapper.ntservice.description=JBoss Application Server
Trying It Out
JBoss can now be run by simply executing the batch file bin\JBoss.bat.
Because of the way the Wrapper sets its current directory, it is not necessary
to run this batch file from within the bin directory.
Please try running the application once as a console application
to verify the configuration before attempting to run it as a service.
Congratulations. Your application should now be up and running.
If you did have any problems, please take a look at the Troubleshooting
section for help with tracking down the problem.
Tuning The Startup
By default the
class will wait 2 seconds for the user application's main method to complete.
After that, it assumes that the application has started and reports back to the Wrapper process.
This is done because many user applications are written with main methods that do not return for the life of the application.
In such cases, there is no reliable way for the WrapperSimpleApp
class to tell when and if the application has completed its startup.
If, however, it is known that the application's main method will return once the application
is started, it would be ideal for the Wrapper to wait until it has done so before continuing.
Waiting indefinitely is an advantageous option if it's known for sure that the main method will return in a timely manner.
But on the other hand, while it is waiting eternally, the Wrapper will never give up on the startup process, no matter how long it takes.
So, if there is any chance that this startup could hang, then the
system property to set the maximum wait time may be a better option.
For instance, to wait for up to 5 minutes (300 seconds) for the startup main method to complete,
set the property to 300 as follows:
The main methods of many applications are designed not to return.
In these cases, you must either stick with the default 2 second startup timeout
or specify a slightly longer timeout.
This is possible using the maxStartMainWait property,
to simulate the amount of time your application takes to start up.
If TRUE in the waitForStartMain is specified for an application
whose start method never returns, the Wrapper will appear at first to be functioning correctly.
However, the Wrapper is actually in a wait status eternally and will never enter a running state.
This means that the Windows Service Manager and several of the Wrapper's error recovery mechanisms will not function correctly.