<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web2.0 Tutorials &#187; Tomcat</title>
	<atom:link href="http://www.zulutown.com/blog/tag/tomcat/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zulutown.com/blog</link>
	<description>All the Guides You Need to Become a Web2.0 Expert</description>
	<lastBuildDate>Mon, 13 Jul 2009 07:50:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating Tomcat6 Windows Services</title>
		<link>http://www.zulutown.com/blog/2009/03/12/creating-tomcat6-windows-services/</link>
		<comments>http://www.zulutown.com/blog/2009/03/12/creating-tomcat6-windows-services/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 21:10:49 +0000</pubDate>
		<dc:creator>Zulutown Webmaster</dc:creator>
				<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[catalina_home]]></category>
		<category><![CDATA[java_home]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[service.bat]]></category>
		<category><![CDATA[tomcat6]]></category>
		<category><![CDATA[tomcat_home]]></category>
		<category><![CDATA[webapps]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[windows service]]></category>

		<guid isPermaLink="false">http://www.zulutown.com/blog/?p=101</guid>
		<description><![CDATA[Running the default Windows Tomcat installer a Tomcat server named Tomcat6 will be created on the Windows machine.
In the case the tomcat zipped installation file has been used, or if during the installation wizard the option for creating a Windows service hasn&#8217;t been checked, or finally, if it is required to have multiple Tomcat services [...]]]></description>
			<content:encoded><![CDATA[<p>Running the default Windows Tomcat installer a Tomcat server named <em>Tomcat6</em> will be created on the Windows machine.</p>
<p>In the case the tomcat zipped installation file has been used, or if during the installation wizard the option for creating a Windows service hasn&#8217;t been checked, or finally, if it is required to have <em>multiple Tomcat services</em> running on the server, the Tomcat features to create new services should be used.</p>
<p>Obviously it&#8217;s required to have Java installed, in this case, it&#8217;s used the JDK.</p>
<p>The following batch script will install a tomcat service named <em>YourTomcat</em> related to a <code>CATALINA_BASE</code> located in <code>c:\YourDir\YourTomcat</code>.</p>
<pre>set JAVA_HOME="c:\Program Files\Java\jdk1.6.0_12\"
set TOMCAT_HOME="c:\Program Files\Apache Software Foundation\Tomcat 6.0"
set CATALINA_BASE="c:\YourDir\YourTomcat"
call service.bat install YourTomcat</pre>
<p><code>JAVA_HOME</code> and  <code>TOMCAT_HOME</code> are obviously the places where Tomcat and Java are installed.</p>
<p>What&#8217;s the <code>CATALINA_BASE</code>? In few words, from the same Tomcat installation (located in this example in <code>c:\Program Files\Apache Software Foundation\Tomcat 6.0</code>, the <code>TOMCAT_HOME</code>) it&#8217;s possible to run more than one server instances. Each Tomcat instance has its own deployed web applications, its own logs, its own configuration and so on.</p>
<p>The <code>CATALINA_BASE</code> needs to have those directories structure:</p>
<pre>conf/
logs/
temp/
webapps/
work/</pre>
<p>In <code>conf/</code> it&#8217;s possible to copy the content of the <code>conf/</code> directory of the Tomcat installation, and obviously these files have to be customized, depending on what is required for that specific Tomcat service, i.e. the HTTP, AJP and SHUTDOWN ports, and so on.</p>
<p>In <code>logs/</code> each tomcat will write its custom <em>Catalina</em> logs or the web application specific logs (i.e. handled by Log4J).</p>
<p>In <code>temp/</code> Tomcat will obviously place temporary files.</p>
<p>In <code>webapps/</code> the web applications <code>.war</code> will be placed (and exploded).</p>
<p>in <code>work/</code> the compiled <code>.jsp</code> will be placed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zulutown.com/blog/2009/03/12/creating-tomcat6-windows-services/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Java EE Load Balancing with Tomcat and Apache</title>
		<link>http://www.zulutown.com/blog/2009/02/16/java-ee-load-balancing-with-tomcat-and-apache/</link>
		<comments>http://www.zulutown.com/blog/2009/02/16/java-ee-load-balancing-with-tomcat-and-apache/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 21:16:45 +0000</pubDate>
		<dc:creator>Zulutown Webmaster</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Java EE]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[ajp]]></category>
		<category><![CDATA[balancermember]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[connector]]></category>
		<category><![CDATA[jsessionid]]></category>
		<category><![CDATA[jvmroute]]></category>
		<category><![CDATA[load balancer]]></category>
		<category><![CDATA[load balancing]]></category>
		<category><![CDATA[mod_proxy]]></category>
		<category><![CDATA[mod_proxy_ajp]]></category>
		<category><![CDATA[mod_proxy_balancer]]></category>
		<category><![CDATA[stickysession]]></category>

		<guid isPermaLink="false">http://www.zulutown.com/blog/?p=78</guid>
		<description><![CDATA[This tutorial explains how to configure an Apache HTTPD server to map a specific path on a series of load-balanced Apache Tomcat.
The first step is to define the Virtual Host in the Apache configuration files.
In this case the root directory (on file system) of the site is located in /path/to/your/site/, the name of the site [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial explains how to configure an <em>Apache HTTPD</em> server to map a specific path on a series of load-balanced <em>Apache Tomcat</em>.<br />
The first step is to define the <em>Virtual Host</em> in the Apache configuration files.<br />
In this case the root directory (on file system) of the site is located in <code>/path/to/your/site/</code>, the name of the site is <code>www.yoursite.com</code> and the path where the Tomcat servers may be reached is <code>/javaee</code>.</p>
<p>In few words, an URL like <code>http://www.yoursite.com/home.html</code> is mapped on the file <code>/path/to/your/site/home.html</code>.</p>
<p>An URL like <code>http://www.yoursite.com/javaee/hello.jsp</code> is mapped to the <code>hello.jsp</code> file contained in <code>javaee.war</code> application deployed on all the Tomcat servers defined in the <em>load balanced cluster</em>.</p>
<p>The configuration of the Apache virtual host:</p>
<pre>&lt;VirtualHost *&gt;
	ServerAdmin webmaster@localhost
	ServerName www.yoursite.com
	DocumentRoot /path/to/your/site/
	&lt;Directory /path/to/your/site/&gt;
		Options MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	&lt;/Directory&gt;

	ErrorLog /var/log/yoursite-error.log

	LogLevel warn

	CustomLog /var/log/yoursite-access.log combined

    &lt;Proxy balancer://tomcatservers&gt;
	BalancerMember ajp://tomcatserver.yoursite.com:8009 route=tomcatA retry=60
        BalancerMember ajp://tomcatserver.yoursite.com:8010 route=tomcatB retry=60
	BalancerMember ajp://tomcatserver.yoursite.com:8011 route=tomcatC retry=60
    &lt;/Proxy&gt;

    &lt;Location /javaee&gt;
	Allow From All
        ProxyPass balancer://tomcatservers/javaee stickysession=JSESSIONID nofailover=off
    &lt;/Location&gt;

&lt;/VirtualHost&gt;</pre>
<p>The most important settings are <code>Proxy</code> and <code>Location</code>.<br />
In <code>Proxy</code> it&#8217;s defined a <em>load balancer</em> made with 3 tomcat servers and an URL is assigned to the balancer, in this case <code>balancer://tomcatservers</code>.</p>
<p>The balancer has three members, everyone with its own URL based on the <code>ajp</code> protocol. In this case Apache will connect to the Tomcat servers on their <em>AJP connectors</em> (an alternative would be to use their <em>HTTP connectors</em>).</p>
<p>The Tomcat servers run on the <code>tomcatserver.yoursite.com</code> hostname and each of them opens its own AJP connector on a different port: the first on <code>8009</code> (the default one), the second on <code>8010</code>, the third on <code>8011</code> (obviously if they run on the same hostname/IP they must bind to different ports).</p>
<p>Each Tomcat is identified by a route name: <code>tomcatA</code>, <code>tomcatB</code> and <code>tomcatC</code>. The importance of it will be explained later.</p>
<p>In the <code>Location</code> section, a specific path <code>/javaee</code> of the virtual host is mapped on the previously defined balancer <code>balancer://tomcatservers/javaee</code>. So when someone asks for <code>http://www.yoursite.com/javaee/hello.jsp</code> the virtual host will request that JSP to a randomly chosen Tomcat in the balancer members.</p>
<p>What&#8217;s the <code>stickysession</code> attribute? It&#8217;s a very useful configuration parameter used in conjunction with the <code>route</code> attributes, defined before.</p>
<p>As probably every Java EE (or Web) developer should know, while browsing on a server, it keeps trace of some data about the browsing session in a server-side <em>HttpSession</em> object. For example an ecommerce web application needs to store somewhere the information about the shopping cart of non registered users.</p>
<p>How the server can associate the remote session data with the specific navigation session? This is done through a cookie (or via a GET parameter in the URL) that gives to the server the <em>session ID</em> value.</p>
<p>In Java EE applications, the cookie name to identify the sessions is <code>JSESSIONID</code>.</p>
<p>This is closely related to the management of the load balancing between the Tomcat servers.</p>
<p>If Apache picked randomly one of the Tomcat to handle a single request and if the next request from the same user/browser was forwarded by the balancer <em>to another Tomcat</em> in that battery, things wouldn&#8217;t work correctly.</p>
<p>Each Tomcat doesn&#8217;t know anything of the existence of other Tomcat in that balancer configuration and especially a single Tomcat server cannot access the information of <em>http sessions</em> handled by another Tomcat.</p>
<p>In few words, when a Tomcat is chosen to handle the first request from a user/browser, it&#8217;s absolutely required that, to keep valid session data, the same Tomcat must be used to handle the following requests coming from that browser/user.</p>
<p>If not, on each request, the session data would be lost and simple tasks, such as building a shopping cart would result impossible.</p>
<p>So, it&#8217;s required to tell to Apache what is the session cookie name: <code>JSESSIONID</code> and which is the identifier of the routes to each single tomcat Server: <code>tomcatA</code>, <code>tomcatB</code>, <code>tomcatC</code>.</p>
<p>In this way, Apache will append to the end of the cookie value the information about the route to the specific Tomcat.</p>
<div id="attachment_83" class="wp-caption aligncenter" style="width: 490px"><img class="size-large wp-image-83" title="Java EE Tomcat Load Balancing" src="http://www.zulutown.com/blog/wp-content/uploads/2009/02/javaee-tomcat-load-balancing-480x320.png" alt="Java EE Tomcat Load Balancing" width="480" height="320" /><p class="wp-caption-text">Java EE Tomcat Load Balancing</p></div>
<p>Finally, the last thing to set-up Apache, is obviously to add to it the  modules required by the previous configuration:</p>
<ul>
<li>proxy</li>
<li>proxy_balancer</li>
<li>proxy_ajp</li>
</ul>
<p>About Tomcat configuration, there are just few changes to apply to the default configuration, in the <code>Engine</code> section it&#8217;s required to add the <code>jvmRoute</code> attribute.</p>
<pre>&lt;Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcatA"&gt;</pre>
<p>This is related to the <code>route</code> parameter defined in the Apache load balancer. So, <code>tomcatA</code> should be set in the configuration of the first Tomcat server, <code>tomcatB</code> in the second and <code>tomcatC</code> in the third one.</p>
<p>Then, the port where <em>AJP connector</em> listens, has to be set accordingly to the apache configuration, so <code>8009</code>, <code>8010</code>, <code>8011</code> respectively on the first, second and third Tomcat.</p>
<p>The following is the the configuration of the <em>AJP connector</em>:</p>
<pre>&lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /&gt;</pre>
<p>It&#8217;s not directly related to the setup of the load-balancer, but since they run on the same host, each Tomcat should have its own set of ports.</p>
<p>To prevent any conflict you should change the following settings on the second and third servers: <code>Server port="8005"</code> and <code>Connector port="8080"</code>.</p>
<p>I hope this tutorial has given a complete overview about every step required to setup <em>Apache</em> and <em>Tomcat</em> to create a simple load-balanced cluster.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zulutown.com/blog/2009/02/16/java-ee-load-balancing-with-tomcat-and-apache/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Setup Tomcat6 on Eclipse</title>
		<link>http://www.zulutown.com/blog/2009/01/18/setup-tomcat6-on-eclipse/</link>
		<comments>http://www.zulutown.com/blog/2009/01/18/setup-tomcat6-on-eclipse/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 23:10:07 +0000</pubDate>
		<dc:creator>Zulutown Webmaster</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[ganymede]]></category>
		<category><![CDATA[tomcat6]]></category>

		<guid isPermaLink="false">http://www.zulutown.com/blog/?p=5</guid>
		<description><![CDATA[Download Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/ and tomcat6 from http://tomcat.apache.org/download-60.cgi
Extract both of them where you prefer. I extracted Eclipse in /opt/eclipse and Tomcat in /opt/tomcat6), then run Eclipse.
When you&#8217;ll run eclipse it asks you about creating a new workspace (that will be used to store all of your projects), so create a [...]]]></description>
			<content:encoded><![CDATA[<p>Download Eclipse IDE for Java EE Developers from <a href="http://www.eclipse.org/downloads/">http://www.eclipse.org/downloads/</a> and tomcat6 from <a href="http://tomcat.apache.org/download-60.cgi">http://tomcat.apache.org/download-60.cgi</a></p>
<p>Extract both of them where you prefer. I extracted Eclipse in /opt/eclipse and Tomcat in /opt/tomcat6), then run Eclipse.</p>
<p>When you&#8217;ll run eclipse it asks you about creating a new workspace (that will be used to store all of your projects), so create a <em>workspace</em>, usually somewhere in your user home directory.</p>
<p>When Eclipse is up and running, choose <em>preferences</em> from the <em>window</em> menu. Choose from the bar on the left: Server, Runtime Environments.</p>
<div id="attachment_6" class="wp-caption aligncenter" style="width: 247px"><img class="size-medium wp-image-6" title="Preferences" src="http://www.zulutown.com/blog/wp-content/uploads/2009/01/screenshot-preferences-237x300.png" alt="Preferences window in Eclipse" width="237" height="300" /><p class="wp-caption-text">Preferences</p></div>
<p>Click the button <em>Add</em>, choose <em>Apache Tomcat 6</em>.</p>
<div id="attachment_7" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-7" title="New Server Runtime Environment" src="http://www.zulutown.com/blog/wp-content/uploads/2009/01/screenshot-new-server-runtime-environment-300x275.png" alt="New Server Runtime Environment" width="300" height="275" /><p class="wp-caption-text">New Server Runtime Environment</p></div>
<p>In the next page, <em>browse</em> on your disk and choose the directory where you previously extracted Tomcat. In my case it&#8217;s /opt/tomcat6. Finally click Finish.</p>
<div id="attachment_9" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-9" title="New Server Runtime Environment - Server Path" src="http://www.zulutown.com/blog/wp-content/uploads/2009/01/screenshot-new-server-runtime-environment-1-300x275.png" alt="New Server Runtime Environment - Server Path" width="300" height="275" /><p class="wp-caption-text">New Server Runtime Environment - Server Path</p></div>
<p>Well, until now we have just told to our workspace where Tomcat &#8220;installation&#8221; is located on our disk.</p>
<p>But, if we wish to run Java Web Applications within Eclipse, we should setup a Server and eventually assign to it a specific configuration.<br />
Go in the <em>Servers</em> view, right click and choose New, then Server.</p>
<p>Select &#8220;Tomcat v6.0 Server&#8221; as server type (or probably it will be automatically pre-selected), then, in the <em>Server Runtime environment</em> select box you&#8217;ll have to choose &#8220;Apache Tomcat v6.0&#8243; (that&#8217;s probably the only available option.</p>
<div id="attachment_39" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-39" title="New Tomcat Server in Eclipse" src="http://www.zulutown.com/blog/wp-content/uploads/2009/01/eclipse-new-tomcat-server-300x290.png" alt="New Tomcat Server in Eclipse" width="300" height="290" /><p class="wp-caption-text">New Tomcat Server in Eclipse</p></div>
<p>Click on Next, Eclipse will prompt you to eventually add (or remove) web projects from this Server, in this case, if your workspace is empty you&#8217;ll have not any project to add. So, click <em>Finish</em>.</p>
<div id="attachment_40" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-40" title="Add remove Eclipse projects from Tomcat" src="http://www.zulutown.com/blog/wp-content/uploads/2009/01/eclipse-add-remove-projects-from-tomcat-300x290.png" alt="eclipse-add-remove-projects-from-tomcat" width="300" height="290" /><p class="wp-caption-text">Add remove Eclipse projects from Tomcat</p></div>
<p>In the <em>Servers</em> panel, you will see the Tomcat you just added, and in the <em>Project Explorer</em> view, a new Server configuration will  magical appear.</p>
<p>So you can edit the configuration file <code>server.xml</code> as you prefer, change AJP or HTTP connector ports and so on, start/stop/debug the server and obviously add and remove projects from it.</p>
<div id="attachment_41" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-41" title="Editing Tomcat configuration in Eclipse" src="http://www.zulutown.com/blog/wp-content/uploads/2009/01/tomcat-configuration-300x177.png" alt="Editing Tomcat configuration in Eclipse" width="300" height="177" /><p class="wp-caption-text">Editing Tomcat configuration in Eclipse</p></div>
<p>It is also possible to add other server &#8220;instances&#8221;, just right click again in the &#8220;Servers&#8221; view, and follow the procedure described before.</p>
<p>In this way, you will just a single &#8220;Tomcat&#8221; binaries location (that you defined in the first step of this tutorial), but you&#8217;ll have the chance to add many instances of that server, each of them with its specific configuration (imagine the <code>/conf</code> directory of Tomcat) and its specific web application (imagine the <code>/webapps</code> directory).</p>
<div id="attachment_42" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-42" title="Multiple Tomcat Instances in Eclipse" src="http://www.zulutown.com/blog/wp-content/uploads/2009/01/eclipse-multiple-tomcat-instances-300x291.png" alt="Multiple Tomcat Instances in Eclipse" width="300" height="291" /><p class="wp-caption-text">Multiple Tomcat Instances in Eclipse</p></div>
<p>For the more expert ones, it is similar to have more instances on the same tomcat binaries defined on different <code>CATALINA_BASE</code> paths.</p>
<p>I hope this tutorial has been useful, please post any question or comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zulutown.com/blog/2009/01/18/setup-tomcat6-on-eclipse/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
