9

I have a problem starting tomcat from terminal. I installed tomcat using - sudo apt-get install tomcat7, few days back. Now when I'm starting it using the below command, I'm getting the following error:

~/tomcat7/bin$ sudo ./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  
./catalina.sh: 389: ./catalina.sh: cannot create /usr/share/tomcat7/logs/catalina.out: Directory nonexistent

I can't understand what went wrong. I was able to access - http://localhost:8080 when I installed it. But then, I ran the command to disable the startup at boot time:

sudo update-rc.d tomcat remove

And now it's not starting at all. :(

Rohit Jain
  • 877
  • 2
  • 8
  • 15
  • Are you sure you're running the Tomcat from the Ubuntu packages? I don't think so... It seems you've installed another one from upstream (in `~/tomcat7`?) as the one from Ubuntu won't write log files to `/usr/share/tomcat7/logs`, but to `/var/log` somewhere. Didn't you mean to run Tomcat like `service tomcat start`? – gertvdijk Jun 26 '13 at 17:44
  • @gertvdijk. Oh Dear! It works now. Seems like tomcat was installed as a service. Thanks. – Rohit Jain Jun 26 '13 at 17:47
  • @gertvdijk. I've one more question. I'm now trying to deploy a war file. I copied it in - `/usr/share/tomcat7/webapps` directory. But when I access the page, It show 404 error. Then I moved the war file to - `/var/lib/tomcat7/webapps`, there also it's showing the same error. How would I deploy the war? If you want, I can post it as a different question. – Rohit Jain Jun 26 '13 at 17:49
  • @gertvdijk. Meanwhile, you can add your comment as answer. I'll accept it. Thanks :) – Rohit Jain Jun 26 '13 at 17:49
  • Please don't ask new questions in comments. Ask a new question instead by pressing the "Ask Question" button at the top of the page. – gertvdijk Jun 26 '13 at 17:50
  • @gertvdijk. Sure. – Rohit Jain Jun 26 '13 at 17:51
  • Hi @gertvdijk. I got another issue. I uninstalled the old tomcat, and installed a private instance, using `sudo apt-get install tomcat7-user`. And now I cannot start tomcat using either startup.sh, or as a service. :( – Rohit Jain Jun 26 '13 at 20:18

4 Answers4

6

When installed using the tomcat7 package, it is intended that you start and stop Tomcat using upstart (service tomcat start) or the /etc/init.d/tomcat script. If you start it using the startup.sh script then it is likely to have its environmental variables incorrectly configured.

Please see my answer to your previous question (How should I install Apache Tomcat 7 for use with Eclipse?) for a better way to install Tomcat if you don't want to run it as a service.

David Edwards
  • 5,088
  • 3
  • 33
  • 45
  • Ok. I think I would better install a private instance of tomcat. Can I just do - `apt-get purge tomcat7` to uninstall the previous one? – Rohit Jain Jun 26 '13 at 17:52
  • 1
    @RohitJain No. `apt-get` manages the Ubuntu packages, not the files you installed from another source. Consult the README/INSTALL or other documentation with the upstream source of the other instance you have installed. Please avoid running software from source if Ubuntu packages are available. As you see you're only making it harder to manage your system. – gertvdijk Jun 26 '13 at 17:53
  • @gertvdijk. I installed it using `apt-get install tomcat7` only. Can I do uninstall it like that in this case? – Rohit Jain Jun 26 '13 at 18:02
1

just create the missing folder like this:

sudo mkdir /var/tomcat/logs

then run tomcat again like this:

sudo sh /opt/apache-tomcat-{version}/bin/startup.sh

The message itself is self explanatory, if you don't know the hierarchy of the Unix/Linux File System, and how it works, i highly recommend you to start watching some tutorials.

JulsLyon
  • 11
  • 1
0

In my case I faced similar issue and tomcat7 would not start.
Apparently the /var/log/tomcat7 folder had been deleted due to box reboot...

Here is how i fixed :

rwxrwxrwx 1 root    root      17 Feb 27  2014 logs -> ../../log/tomcat7
/var/log# mkdir tomcat7
/var/log/tomcat7# cd /etc/init.d/
/etc/init.d# ./tomcat7 start
abu_bua
  • 10,473
  • 10
  • 45
  • 62
dinbo
  • 1
0

I encountered the same problem, and I fixed it with the following:

sudo mkdir /usr/share/tomcat7/logs/
sudo touch /usr/share/tomcat7/logs/catalina.out
sudo chown -R tomcat: /usr/share/tomcat7/ 

Where "tomcat" is your Tomcat user

sudo systemctl daemon-reload
sudo systemctl start tomcat
David
  • 3,317
  • 11
  • 34
  • 56
John Guoy
  • 1
  • 1