|
|||||
Previous section: JBoss Server Configurations Adding our Tomcat ServiceWe are going to try building a minimal JBoss configuration that holds nothing but the Tomcat server. You might wonder why we don't simply get a recent copy of Tomcat, unpack it, and use it "stand-alone." The thing is, there are a number of JBoss services that can be made available to Tomcat, thus enhancing it. These include some transaction services, security, pooled datasources. Eventually you might want to add full Enterprise JavaBeans. This could be done by adding—piece by piece—JBoss components. A quick warning: although I provide these instructions as though it were an intuitive process to me, I've got to confess I'm pretty new to this stuff myself. There was a lot of trial-and-error to get an idea of which components constitute the Tomcat "service" and what dependencies (jar libraries, other services, etc.) we have to take into consideration. Nevertheless, I think you'll agree the steps I outline here wont seem overly complex. We will begin this mini-tutorial by assuming that you already created the new "custom" configuration as outlined in the last section. Step 1: Copy "Tomcat" Service to the Custom ConfigurationIt's convenient to use the default or all server configurations
as templates to grab the components we want to build into our new configuration.
In the default configuration's deploy directory you can find
the Tomcat service. It is a directory named cp -R server/default/deploy/jbossweb-tomcat50.sar server/custom/deploy/ Notice the funny directory name Step 2: Modify Tomcat's ConfigurationThe Tomcat service that we "borrowed" from the JBoss default configuration is set up to make use of some transaction and security services that are also found in default. Since we have pared our new configuration down to the bare minimums, the transaction and security services don't exist! Thus we will need to make a slight modification to Tomcat's configuration. Go to the jbossweb-tomcat50.sar/META-INF directory and locate the jboss-service.xml file. We will have to comment out two small sections. First locate the section that looks like this: <!-- A mapping to the server security manager service which must be operation compatible with type org.jboss.security.plugins.JaasSecurityManagerServiceMBean. This is only needed if web applications are allowed to flush the security manager authentication cache when the web sessions invalidate. --> <depends optional-attribute-name="SecurityManagerService" proxy-type="attribute">jboss.security:service=JaasSecurityManager </depends> We will just want to move the end of the xml-comment field so that it also comments out the <depends> tag, so we'll have: <!-- A mapping to the server security manager service which must be operation compatible with type org.jboss.security.plugins.JaasSecurityManagerServiceMBean. This is only needed if web applications are allowed to flush the security manager authentication cache when the web sessions invalidate. <depends optional-attribute-name="SecurityManagerService" proxy-type="attribute">jboss.security:service=JaasSecurityManager </depends> --> Second we look for the line: <depends>jboss:service=TransactionManager</depends> And we'll comment it out as well: <!-- <depends>jboss:service=TransactionManager</depends> --> Step 3: Copy over some needed librariesThis part was a tremendous exercise of trial and error on my behalf.
(Okay, it probably only took 30 minutes.) You will need to copy over
some JAR files from javax.servlet.jar javax.servlet.jsp.jar jbosssx.jar jboss-j2ee.jar jboss.jar Step 4: Try it out!In order to try out Tomcat, we need an appropriate Web application.
I have a small, humble HelloWorld application that you can download.
The file's name is SampleWeb.war and you
will want to place it in the server/custom/deploy directory, right next
to INFO [Embedded] Catalina naming disabled INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8080 INFO [Catalina] Initialization processed in 1037 ms INFO [StandardService] Starting service jboss.web INFO [StandardEngine] Starting Servlet Engine: Apache Tomcat/5.0.28 INFO [StandardHost] XML validation disabled INFO [Catalina] Server startup in 107 ms INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=file:/Library/JBoss/4.0.0 /server/custom/deploy/jbossweb-tomcat50.sar/ROOT.war/ INFO [WebappLoader] Dual registration of jndi stream handler: factory already defined INFO [TomcatDeployer] deploy, ctxPath=/SampleWeb, warUrl=file:/Library /JBoss/4.0.0/server/custom/tmp/deploy/tmp18496SampleWeb-exp.war/ INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080 INFO [ChannelSocket] JK2: ajp13 listening on /0.0.0.0:8009 INFO [JkMain] Jk running ID=0 time=1/77 config=null Now, just to test the application, try browsing to http://localhost:8080/SampleWeb/servlet/HelloWorld and you should see a (humble) Hello World program running. ConclusionSo what have we learned? Well, first we learned that we could add the
Tomcat server by dropping one SAR archive into the In the next exercise we will try to do basically the same thing, but with JBoss's JMS messaging service. Next section: Adding our JMS Service |
|||||
Written material copyright © 2004 by Murray Todd Williams Page last modified 10/29/2004 20:19 |