Ubuntu – Cannot start tomcat after installing a private instance

12.04eclipsetomcat7

Ok, now I've spend enough time configuring Tomcat properly on my Ubuntu 12.04 OS, and I'm already fed-up, given that it's already 2:00 am.

First I installed tomcat7 as described in this question – How should I install Apache Tomcat 7 for use with Eclipse?.

Then I thought I would install a private instance of tomcat as described in an answer to the linked question. So, I uninstalled tomcat7 using the process described in this question – https://askubuntu.com/q/313070/159439

And now, I installed a private instance using:

sudo apt-get install tomcat7-user
sudo tomcat7-instance-create ~/my-tomcat-instance

Now, when I go to start the tomcat, it's not starting. Since it is not installed as a service, so I of course cannot start it as a service. But, I can't even start it using the startup.sh file. I'm getting the following error:

/usr/share/tomcat7$ bin/startup.sh

Using CATALINA_BASE:   /usr/share/tomcat7
Using CATALINA_HOME:   /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME:        /usr

Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
touch: cannot touch `/usr/share/tomcat7/logs/catalina.out': No such file or directory
bin/catalina.sh: 389: bin/catalina.sh: cannot create /usr/share/tomcat7/logs/catalina.out: Directory nonexistent

Now what's the problem here. I understand that earlier tomcat was not starting as it was installed as a service. So, I've to use – service tomcat7 start, to start it. But now, it's not installed as a service. So, how am I supposed to start it?


I'm facing another issue of configuring the newly installed tomcat in eclipse. It's showing me the same error as in this question – Tomcat 7 and Eclipse integration getting error when I add the server. I'm using Eclipse Juno. Installed it by downloading a .tar.gz file.

Kindly help me out of here. I've been stuck with it for the last 5 hours.

Best Answer

From the command line

To run your private instance of Tomcat from the command line, you need to run the startup.sh script within the private instance directory rather than the one in /usr/share/tomcat7. So, in your case, you need to run:

~/my-tomcat-instance/bin/startup.sh

This should work out-of-the-box.

From Eclipse

To run from Eclipse you should also create your Server Runtime Environment using your ~/my-tomcat-instance/ directory instead of /usr/share/tomcat7/.

However, getting this working is far harder than it should be. This is partly because Eclipse is a bit buggy, and partly because Eclipse doesn't distinguish between CATALINA_BASE and CATALINA_HOME.

Missing files

It turns out that the tomcat7-instance-create script does not set up everything that Eclipse needs. This was reported as a bug that appears to have been fixed at some point for Tomcat 6, but for whatever reason the patch is not in the tomcat7-user package. I've raised a new bug in the hope this will get fixed, but in the meantime, you need to run the following commands:

ln -s /usr/share/tomcat7/lib ~/my-tomcat-instance/lib
ln -s /usr/share/tomcat7/bin/bootstrap.jar ~/my-tomcat-instance/bin/bootstrap.jar

Then you need to grab a copy of catalina.policy which is not distributed as part of the tomcat7-user package and put it in the conf/ directory in your instance. You can get it from the code repository for the tomcat7 package:

curl http://bazaar.launchpad.net/\~ubuntu-branches/ubuntu/precise/tomcat7/precise/view/head:/conf/catalina.policy > ~/my-test-tomcat7-instance/conf/catalina.policy

New server bug

Whilst testing this, I also ran into another bug, which I solved by deleting these files:

{workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.server.core.prefs
{workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jst.server.tomcat.core.prefs

as per the accepted answer on Eclipse add Tomcat 7 blank server name. Obviously, only do this step if you need to.


See also Eclipse 4.2 (Juno) 'Cannot create a server using the selected type' in Tomcat 7 for getting this working using the tomcat7 package.

Related Question