So for some bizarre reason I decided to slap Tomcat on my Windows XP machine so that I could brush up my rather rusty Java skills with some web programming. Having recently had a remarkably pleasant install experience with MySQL I had high hopes for Tomcat.
So first I needed to work out what binaries I need. Please PLEASE Java world... realise that not everyone who wants to install your software is comfortable compiling stuff first and just maybe they'd like an easy link to the binaries! Yes I know they are there but it's not exactly obvious. Anyway - I got my ZIP package and ran my setup. It was like stepping back five years in time with a rather archaic install - but it seemed to do the job and after prompting me for the usual kind of things it was installed. Job done.
So I start it up and after it's entirely non-standard and rather obtuse status message it says 'Started'. Excellent. I hit the sample page. Server unavailable. No, I think... I said I started you.... restart the service. Same result. At this point I start to think maybe I've missed the point. Maybe I need Apache as well? Maybe I've utterly misunderstood what Tomcat is? It's a while since I last used it. A bit of googling later and I'm pretty sure I was right first time. This page should have worked.
Time to go digging. There's nothing in the Tomcat monitor to tell me anything is amiss. It seems to be hunky-dory. Well - I guess it seems so. There's no status messages or anything apart from 'started'. But it ain't working. So I start to refresh myself on the Tomcat directory structure and logs. There's a whole bunch of XML files containing various settings that I tweak and fiddle with - restarting Tomcat each time. I make progress, in a sense - Tomcat stops working altogether.
So I go back to all the originally installed files and start digging in logs. And then I find the problem in the catalina log. Not exactly the first thing that would spring to mind unless you knew what catalina meant and why, but there you go:
SEVERE: Error initializing endpoint
java.net.BindException: Address already in use: JVM_Bind:8080
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:501)
at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:177)
at org.apache.catalina.connector.Connector.initialize(Connector.java:1059)
at org.apache.catalina.core.StandardService.initialize(StandardService.java:677)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:792)
at org.apache.catalina.startup.Catalina.load(Catalina.java:518)
at org.apache.catalina.startup.Catalina.load(Catalina.java:538)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
14-Aug-2007 09:17:30 org.apache.catalina.startup.Catalina load
I guess what this is trying to tell me is that port 8080 is already in use. A little netstat and process explorer later and I find that Sky AnyTime is using port 8080. In case you're wondering what that is - it's a PC-based service from my Satellite TV company that lets you download movies and stuff via a torrent-alike thing. Makes PERFECT sense for it to default to port 8080, which is commonly used for web servers. Makes even more perfect sense that it isn't configurable.
Oh well - at least Tomcat is, if you are happy to start cutting XML files. So a quick edit later and a couple of restarts due to a missed quote mark on one of my attributes, and Tomcat is running happily on port 9090. I hope. Of course, the shortcuts on the Start Menu don't work any more and aren't configurable, so I delete them all and create new ones and test my lovely new Tomcat.
Which now works pefectly :) I grab a J2EE 'pre-configured' Eclipse and cut a quick hello world test. Yep - all is fine. Now to get down to some serious geekerism with Java, but I'm a little worried that the pain I felt just figuring out Tomcat and it's foibles is a taste of things to come...