|
|
 |
 |
| WrapperJarApp Integration (Windows) |
WrapperJarApp Integration (Windows)
 |
|
|
 |
 |
 |
|
The fourth and final method is to use the
WrapperJarApp helper class to
launch the application. This is another simple way to integrate
with the Wrapper when the application is already configured to run
as an executable jar.
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 4 (WrapperJarApp helper class),
the WrapperJarApp class replaces an application's main class.
This gives the WrapperJarApp class a chance to
immediately initialize the WrapperManager
and register the JVM with the Wrapper.
The WrapperJarApp 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 jar's manifest is
inspected and its configured main class is called. The
WrapperJarApp creates a new ClassLoader
which is able to load classes from the executable jar file as well as any
other jar files referenced within its manifest file.
The WrapperJarApp helper class
is told how to launch the application by passing the absolute or
relative location of the executable jar file, followed by any additional
application parameters to the main method of the
WrapperJarApp.
|
 |
 |
|
This section will walk you through a detailed explanation of
how to configure Hudson,
an integration engine, to run within the Wrapper.
Most other applications deployed
as executable jars
can be integrated by following the same steps.
 |
 |
|
This tutorial will start with a clean install of
Hudson.
We used "Hudson version 1.285" so the exact steps may be slightly different
depending on the exact version installed.
Hudson is deployed as a file called hudson.war.
This is to enable it to be deployed as a web application,
but it is also an executable jar.
We will install Hudson in a directory, D:\Hudson.
Create bin, lib,
conf, and logs
directories and place the hudson.war
file inside the lib directory.
|
 |
 |
|
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 Hudson
bin directory:
{WRAPPER_HOME}\bin\wrapper.exe
{WRAPPER_HOME}\src\bin\App.bat.in
{WRAPPER_HOME}\src\bin\InstallApp-NT.bat.in
{WRAPPER_HOME}\src\bin\UninstallApp-NT.bat.in
|
Rename the three batch files with refrecting your application name as follows.
Be sure to remove the .in
extensions so that the files all end in
.bat.
(Depending on how your file explorer is configured on your computer,
you may not be able to see file extensions.)
You should now have:
{HUDSON_HOME}\bin\Hudson.bat
{HUDSON_HOME}\bin\InstallHudson-NT.bat
{HUDSON_HOME}\bin\UninstallHudson-NT.bat
|
The wrapper.exe file is the actual Wrapper executable.
The three batch files are used to run Hudson in a console,
and to install and uninstall it as a Wiindows 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 following two files into the Hudson lib directory:
{WRAPPER_HOME}\lib\wrapper.dll
{WRAPPER_HOME}\lib\wrapper.jar
|
The wrapper.dll file is a
native library 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.
Please copy the following template file wrapper.conf.in
into the conf directory of Hudson.
{WRAPPER_HOME}\src\conf\wrapper.conf.in
|
Rename the file as follows.
Be sure to remove the .in
extension so that the file is named
wrapper.conf.
You should now have:
{JBOSS_HOME}\conf\wrapper.conf
|
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.
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.
|
|
 |
 |
|
In the case of an executable jar, the Java command line is quite simple.
In the case of Hudson, you would simply go to the Hudson directory and execute:
java -jar C:\Hudson\lib\hudson.war
|
Any arguments would be passed in as follows:
java -jar C:\Hudson\lib\hudson.war arg1 arg2 arg3
|
|
 |
 |
|
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.
|
NOTE
|  |
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.
|
 |
 |
|
First is to extract the Java executable and assign the location path to the
wrapper.java.command
property:
wrapper.java.command=java
|
|
 |
 |
|
Next, comes the classpath, which is configured using the
wrapper.java.classpath.<n>
properties. Java does not actually allow you to specifiy a
classpath when running with the -jar parameter. But this
integration with the Wrapper works a little differently.
The Wrapper requires that its wrapper.jar
be specified in the classpath:
wrapper.java.classpath.1=C:\Hudson\lib\wrapper.jar
|
|
 |
 |
|
When using the Wrapper and the WrapperJarApp helper class,
Java is not executing the jar directly.
It is necessary to specify the helper class as the main class of the application.
The main class executed by Java when launched is specified by using the
wrapper.java.mainclass
property as follows:
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperJarApp
|
|
 |
 |
|
Application parameters are set using the
wrapper.app-parameter.<n>
properties.
In this case, the command line to launch Hudson does not specifiy any application parameters,
but it is nessary to tell the WrapperJarApp helper class
which jar to execute. This is done as follows:
wrapper.app.parameter.1=C:\Hudson\lib\hudson.war
|
|
 |
 |
|
In order to use the Wrapper, there is one more property which
much be set. The Wrapper makes use of a native library to
control interactions with the system. This library file
wrapper.dll needs to be
specified on the library path supplied to the JVM. Hudson
does not have any native libraries of its own, but if it did,
the directories where they were located would also need to be
specified. The library path is set using the
wrapper.java-library-path.<n>
properties.
wrapper.java.library.path.1=C:\Hudson\lib
|
|
 |
 |
|
Putting it all together, we get the following:
wrapper.java.command=java
wrapper.java.classpath.1=C:\Hudson\lib\wrapper.jar
wrapper.java.library.path.1=C:\Hudson\lib
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperJarApp
wrapper.app.parameter.1=C:\Hudson\lib\hudson.war
|
Notice, while these configurations will work correctly on this
particular machine, it is highly dependent on the directory
structure and platform. By taking advantage of the fact that
the Wrapper always sets the working directory to the location
of the wrapper.exe file
and by making use of a single environment variable, we are able
to modify the above properties so that they are completely
platform and machine independent:
wrapper.java.command=%JAVA_HOME%/bin/java
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.library.path.1=../lib
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperJarApp
wrapper.app.parameter.1=../lib/hudson.war
|
|
 |
 |
|
(See:Windows Versions supported by Wrapper)
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.name=Hudson
wrapper.ntservice.displayname=Hudson Integration Engine
wrapper.ntservice.description=Hudson Integration Engine
|
|
|
 |
 |
|
Hudson can now be run by simply executing the batch file
bin\Hudson.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.
The first time Hudson starts up, it will create its configuration
files within the current user's home directory. Note that this
will most likely be a different location when running as a service
versus when running in a console window.
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.
|
|
|
|
|
 | If you notice something that is incorrect, missing, or simply feel that some part of this page could be explained better, feel free to log in and add a comment. You will need to register before you can log on. |
|
|  |
|
 |
| |