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: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
andCATALINA_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 thetomcat7-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:Then you need to grab a copy of
catalina.policy
which is not distributed as part of thetomcat7-user
package and put it in theconf/
directory in your instance. You can get it from the code repository for thetomcat7
package:New server bug
Whilst testing this, I also ran into another bug, which I solved by deleting these files:
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.