User: gropi   
  Date: 01/11/18 11:04:41

  Added:       src/obsolete howtotomcat.xml
  Log:
  Moved the Tomcat-Howto to the "obsolete" directory.
  
  Revision  Changes    Path
  1.1                  manual/src/obsolete/howtotomcat.xml
  
  Index: howtotomcat.xml
  ===================================================================
  <?xml version = "1.0" encoding = "UTF-8"?>
   <section id="howtotomcat">
     <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>
   <section>
   <title>Features</title>
         <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>
  </section>
   
   <section> 
   <title>Mailing lists</title>
   <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/lists.jsp";>our lists</ulink> (JBoss)</para>
   </section>
   <section>
   <title>Distribution and CVS</title>
   
   <para>
   JBoss Tomcat is shipped as part of the <ulink 
url="http://www.jboss.org/binary.jsp";>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>
   </section>
   <section>
   <title>How-to build and install EmbeddedTomcat</title>
  
   <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>
         </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>
   </section>
   <section>
   <title>How-to package and deploy an EAR file on JBoss/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 <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>
      
     <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>
        
         <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>
              
             
              <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> 
  
   <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>
  </section>
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to