User: vlada Date: 01/04/02 15:46:01 Modified: src/docs howtotomcat.xml Log: updating tomcat integration Revision Changes Path 1.3 +358 -232 manual/src/docs/howtotomcat.xml Index: howtotomcat.xml =================================================================== RCS file: /cvsroot/jboss/manual/src/docs/howtotomcat.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- howtotomcat.xml 2001/03/21 08:30:20 1.2 +++ howtotomcat.xml 2001/04/02 22:46:01 1.3 @@ -1,239 +1,365 @@ <?xml version = "1.0" encoding = "UTF-8"?> -<section> - <title>Running Tomcat with JBoss</title> - <section> - <title>Goal</title> - - <para> As part of project Game Over, the JBoss organization wants to deliver a complete J2EE based product to the market. The JBoss organization decided to integrate the Tomcat - engine stack with a running version of JBoss in a single VM. Now you can serve all your servlet and JSP needs with 2 simple downloads and a couple of configuration files. - Check out the Tomcat homepage for information related to Tomcat. </para> - <para> The goal of this page is to explain how to make JBoss automatically start Tomcat, so that it runs in the same VM.</para> - - </section> - <section> - <title>Benefits</title> - <para> One benefit of running Tomcat inside the same VM as JBoss is to have an easier to manage application server. The main goal, however, is greater performance. By eliminating - unnecessary network calls and keeping all the invocations inside one VM the performance is significantly enhanced.</para> - - <para> If you have Servlets/JSPs which access some EJBs, you'll get dramatically improved performance because the calls will be intra-VM (no network access).</para> - <para> WARNING - THIS IS STILL A BETA VERSION. </para> - - </section> - - <section> - <title>Requirements</title> - <para> - JBoss 2.0. BETA-PROD 03 - Tomcat Version 3.2b4. You can get the latest release of tomcat from the jakarta website.</para> - - <para> NOTE: This has been tested with tomcat up to 3.2b6, and should work with the forthcoming final 3.2 version. However it won't run on tomcat 3.1, and tomcat 3.3 is not - suppported yet. </para> - - - </section> - <section> - <title>How-to setup jboss for tomcat</title> - <para> - - <itemizedlist> - - <listitem> - <para>Setup environment variables.In whatever batch or shell script you use to launch JBoss and Tomcat, add entries for the following environment variables - <table> - <title>Enviromental variables</title> - <tgroup cols = "2"> - <thead> - <row> - <entry>Variable</entry> - <entry>Value</entry> - </row> - </thead> - <tbody> - <row> - <entry>TOMCAT_HOME</entry> - <entry>The base directory of Tomcat's binaries. With the binary distribution, this would be jakarta-tomcat under your installation root</entry> - </row> - <row> - <entry>JAVA_HOME</entry> - <entry>The base directory of your JDK 1.2.2 or 1.3 installation</entry> - </row> - <row> - <entry>CLASSPATH</entry> - <entry>This should not include anything (unless you really know what you're doing!). Both Tomcat and JBoss have startup scripts that load the necessary - JARs onto the classpath.</entry> - </row> - </tbody> - </tgroup> - </table> - - </para> - </listitem> - - - <listitem> - <para>Edit jboss.conf. It is located in the conf directory under the base of your JBoss binary distribution, or the dist/conf directory - if you built from the JBoss source. There are some commented-out lines near the end of the file that deal with Tomcat: - - <programlisting><![CDATA[ - <!-- - -- Uncomment this to add "Integrated Stack (fast) Tomcat support". - -- This service allows you to integrate the stack of Tomcat and jboss. - -- Invocations are not going through network but pass native - -- pointers resulting in dramatic speed increases. - -- This service allows the J2EE deployer to add and remove Tomcat contexts dynamically - -- through JMX for you and in effect deploy EARs. Note that tomcat's - -- server.xml file will be partially processed for context support: you can - -- also use JMX to add contexts. - -- Use the J2EE deployer to deploy full EARs on this stack - -- Be sure to set your 'TOMCAT_HOME' environment variable before starting JBoss. - -- - -- The ARG tags are the config file and the port to run tomcat on. Note: only the url - -- contexts will be parsed, (path and docBase attruibutes only) all other - -- configurations are not yet supported. - -- - -- MLET CODE = "org.jboss.tomcat.EmbeddedTomcatService" ARCHIVE="jboss.jar" CODEBASE="../../lib/ext/"> - -- ARG TYPE="java.lang.String" VALUE="full path to tomcat config file"> - -- ARG TYPE="int" VALUE=8080> - -- /MLET> - ]]></programlisting> - </para> - - <para><![CDATA[ - You need to uncomment these lines so they read as follows (note you must add the < signs at the beginning of the - three relevant lines and the file path must always begin with a '/'): - ]]><programlisting><![CDATA[ - <MLET CODE = "org.jboss.tomcat.EmbeddedTomcatService" ARCHIVE="jboss.jar" CODEBASE="../lib/ext/"> - <ARG TYPE="java.lang.String" VALUE="/yyy/server.xml"> - <ARG TYPE="int" VALUE=8080> + <section> + <title>Tomcat and JBoss - A Full J2EE Stack</title> + <mediaobject> + <imageobject> + <imagedata fileref = "images/tomcat_3.gif"/> + </imageobject> + </mediaobject> + <para> + The JBoss organization wants to deliver a complete J2EE based product to the market. + The JBoss organization decided to integrate the Tomcat engine stack with a running + version of JBoss in a single VM. Now you can serve all your servlet and JSP needs with + 2 simple downloads and a couple of configuration files. Check out the Tomcat homepage + for information related to Tomcat. </para> + + <para> + The goal of this page is to explain how to make JBoss automatically start Tomcat, so that it runs in + the same VM.</para> + + <para> + We now run <emphasis>optimized stacks</emphasis> the JSP/Servlet engine talks natively with the EJB engine resulting in + dramatic speed increases. Without the optimization the invocation is through the network layer. With + the optimized layers the invocation is <emphasis>native, inVM,</emphasis> within the same stack of APIs</para> + <para> + Features + <itemizedlist> + <listitem><para> + Parsing of server.xml for full Tomcat configuration support + </para></listitem> + <listitem><para> + Support for Tomcat 3.2 and up + </para></listitem> + <listitem><para> + Coming support for Catalina + </para></listitem> + <listitem><para> + Full j2ee integration in JMX + </para></listitem> + <listitem><para> + single startup/shutdown script + </para></listitem> + <listitem><para> + Separated stacks inVM + </para></listitem> + <listitem><para> + Integrated stacks inVM + </para></listitem> + <listitem><para> + J2EE deployer for JBoss/Tomcat + </para></listitem> + <listitem><para> + Full EAR support + </para></listitem> + <listitem><para> + JBoss Auto-Deploy for EAR + </para></listitem> + <listitem><para> + JNDI shared visibility + </para></listitem> + <listitem><para> + Integrated Security Model + </para></listitem> + </itemizedlist> +</para> + + <para> + Mailing lists + </para> + <para> + Refer to Tomcat's <ulink url="http://jakarta.apache.org/tomcat/index.html">homepage</ulink> for questions specific to + Tomcat deployment. </para> + + <para> + Questions about the J2EE deployer and the integration should be posted to + <ulink url="http://www.jboss.org/business/lists.html">our lists</ulink> (JBoss)</para> + + <para>Distribution and CVS</para> + + <para> + JBoss Tomcat is shipped as part of the <ulink url="http://www.jboss.org/business/binary.html">standard JBoss/Server</ulink> + package. However, the current distribution is based on an earlier version of EmbeddedTomcat that does not parse Tomcat's + server.xml. If you don't need server.xml parsed (ie, you're not trying to integrate with Apache), + then the current version may be the easiest route for you. </para> + + + <para> + The Pre-2.1 CVS source contains a new version of EmbeddedTomcat (plus other enhancements) that does + parse Tomcat's server.xml. It is recommended that you use the information provided below. This new + version of EmbeddedTomcat will be rolled in to the official 2.1 release. </para> + + <para> + How-to build and install EmbeddedTomcat</para> + + <para> + You will need + <itemizedlist> + <listitem><para> + <ulink url="http://www.jboss.org/zip_archives">JBoss Pre-2.1 Src</ulink> + </para></listitem> + <listitem><para> + <ulink url="http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.1/bin">Tomcat Version 3.2 </ulink> + </para></listitem> + </itemizedlist> +</para> + + <para> + You can get the latest CVS version of JBoss Pre-2.1 from here. Grab both jboss-cvs.zip and + contrib-cvs.zip to build JBoss and EmbeddedTomcat. </para> + + <para> + You can get the latest release of tomcat from the jakarta website. NOTE: This has been tested with + tomcat 3.2.1 However it won't run on tomcat 3.1, and tomcat 3.3 is not suppported yet.</para> + <para> + <orderedlist> + <listitem><para>Build JBoss from src </para> + <para> + Build JBoss from the CVS sources. This is generally accomplished by changing to the src/build + directory and executing build.sh (or build.bat on NT). The build creates a dist directory under + the src root. This dist directory will be referred to as the JBOSS_HOME for the EmbeddedTomcat + build.</para> + </listitem> + <listitem><para>Build EmbeddedTomcat(optional) </para> + + <para>Build the EmbeddedTomcat service from the contrib CVS sources if you want. This is optional as + the current JBoss cvs src includes a prebuilt version of the tomcat-service.jar. To build the + EmbeddedTomcat service, change to the contrib/tomcat/src/build directory and execute build.sh + (or build.bat on NT). NOTE: You need to define environment values for JBOSS_HOME and + TOMCAT_HOME to fit your environment. JBOSS_HOME needs to point to the dist directory of the + JBoss build step and TOMCAT_HOME is the dist directory of the jakarta-tomcat-3.2.x release. </para> + + <para>Once this build completes, execute build.sh client. This will create a new tomcat-test.ear. </para> + + <para>Once you've built EmbeddedTomcat, copy contrib/tomcat/tomcat-service.jar to + $JBOSS_HOME/lib/ext. Finally, copy contrib/tomcat/tomcat-test.ear to $JBOSS_HOME/deploy. </para> + </listitem> + <listitem><para>Add the tomcat libs to the server classpath </para> + <para>In JBOSS_HOME/conf/default/ edit <link linkend="jboss.conf-file">jboss.conf</link> file to uncomment + the ClassPathExtension mbean for the tomcat lib directory to:</para> + + <figure id="tomcat-classpathextension"> + <title>Adding tomcat classes to classpath</title> + <programlisting><![CDATA[ + <!--Uncomment to add Tomcat classes to classpath --> + <MLET CODE = "org.jboss.util.ClassPathExtension" ARCHIVE="jboss.jar" CODEBASE="../../lib/ext/"> + <ARG TYPE="java.lang.String" VALUE="TOMCAT_HOME/lib/"> + <ARG TYPE="java.lang.String" VALUE="Tomcat"> </MLET> - - ]]></programlisting> - - </para> - </listitem> - - - - - <listitem> - <para>Start JBoss. If you start JBoss now by typing run.sh (or run.bat for Windows) you should see the following Tomcat related output - in your log messages: - - <programlisting> ... - [EmbeddedTomcat] Initializing - [EmbeddedTomcat] Initialized - [EmbeddedTomcat] Starting - [EmbeddedTomcat] Testing if Tomcat is present.... - [EmbeddedTomcat] OK - [EmbeddedTomcat] ContextManager: Adding context Ctx( ) - [EmbeddedTomcat] path="" :jsp: init - [EmbeddedTomcat] PoolTcpConnector: Starting HttpConnectionHandler on 8080 - [EmbeddedTomcat] Started - ... - - </programlisting> - - </para> + ]]> + </programlisting> + </figure> + + <para>where TOMCAT_HOME value must be set to the full path described above in the build of the + EmbeddedTomcat service. Note that there must be a trailing slash(/) in order for the jars in + the lib directory to be added to the classpath. </para> + </listitem> + <listitem><para>Edit <link linkend="jboss.jcml-file">jboss.jcml</link></para> + <para>In JBOSS_HOME/conf/default/ edit the jboss.jcml file to uncomment the EmbeddedTomcatService + mbean. Locate: </para> + + <figure id="embedded-tomcat-service-before"> + <title>EmbeddedTomcat MBean inclusion before</title> + <programlisting><![CDATA[ + <!-- + Uncomment to add embedded tomcat service + <mbean code="org.jboss.tomcat.EmbeddedTomcatService" name="DefaultDomain:service=EmbeddedTomcat" /> + --> + ]]> + </programlisting> + </figure> + + <para>and uncomment the mbean line so it reads as follows: </para> + <figure id="embedded-tomcat-service-after"> + <title>EmbeddedTomcat MBean inclusion after</title> + <programlisting><![CDATA[ + <!-- + Uncomment to add embedded tomcat service + --> + <mbean code="org.jboss.tomcat.EmbeddedTomcatService" name="DefaultDomain:service=EmbeddedTomcat" /> + ]]> + </programlisting> + </figure> + + + + <para>Further down in the <link linkend="jboss.jcml-file">jboss.jcml</link> file, make sure your + J2eeDeployer is set as: </para> + <figure id="j2eedeployer-embeddedtomcat"> + <title>J2eeDeployer setting</title> + <programlisting><![CDATA[ + <mbean code="org.jboss.deployment.J2eeDeployer" name="J2EE:service=J2eeDeployer"> + <attribute name="DeployerName">Default</attribute> + <attribute name="JarDeployerName">:service=ContainerFactory</attribute> + <attribute name="WarDeployerName">:service=EmbeddedTomcat</attribute> + <mbean> + ]]> + </programlisting> + </figure> + + </listitem> + <listitem><para>Edit Tomcat's server.xml </para> + <para> Add the following lines to server.xml in TOMCAT_HOME/conf/ </para> + <figure id="new-tomcat-server.xml"> + <title>Change in server.xml</title> + <programlisting><![CDATA[ + <!-- JBoss, Setup the class loader heirarchy to enable in VM call optimization. + Add after the org.apache.tomcat.context.WorkDirInterceptor ContextInterceptor + --> + <ContextInterceptor className="org.jboss.tomcat.ContextClassLoaderInterceptor" /> + <!-- JBoss, Add the jboss-web.xml parser. Add after the org.jboss.tomcat.ContextClassLoaderInterceptor + ContextInterceptor + --> + <ContextInterceptor className="org.jboss.tomcat.naming.JbossWebXmlReader" /> + <!-- JBoss, Set the request thread classloader. Add before the org.apache.tomcat.request.SessionInterceptor + RequestInterceptor + --> + <RequestInterceptor className="org.apache.tomcat.request.Jdk12Interceptor" /> + <!-- JBoss, Map the current web user to the SecurityAssociation principal. Add + after the org.apache.tomcat.request.SimpleRealm RequestInterceptor + --> + <RequestInterceptor className="org.jboss.tomcat.security.JbossRealm" /> + ]]> + </programlisting> + </figure> + </listitem> + <listitem><para>Adding javac to the server classpath </para> + <para>If you are going to be using JSP files with tomcat, you need to add the JDK lib/tools.jar file + to the classpath to pickup the javac compiler. You can do this by either setting your CLASSPATH + env variable, by editing run.sh/run.bat to add tools.jar to CLASSPATH, or by copying tools.jar + to the TOMCAT_HOME/lib directory. </para> + </listitem> + <listitem><para>Start JBoss</para> + <para>If you start JBoss now by typing run.sh (or run.bat for Windows) you should see the following + Tomcat related output in your log messages: </para> + + <figure id="proper-startup-using-tomcat"> + <title>Embedded Tomcat started properly</title> + <programlisting><![CDATA[ + Using configuration "default" + [Info] Java version: 1.3.0_01,Sun Microsystems Inc. + [Info] Java VM: Java HotSpot(TM) Server VM 1.3.0_01,Sun Microsystems Inc. + [Info] System: Linux 2.2.16-22,i386 + ... + [EmbeddedTomcat] Starting + [EmbeddedTomcat] Starting EmbeddedTomcat.... + 2001-02-20 05:01:23 - ContextManager: Adding context Ctx( /examples ) + 2001-02-20 05:01:23 - ContextManager: Adding context Ctx( /admin ) + [EmbeddedTomcat] Starting tomcat. Check logs/tomcat.log for error messages + 2001-02-20 05:01:23 - ContextManager: Adding context Ctx( ) + 2001-02-20 05:01:23 - ContextManager: Adding context Ctx( /test ) + 2001-02-20 05:01:25 - PoolTcpConnector: Starting HttpConnectionHandler on 8080 + 2001-02-20 05:01:25 - PoolTcpConnector: Starting Ajp12ConnectionHandler on 8007 + [EmbeddedTomcat] OK + [EmbeddedTomcat] Started + ... + [Default] JBoss PRE-2.1 Started in 0m:14s + ]]> + </programlisting> + </figure> + + </listitem> + </orderedlist> + </para> + <para> That's it !! Note that the connection handlers are configured from Tomcat's server.xml file. </para> + + <para>How-to package and deploy an EAR file on JBoss/Tomcat</para> + + <para> + In order to benefit from the classloader integration, you have to deploy your application in an EAR + file as recommended by the J2EE <ulink url="http://java.sun.com/j2ee/download.html#platformspec">specification</ulink>. </para> + + <para> + In case you don't want to read all the J2EE spec, here is a brief summary of what you have to do:</para> - </listitem> - - </itemizedlist> - - </para> - - <para> That's it !! You just have to launch JBoss now and it will start Tomcat and you will have an EJB/JSPs/Servlets server running in one VM... </para> - - </section> - <section> - <title>How-to build web applications for jboss and tomcat</title> - <para> - In order to benefit from the classloader integration, you have to deploy your application in an ear file as recommended by the J2EE specification.</para> - <para> Tomcat's server.xml file will not be processed!</para> - <para> The reason is that we want to share the classloader for your application between tomcat and jboss. Since this classloader must be initialized at - deployment time, your EJBs and your servlets/JSPs must be bundled together for jboss to know who talks to whom! </para> - <para> In case you don't want to read all the J2EE spec, here is a brief summary of what you have to do:</para> - - <orderedlist> - <listitem> - <para>Write your beans and package them in an ejb-jar file. You don't have to do anything special here. - See the manual for details on how to package beans for jboss.</para> - </listitem> - - <listitem> - <para>Write your servlets/JSPs and package them in a war file. Assuming you have a bean deployed under the jndi name "myBean", - the calls to this bean from your servlets will look like that: </para> - <programlisting> - MyBeanHome home = (MyBeanHome)new InitialContext().lookup("myBean"); - MyBean bean = home.create(); - </programlisting> - + <orderedlist> + <listitem><para>Write your beans and package them in an ejb-jar file.</para> + <para>You don't have to do anything special here. See the manual for details + on how to package beans for JBoss.</para> + </listitem> + <listitem><para>Write your servlets/JSPs and package them in a war file.</para> + <para> + Add a Class-Path attribute to your war files MANIFEST.MF file to reference your beans package. + for detailed information on that see: J2eeDeployment Howto.</para> + <para> + Assuming you have a bean deployed under the jndi name "myBean", the calls to this bean from your + servlets will look like that: </para> - <para> Notes: - We don't support lookups in the "java:" namespace from the servlets yet, but work is in progress. - Since jboss takes care of the classloader stuff, you don't have to include much in the WEB-INF/lib directory: you don't any of your beans interfaces, and you - don't need the usual jboss-client.jar, jnp-client.jar... </para> - </listitem> - - - <listitem> - <para>Package your application in an ear file. An ear file is a jar archive which contains:</para> - - <itemizedlist> - <listitem> - <para>Your jar files</para> - </listitem> - - <listitem> - <para>Your war files</para> - </listitem> + <programlisting> + MyBeanHome home = (MyBeanHome)new InitialContext().lookup("myBean"); + MyBean bean = home.create();</programlisting> + + <para> + Notes:</para> + <para> + Since JBoss takes care of the classloader stuff, you don't have to include much in the + WEB-INF/lib directory: you don't need any of your beans interfaces, and you don't need the + old jboss-client.jar, jnp-client.jar... </para> + </listitem> + + <listitem><para>Package your application in an ear file.</para> + <para>An ear file is a jar archive which contains: </para> + <itemizedlist> + <listitem><para>Your jar files + </para></listitem> + <listitem><para>Your war files + </para></listitem> + + <listitem><para>A deployment descriptor for your application.</para> + + <para>This file must be named "application.xml", + and must be located in the META-INF directory in the ear archive. This file tells JBoss + which modules are EJBs, which ones are web modules, and the context paths for the + web-modules. Here is a sample application.xml file: </para> + - <listitem> - <para>A deployment descriptor for your application. This file must be named "application.xml", and must be located in the META-INF - directory in the ear archive. This file tells jboss which modules are EJBs, which ones are web modules, and the context paths for the web-modules. - Here is a sample application.xml file: - - <programlisting><![CDATA[ - <?xml version="1.0" encoding="ISO-8859-1"?> - - <application> - <display-name>My application</display-name> - - <module> - <web> - <web-uri>webmodule.war</web-uri> - <context-root>/servlets</context-root> - </web> - </module> - - <module> - <ejb>beans.jar</ejb> - </module> + <figure id="application.xml-example"> + <title>Example application.xml</title> + <programlisting><![CDATA[ + <?xml version="1.0" encoding="ISO-8859-1"?> + + <application> + <display-name>My application</display-name> + + <module> + <web> + <web-uri>webmodule.war</web-uri> + <context-root>/servlets</context-root> + </web> + </module> + + <module> + <ejb>beans.jar</ejb> + </module> + + </application> + ]]> + </programlisting> + </figure> + + <para>See also the <ulink url="http://java.sun.com/j2ee/dtds/application_1_2.dtd">DTD</ulink> for application.xml on Javasoft's website.</para> + + </listitem> + </itemizedlist> + </listitem> + <listitem><para>Deploy your ear file.</para> + <para>Option 1: Copy your ear file to JBOSS_HOME/deploy (wow!) </para> + + <para> + Option 2: Surf to http://yourhost:8082, and find the J2eeDeployer service. Give it the URL of + your ear file (don't forget the protocol, be it http: or file:), and click on the deploy button.</para> + + </listitem> + <listitem><para>That's it!</para> + <para>The server console should show your application being deployed on Tomcat and JBoss, and your web + module should be available on http://yourhost:8080/servlets (assuming the context-root was + "/servlets"). </para> + + <para>Note: Even though JBoss and Tomcat are cooperating to dynamically deploy your application, + Apache must be configured manually. This means that for your application to be visible through + Apache, you must setup the appropriate JkMount statements in mod_jk.conf. </para> + </listitem> + </orderedlist> - </application> - ]]></programlisting> - - </para> - </listitem> - - </itemizedlist> - - <para> - See also the DTD for application.xml on Javasoft's website. </para> - </listitem> - - - <listitem> - <para>Deploy your ear file. Surf to http://yourhost:8082, and find the J2eeDeployer service. Give it the URL of your ear file - (don't forget the protocol, be it http: or file:), and click on the deploy button.</para> - </listitem> - - <listitem> - <para>That's it! The server console should show your application being deployed on tomcat and jboss, and your web module should be available on - http://yourhost:8080/servlets (assuming the context-root was "/servlets").</para> - </listitem> - </orderedlist> - - <para> For a full example including a servlet and an EJB, see the contrib module </para> - </section> + <para> + For a full example including a servlet and an EJB, see the tomcat-test.ear in the <ulink url="http://www.jboss.org/zip_archives/contrib-cvs.zip">contrib/tomcat module</ulink></para> </section> _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/jboss-development