# tomcat 5.0.27 is giving me hell!

## epall

My gentoo box apparently just upgraded to tomcat 5.0.27 last night and it's completely screwed up my setup. It used to be that tomcat would reside in /opt/tomcat (conf in /etc/tomcat, which was symlinked to from witin /opt/tomcat), my app detail .xml files in /opt/tomcat/conf/Catalina/localhost and most of my apps in /home/eric/workspace and I could start it either with /etc/init.d/tomcat or eclipse. Everything was great. Then I upgraded. Apparently, gentoo tried to migrate everything to /opt/tomcat5 and /etc/tomcat5 but it didn't do a very good job. I got it to start from the init script, although it's log was very crabby (far below). I changed the location of tomcat from in eclipse and tried to start it and got the below response. What is wrong?!

```

Can't load server.xml

Can't load server.xml

Jul 29, 2004 2:44:59 PM org.apache.catalina.startup.Catalina start

INFO: Server startup in 0 ms

java.lang.reflect.InvocationTargetException

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:324)

    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)

    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

Caused by: java.lang.NullPointerException

    at org.apache.catalina.startup.Catalina.await(Catalina.java:619)

    at org.apache.catalina.startup.Catalina.start(Catalina.java:579)

    ... 6 more

```

Excerpts from catalina.out. It was too long to post all of it. I got the same exception for every single webapp, despite the fact that the directories are in fact there.

```

Jul 29, 2004 2:41:56 PM org.apache.catalina.core.StandardContext start

SEVERE: Error in resourceStart()

Jul 29, 2004 2:41:56 PM org.apache.catalina.core.StandardContext start

SEVERE: Error getConfigured

Jul 29, 2004 2:41:56 PM org.apache.catalina.core.StandardContext start

SEVERE: Context startup failed due to previous errors

Jul 29, 2004 2:41:56 PM org.apache.catalina.core.StandardContext start

SEVERE: Exception during cleanup after start failed

LifecycleException:  Container StandardContext[/jdbc] has not been started

        at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4466)

        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)

        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)

        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)

        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)

        at org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer.java:903)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:324)

        at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:252)

        at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:256)

        at org.apache.commons.digester.Rule.end(Rule.java:276)

        at org.apache.commons.digester.Digester.endElement(Digester.java:1058)

        at org.apache.catalina.util.CatalinaDigester.endElement(CatalinaDigester.java:76)

        at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)

        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)

        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

        at org.apache.commons.digester.Digester.parse(Digester.java:1567)

        at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:488)

        at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)

        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:482)

        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)

        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:968)

        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)

        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)

        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)

        at org.apache.catalina.core.StandardService.start(StandardService.java:480)

        at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)

        at org.apache.catalina.startup.Catalina.start(Catalina.java:556)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:324)

        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)

        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

Jul 29, 2004 2:41:56 PM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path  from URL file:/opt/tomcat5/webapps/ROOT

Jul 29, 2004 2:41:56 PM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path /webdav from URL file:/opt/tomcat5/webapps/webdav

Jul 29, 2004 2:41:56 PM org.apache.coyote.http11.Http11Protocol start

INFO: Starting Coyote HTTP/1.1 on http-8080

Jul 29, 2004 2:41:57 PM org.apache.jk.common.ChannelSocket init

INFO: JK2: ajp13 listening on /0.0.0.0:8009

Jul 29, 2004 2:41:57 PM org.apache.jk.server.JkMain start

INFO: Jk running ID=0 time=1/32  config=/opt/tomcat/conf/jk2.properties

Jul 29, 2004 2:41:57 PM org.apache.catalina.startup.Catalina start

INFO: Server startup in 6293 ms

Jul 29, 2004 2:44:19 PM org.apache.coyote.http11.Http11Protocol pause

INFO: Pausing Coyote HTTP/1.1 on http-8080

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardService stop

INFO: Stopping service Catalina

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /cookieMonster

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /webdav

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /fleadirt

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /StrutsBlank

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /Tom1

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /hellotom

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /gmail

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /manager

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /jdbc

Jul 29, 2004 2:44:20 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /admin

Jul 29, 2004 2:44:20 PM org.apache.catalina.logger.LoggerBase stop

INFO: unregistering logger Catalina:type=Logger,path=/admin,host=localhost

Jul 29, 2004 2:44:21 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /balancer

Jul 29, 2004 2:44:21 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /fleadirt2

Jul 29, 2004 2:44:21 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path /StrutsValidation

Jul 29, 2004 2:44:21 PM org.apache.catalina.core.StandardHostDeployer remove

INFO: Removing web application at context path

Jul 29, 2004 2:44:21 PM org.apache.catalina.logger.LoggerBase stop

INFO: unregistering logger Catalina:type=Logger,host=localhost

Jul 29, 2004 2:44:21 PM org.apache.catalina.logger.LoggerBase stop

INFO: unregistering logger Catalina:type=Logger

Jul 29, 2004 2:44:21 PM org.apache.coyote.http11.Http11Protocol destroy

INFO: Stopping Coyote HTTP/1.1 on http-8080

```

