Article ID: 000020
Last Revised On: 22-Sep-2005
PDF Version: 000020.pdf
The information in this article applies to:
This article does not apply to Excelsior JET 4.0 and above.
This document contains step-by-step instructions for using Excelsior JET to compile the Caucho Resin application server along with your deployed Web applications. Deployment of the entire system to end users is also covered.
Project files and build/run scripts for this article may be found here.
Today’s state-of-the-art server-side Java applications usually run on a so-called application server. The application server itself is also a Java program and thus can be converted to an executable using Excelsior JET.
A typical application server, such as Caucho Resin, loads applications for further execution through server-specific classloading that cannot be defined before the actual server execution. As a result, deployed applications can not be precompiled together with the server, but have to be dynamically compiled during the server run. The Caching JIT compiler, available only in Excelsior JET, Professional Edition, is capable of compiling classes loaded by those server-specific classloaders, and caching the results of compilation to disk. For better performance, you may optimize the accumulated JIT cache using the JIT cache optimizer.
To sum up, in order to compile a typical Java application server together with deployed applications into binary executables using Excelsior JET, you have to perform three major steps:
Note: You would still have to include the original application jars in the deployment package, since it can not be guaranteed that all application classes were used during load testing and thus put in the JIT cache. Moreover, even if some class was compiled and cached, it may happen that it has to be compiled again.
We will now illustrate the process of optimizing Web applications deployed onto Caucho Resin application server. We used Caucho Resin version 3.0.8, so if you are using another version of Resin, details may be slightly different.
Below we assume that Resin-dir is the Resin installation directory (/home/user/resin-ee-3.0.8 in the screenshots.)
For each jar file you add, answer “Yes” in reply to the question “Force the entire jars into the project?” to make sure that all classes are compiled.
After successful completion of the compilation process, close the JET Control Panel.
Resin is a Java application and thus is normally started using the java tool, which allows you to specify Java system properties on the command line. JET-compiled Resin is a binary executable that is run by itself, so it reads Java system properties from the JETVMPROP environment variable. Furthermore, JET-compiled applications recognize a slightly different format of Java properties than the Sun java tool does. Thus, you have to patch one of Resin startup scripts. This section explains the workflow.
You also need to temporarily set the property jet.jit.save.classes to enable subsequent recompilation of the JIT cache.
Replace the line
$EXTRA_JAVA_ARGS="-Djava.util.logging.manager=com.caucho.log.LogManagerImpl"; with
$EXTRA_JAVA_ARGS="-Djet.jit.save.classes \
-Djava.util.logging.manager:com.caucho.log.LogManagerImpl";
Replace the line
$JAVA_ARGS .= " -Dresin.home=$SERVER_ROOT $EXTRA_JAVA_ARGS";
with
$JAVA_ARGS .= " -Dresin.home:$SERVER_ROOT $EXTRA_JAVA_ARGS";
$ENV{"CLASSPATH"} = $CLASSPATH;
if ($JAVA_HOME) {
$ENV{"JAVA_HOME"} = $JAVA_HOME;
}
with the line
$ENV{"JETVMPROP"} = $JAVA_ARGS;
This Perl statement is analogous to the shell command export JETVMPROP=$JAVA_ARGS.
exec("$JAVA_EXE $JAVA_ARGS $class $conf $RESIN_ARGS");
die("Can't start java: $JAVA_EXE $JAVA_ARGS $class $conf $RESIN_ARGS");
with
exec("$RESIN_HOME/Excelsior/Resin $conf $RESIN_ARGS");
die("Can't start java: $RESIN_HOME/Excelsior/Resin $conf $RESIN_ARGS");
so that the Resin executable is launched instead of the java tool.
Note: The above are the basic changes required to run Resin properly on the next step. Before using JET-compiled Resin in production, you should edit the script more thoroughly. That is, edit the if ($verbose) {...} block, check all the parameters passed to the script and so on.
Make sure Resin is not running and invoke the script Resin-dir/Excelsior/http.sh to launch the JET-compiled Resin.
Now, stress test your Web application(s) to achieve the largest possible code coverage. Ideally, you should use all features, all modes of operation, and all their combinations on large amounts of heterogeneous input data. After that, shut down the Resin server using the Ctrl-C key sequence.
Note however that non-exhaustive testing does not imply that your application will not function properly after JET-compilation. The idea is that thorough testing will result in caching of more classes, so more classes will be optimized on the next step.
When you are done with stress testing, remove jet.jit.save.classes property setting from Resin-dir/Excelsior/wrapper.pl again:
Replace the line
$EXTRA_JAVA_ARGS="-Djet.jit.save.classes \
-Djava.util.logging.manager:com.caucho.log.LogManagerImpl";
with
$EXTRA_JAVA_ARGS="-Djava.util.logging.manager:com.caucho.log.LogManagerImpl";
-lookup=*.sym=appsym;sym
-lookup=*.bod=appbod;bod
-lookup=*.obj=appobj
-lookup=*.$(dllext)=jittemp
-lookup=*.cache=jittemp
!module jit$(jetver)$(profile).cache
jc =p webapps.prj
to create the JET-compiled version of your application.
A single, optimized binary containing your web application code and a JIT cache descriptor will be created in the directory Resin-dir/Excelsior/jittemp.
Now, if you need to deploy the optimized applications to other systems, prepare an installation package containing Resin and your applications. To do that, launch JetPackII and follow the instructions below.
conf lib
contrib libexec
deploy licenses
doc webapps
Resin
httpd.sh
start-httpd.sh
stop-httpd.sh
wrapper.pl
wrapper.pl.in
JetPackII shall prompt you for automatic inclusion of the existing JIT cache (which is used by Resin executable compiled with JET) into the installation package. Click Yes.
Note: The JetPackII tool can only detect the JET runtime components that are directly used by Resin and precompiled Web applications. If your application uses some Java 2 platform API, but the classes accessing that API were not loaded during JIT cache accumulation, there is a chance that the respective JET runtime shared libraries will not be included in the deployment package.
To prevent such situation, select "Include JET runtime in whole".
After the packaging completes, you can tar/gzip the resulting image and test it on a machine not having J2SE/Resin installed.
|
Home | Company | Products | Services | Resources | Blog | Contact Store | Downloads | Support | Forum | Blog | Sitemap © 1999-2011 Excelsior LLC. All Rights Reserved. |