<?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>byte bohemian &#187; Tomcat</title>
	<atom:link href="http://nicl.net/category/technology/java/j2ee/tomcat/feed/" rel="self" type="application/rss+xml" />
	<link>http://nicl.net</link>
	<description></description>
	<lastBuildDate>Sat, 15 May 2010 20:51:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tomcat 6.x &#8230; doing it the right way!</title>
		<link>http://nicl.net/2008/07/tomcat-6x-doing-it-the-right-way/</link>
		<comments>http://nicl.net/2008/07/tomcat-6x-doing-it-the-right-way/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 14:24:10 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[Webserver]]></category>

		<guid isPermaLink="false">http://nicl.net/2008/07/19/tomcat-6x-doing-it-the-right-way/</guid>
		<description><![CDATA[Some days ago I posted a blog entry about using Glassfish v2 EJBs with the Tomcat. At this moment I thought that I solved the problems, but last week we were setting our testing evironment on a Debian Linux box and the problems reoccured.
At this moment I thought of a glitch in the server setup [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I posted a blog entry about using Glassfish v2 EJBs with the Tomcat. At this moment I thought that I solved the problems, but last week we were setting our testing evironment on a Debian Linux box and the problems reoccured.</p>
<p>At this moment I thought of a glitch in the server setup but some nagging hours later I realized that my so clever solution was a dirty hack. Which works in a Microsoft Windows environment, but refuses to work on in a Linux environment.<br />
Ok,  I have to confess, that I wasn't really happy with my first solution in the end. Renaming JARs to provide the correct order of class loading always leaves a bad taste. But at that moment I was happy, no other solution was in sight and I had absolutly no time.</p>
<p><span id="more-12"></span></p>
<p>Some days ago I posted a blog entry about using Glassfish v2 EJBs with the Tomcat. At this moment I thought that I solved the problems, but last week we were setting our testing evironment on a Debian Linux box and the problems reoccured.</p>
<p>At this moment I thought of a glitch in the server setup but some nagging hours later I realized that my so clever solution was a dirty hack. Which works in a Microsoft Windows environment, but refuses to work on in a Linux environment.<br />
Ok,  I have to confess, that I wasn't really happy with my first solution in the end. Renaming JARs to provide the correct order of class loading always leaves a bad taste. But at that moment I was happy, no other solution was in sight and I had absolutly no time.</p>
<p>Enough with apologies at this moment, we were late setting up the testing environment too and there was work to do. So I decided to take a different approach and tried to find out some more about the classloading of Tomcat 6. One of my primary questions was: "Why did the Tomcat 6 developers removed the different classloading directories?"</p>
<p>The answer suprised me more, than I expected! After using Google for a while, trying to find out more about the differences in classloading between Tomcat 5.5 and Tomcat 6, I stumbled across a small file: The <code>catalina.properties</code>. This file revealed the secrets of the differnces in classloading between these two Tomcat version. The simple and quite beautyful answer is: There aren't any real differences. The distributions have different default settings, but the classloading mechanism is quite the same. At this point I am getting some more cautious than the last time. The two mechanisms are the same, as far I can judge it from my appication developer/deployer point of view <img src='http://nicl.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>So what is this <code>catalina.properties</code> all about? The <code>catalina.properties</code> - as I understand it - controls some major classloading and security issues while bootstrapping the Tomcat web container. It has three (for my problem) relevant entries:</p>
<pre>
common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar
[...]
server.loader=
[...]
shared.loader=
</pre>
<p>These three entries are controlling three classloader in Tomcats classloader hierachy. The server classloader, the common classloader and the shared classloader. The server classloader is resopnsible for loading the libraries of the tomcat server. It is not set in the Tomcat 6 default distribution and will default to the common classloader which will load the server related classes now. The common classloader is responsible for loading classes common to the tomcat installation. Which are in the Tomcat 6 the server classes as well as addiontional classes like the JavaMail API oder some database driver classes (if you are configuring them with JNDI i.e.). The last classloader is the shared classloader which may load classes which may be shared between different web applications. This is the place where the Amis <a href="http://technology.amis.nl/blog/?p=1368">blog entry</a> suggests the glassfish JARs to be placed, but which I hadn't found in the Tomcat 6 distribution.</p>
<p>After I discovered the secrets of the <code>catalina.properties</code> it took me half an hour to create a <code>shared/lib</code> directory in my <code>TOMCAT_BASE</code> and adapting the <code>catalina.properties</code> file. Now I had the proper place for my Glassfish files and it worked nearly instantly. Good to know that you can make the integration of Glassfish EJB and the Tomcat 6 in a proper way and also good to know about this tiny little classloading tricks of the Tomcat 6 <img src='http://nicl.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>As you say in german: "Kaum macht man es richtig, dann geht's!" (If you starting to do it the right way it works)</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2008/07/tomcat-6x-doing-it-the-right-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tomcat, Glassfish and EJB &#8230; what a mess!</title>
		<link>http://nicl.net/2008/06/tomcat-glassfish-and-ejb-what-a-mess/</link>
		<comments>http://nicl.net/2008/06/tomcat-glassfish-and-ejb-what-a-mess/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 20:17:07 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://nicl.net/2008/06/27/tomcat-glassfish-and-ejb-what-a-mess/</guid>
		<description><![CDATA[I was quite busy in the last weeks, we are starting couple of new projects for a long time customer so I had lot's of work to do and very few time for blogging. On the other hand side I have some new topics to blog about, so it was quite a fair deal.
The last [...]]]></description>
			<content:encoded><![CDATA[<p>I was quite busy in the last weeks, we are starting couple of new projects for a long time customer so I had lot's of work to do and very few time for blogging. On the other hand side I have some new topics to blog about, so it was quite a fair deal.</p>
<p>The last days I had some fun trying to access some Glassfish EJB from a Tomcat web container. Some of you will now start to suggest to use only the Glassfish, so that is the whole story: There is a service layer which provides access to services on the different backend systems. This service layer is provided by our customer using the Glassfish J2EE container. Our application is planned to run on a Tomcat 6 web container - which is some kind of work horse in the company.</p>
<p><span id="more-10"></span></p>
<p>I was quite busy in the last weeks, we are starting couple of new projects for a long time customer so I had lot's of work to do and very few time for blogging. On the other hand side I have some new topics to blog about, so it was quite a fair deal.</p>
<p>The last days I had some fun trying to access some Glassfish EJB from a Tomcat web container. Some of you will now start to suggest to use only the Glassfish, so that is the whole story: There is a service layer which provides access to services on the different backend systems. This service layer is provided by our customer using the Glassfish J2EE container. Our application is planned to run on a Tomcat 6 web container - which is some kind of work horse in the company.</p>
<p>I would like to say this is a quit typical setup for EJB usage in the last years (EJB 1.x / EJB 2.x) so I didn't expect any problems. I confess it was quit a time ago I used EJB, but I fooled around with EJB in BEA and JBoss a couple of years ago.</p>
<p>So we started very naive deploying the <code>appserv-rt.jar</code> and the dependencies into <code>WEB-INF/lib</code> directory of our web application automatically with the maven build. It turned out to be a bad idea. The Tomcat kind of started but the web application could not access any JNDI resources.<br />
As a first fix we moved the Glassfish jars to the <code>$TOMCAT_HOME/lib</code> with basically the same result. So where is the glitch?</p>
<p>I decided to take a closer look to the <code>appserv-rt.jar</code> of the glassfish. I first thought this jar contains some kind of client runtime. You may imagine my ... suprise ... when I realized that this jar contains the application server runtime, which is almost the whole application server. At this point I decided to have a break and go home.</p>
<p>Some times the best ideas come, when you are distracted. So this morning under the shower I thougt that I have an idea who the bad guy is. I suspected the <code>jndi.properties</code> in the <code>appserv-rt.jar</code> to confuse the JNDI initialisation of the Tomcat.<br />
The first thing I tried in the office, was to remove the file from the <code>appserv-rt.jar</code> but it didn't work out. So I really stated to wonder. So consulted to web again and found a nice <a href="http://technology.amis.nl/blog/?p=1368">blog entry</a> concerning the topic, the only difference was the Tomcat version (6 vs. 5.5). It proved my theory on one hand but it doesn't work with the Tomcat 6. So I had to compare the two setups and elaborate the key differences.</p>
<p>In the Tomcat 5.5 the Glassfish jar files had to be put into the <code>$TOMCAT_HOME/shared/lib</code> folder. The Tomcat 6 only provides one library folder at <code>$TOMCAT_HOME/lib</code>. A very imporant difference to the classloading behaviuor between the two Tomcat versions. The Tomcat 5.5 classloader hierachy is to load from the tomcat common lib classloader first and use the shared lib classloader "afterwards". In this configuration the classloader which is responsible for loading the Tomcat system classes has a higher priority to the classloader which loads the glassfish classes, so the JNDI startup could be performed by the Tomcat properly.<br />
The Tomcat 6 doesn't seem to have this mechanism an longer, but why are the glassfish classes are preferred? The answer to this question is as simple as it is painflul. The Glassfish libraries are beginning the the letter <code>a</code> (i.e. <code>appserv-rt.jar</code>) the tomcat libraries are starting the the letters <code>c</code> or <code>t</code> so that the glassfish libraries are earlier in the classpath and preffered to the Tomcat libraries.<br />
This insight was the key to solving the problem. I renamed the <code>appserv-rt.jar</code> (and the dependencies) to <code>xappserv-rt.jar</code> and voilá it worked.</p>
<p>Edit: Sometimes later I discovered <a href="http://nicl.net/2008/07/19/tomcat-6x-doing-it-the-right-way/">a better way</a> to combine the Glassfish EJBs and the Tomcat Webcontainer.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2008/06/tomcat-glassfish-and-ejb-what-a-mess/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Still messing around with &#8220;ETag&#8221; and &#8220;Last-Modified&#8221;</title>
		<link>http://nicl.net/2008/05/still-messing-around-with-etag-and-last-modified/</link>
		<comments>http://nicl.net/2008/05/still-messing-around-with-etag-and-last-modified/#comments</comments>
		<pubDate>Thu, 22 May 2008 19:15:50 +0000</pubDate>
		<dc:creator>niclas</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://nicl.net/2008/05/22/still-messing-around-with-etag-and-last-modified/</guid>
		<description><![CDATA[Stating with this whole website performance an ETag topic opened pandoras box. It's a real mess and lame compromises all over the place. But I have to admit that the whole thing is not as easy as I expected it to be.
Anyway ... today I had a nice discussion with a colleague about this topic. [...]]]></description>
			<content:encoded><![CDATA[<p>Stating with this whole website performance an ETag topic opened pandoras box. It's a real mess and lame compromises all over the place. But I have to admit that the whole thing is not as easy as I expected it to be.</p>
<p>Anyway ... today I had a nice discussion with a colleague about this topic. He's a senior front-end developer. This means he is a real pro in HTML, CSS, Java-Script and stuff like this and he's the one who showed me the whole <a href="http://developer.yahoo.com/performance" target="_blank">Yahoo! performance stuff</a>. After this discussion I wanted to check some things out in detail.</p>
<p><span id="more-8"></span></p>
<p>Stating with this whole website performance an ETag topic opened pandoras box. It's a real mess and lame compromises all over the place. But I have to admit that the whole thing is not as easy as I expected it to be.</p>
<p>Anyway ... today I had a nice discussion with a colleague about this topic. He's a senior front-end developer. This means he is a real pro in HTML, CSS, Java-Script and stuff like this and he's the one who showed me the whole <a href="http://developer.yahoo.com/performance" target="_blank">Yahoo! performance stuff</a>. After this discussion I wanted to check some things out in detail.</p>
<p>First I wanted to check if the Apache was sending two different ETags if you have to Apache web servers delivering the content of a website. A simple test with <code>wget</code> verified it:</p>
<pre>
wget --no-dns-cache -S http://www.a-domain.de/flash/ballons_main.swf
--09:14:26--  http://www.a-domain.de/flash/ballons_main.swf
           => `ballons_main.swf'
Resolving www.a-domain.de... 84.xxx.xxx.x17, 84.xxx.xxx.x33
Connecting to www.a-domain.de|84.xxx.xxx.x17|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Date: Thu, 22 May 2008 07:14:26 GMT
  Last-Modified: Tue, 20 May 2008 15:49:24 GMT
  ETag: "1041e6-7b2c8-6c9fc900"
  Accept-Ranges: bytes
  Content-Length: 504520
  Keep-Alive: timeout=15, max=45
  Connection: Keep-Alive
  Content-Type: application/x-shockwave-flash
Length: 504,520 (493K) [application/x-shockwave-flash]
</pre>
<p>When requesting the first web server the ETag "1041e6-7b2c8-6c9fc900" war returned ...</p>
<pre>
wget --no-dns-cache -S http://www.a-domain.de/flash/ballons_main.swf
--09:14:26--  http://www.a-domain.de/flash/ballons_main.swf
           => `ballons_main.swf'
Resolving www.a-domain.de... 84.xxx.xxx.x17, 84.xxx.xxx.x33
Connecting to www.a-domain.de|84.xxx.xxx.x33|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Date: Thu, 22 May 2008 07:14:26 GMT
  Last-Modified: Tue, 20 May 2008 15:49:24 GMT
  ETag: "b824e-7b2c8-6c9fc900"
  Accept-Ranges: bytes
  Content-Length: 504520
  Keep-Alive: timeout=15, max=45
  Connection: Keep-Alive
  Content-Type: application/x-shockwave-flash
Length: 504,520 (493K) [application/x-shockwave-flash]
</pre>
<p>... after requesting the second web server the ETag "b824e-7b2c8-6c9fc900". So if you do not disable the INode usage for the ETag calculation the whole mechanism will not work. But does this really matter. As you can see the DNS caching was disabled for the test. In a real life situation the DNS caching we be activated and my browser will talk only to one web server and the INode issue won't matter at all.<br />
But if we have multiple web server and the internet browser will only talk to one of them, why do I need the ETag? The Last-Modified header will be enough, won't it?</p>
<p>So my conclusion is use either the Last-Modifed header or the ETag header but using both header makes no really sense at all. This should be right in any case for the Apache HTTPD, the Microsoft IIS or any other web server delivering static content. I also recommend using the Last-Modified because the ETag calculation requires more computing time. There is only one scenario I can provide where the ETag will work and the Last-Modifed Header will not. If someone is changing content and does not modify the last modified time stamp. But this should be rather uncommon.</p>
<p>But how is the situation at dynamic content creation? My favorite web framework is Java Servlets and all related technologies (JSP, JSF, Tapestry, and so on) and after that very disappointing chapter with the ETag I decided to take a closer look at the facilities the servlet and JSP APIs are offering. Another sad very sad story at my actual point of view right now. But for tonight it is enough. Later more about it ...</p>
]]></content:encoded>
			<wfw:commentRss>http://nicl.net/2008/05/still-messing-around-with-etag-and-last-modified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