----------

## defconx

Ensure that CATALINA_HOME is set in your environment and that is it correct.  You should be able to perform a $ echo $CATALINA_HOME  This command should be set to the Tomcat home directory.  This is prob. /opt/tomcat5 from what I can tell from your post.  As a sanity check, the bin and conf directory should be right off of the CATALINA_HOME dir.

if it is not set and you are running bash shell, type: export CATALINA_HOME=the_place_where_tomcat_root_is_ (obviously replace this with the correct dir location).

Once that is done, you are very close.  cd to # cd $CATALINA_HOME/conf

Type: vi (or your fav text editor) server.xml  In here you will find a few lines that tell tomcat where your application's directories are or where the webapps dir is.  Make sure that these are consistent with where they currently reside.

Once you are done you should be able to perform a # $CATALINA_HOME/bin/startup.sh   <- The manual way

-or- 

use your init script.

I am pretty sure once your CATALINA_HOME is set correctly, eclipse should work well again.

Hope all goes well.  Let me know if you need more details.

Cheers,

defconx

----------

## ravingsanity

I think the ebuild is broken because it appears to set incorrect permissions for tomcat's configuration directories.  In the init.d script, tomcat is run as user and group tomcat, but the configuration directories -both /opt/tomcat5/conf and /etc/tomcat5- are owned and only readable/writable by root which of course means that user tomcat in group tomcat cannot read the files it needs to read as is evidenced by the following (from /var/log/tomcat5/catalina.out):

 *Quote:*   

> Can't load server.xml
> 
> Can't load server.xml
> 
> Aug 5, 2004 5:00:45 PM org.apache.catalina.startup.Catalina start
> ...

 

Then, after telling tomcat to stop via '/etc/init.d/tomcat5 stop', I get:

 *Quote:*   

>  * Stopping Tomcat...
> 
> Using CATALINA_BASE:   /opt/tomcat5
> 
> Using CATALINA_HOME:   /opt/tomcat5
> ...

 

So, it really looks like permissions are set incorrectly upon install because the file being complained about, /opt/tomcat5/conf/server.xml, is there, Tomcat just can't see it if it is started and stopped via the /etc/init.d/tomcat5 script.  However, I will add that if /opt/tomcat5/bin/startup.sh is used instead, that everything works as expected and so the temporary (?) workaround is to simply use tomcat's own startup.sh and shutdown.sh instead of /etc/init.d/tomcat5.

Hopefully this little problem will be hammered out soon before more people are bitten by it...

----------

## defconx

ravingsanity - 

I am going to try to look at the ebuild script for Tomcat.  I am pretty green in Gentoo-land so we will see how it goes.  I don't see any reason why Tomcat would have to run as root.  You could perform a:

(as root)# chown -R tomcat:tomcat /opt/tomcat5

This will recusrsively change the ower and group to tomcat on the tomcat files and dirs.  Once this is done, you should be able to use the init scripts.  Hope this helps.

Cheers.

----------

## ravingsanity

 *defconx wrote:*   

> 
> 
> (as root)# chown -R tomcat:tomcat /opt/tomcat5
> 
> 

 

I did try that, and it seemed to sort of work but not completely.  In any case, it still didn't work correctly so there might be another little thing at work here.  Until the ebuild/install bug (whatever it may be) is worked out, I'm happy to use tomcat's own scripts as this is just my desktop workstation and not a "real" server available to the world.

----------

## Danathan

I ran into this same set of problems.  It took me about an hour to move my webapps over into the /opt/tomcat5 directory, and move the contents of /etc/tomcat -> /etc/tomcat5... luckily I was doing this on a dev server, and not my production server.

I looked through the changelog and there's nothing that I saw saying that this will be a non-trivial update.  It's very frustrating to have to wonder whether or not an update will go smoothly or not -- and given that one of Gentoo's real selling points is that you don't wind up far behind the current release (unlike, say, Debian) there really needs to be some kind of notification system for when a minor upgrade is going to break your gentoo.

i'd encorage people to add

```
=net-www/tomcat-5.0.18
```

to their /etc/portage/package.mask file until they have about an hour they know that their server can be offline.  Just my $0.02.

----------

## dustfinger

I was getting the same error messages when shutting down tomcat.  It turned out that my server.xml file was root:root because I wrote it myself using root.  Oddly when I ran the command chown -R tomcat:tomcat /opt/tomcat5/ it never changed the ownership of server.xml??  The recursive flag did not seem to work.  I had to explicitly change that particular file.

```
 chown tomcat:tomcat /opt/tomcat5/conf/server.xml 
```

Now that problem is solved.  Onto the next.

dustfinger.

----------

