1

I have installed tomcat using sudo apt-get install tomcat7 and when i am trying to start the tomcat server using sudo /usr/share/tomcat7/bin/startup.sh I am getting the following error

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 /usr/share/tomcat7/bin/catalina.sh: 389: /usr/share/tomcat7/bin/catalina.sh: cannot create /usr/share/tomcat7/logs/catalina.out: Directory nonexistent. I went through a similar problem How to fix 'Failed to initialize end point associated with ProtocolHandler' error? but the solution says I to re-install tomcat which i don't want to do.Need help

Community
  • 1
  • 1
RCBian
  • 1,080
  • 2
  • 20
  • 31

3 Answers3

0

You need to start it as a service, using either service tomcat start or /etc/init.d/tomcat start.

Sylvain B
  • 513
  • 7
  • 12
0

First you need to set the $JAVA_HOME so that $JRE_HOME in tomcat points to the correct Java path.

If you don't hava Java installed, then install the latest version of Java from the Ubuntu software center

Then, in the terminal type

sudo gedit ~/.bashrc

This will open the .bashrc file. At the end, add

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

You should check the exact folder name in /usr/lib/jvm

To start tomcat7, in the terminal type

sudo service tomcat7 start

And to stop it type

sudo service tomcat7 stop

when you type sudo /usr/share/tomcat7/bin/startup.sh you should see

Using JRE_HOME: /usr/lib/jvm/java-7-openjdk-amd64

Anupam Ghosh
  • 314
  • 3
  • 10
0

I am working through a similar issue setting up tomcat 8 in Ubuntu. Though I am able to manually start using super user script as below, it does not resolve the error I was receiving.

sudo service tomcat8 start

I can tell you that in my case /usr/share/tomcat7/logs/ folder does not exist. Take a look at the scripts you are running and check your paths.

I was running the startup.sh and realized that my path was incorrect. I opened the script for startup.sh located in CATALINA_HOME directory. Looked for the failing line: Error: touch: cannot touch '/usr/share/tomcat8/logs/catalina.out'. Saw that we were executing the catalina.sh.

# Guilty Line in this case
EXECUTABLE=catalina.sh

Since the line referenced catalina.sh script, I tried to locate the error in that script. The catalina.sh located in your CATALINA_HOME directory. If you read in the comments these are all default settings.

#   CATALINA_OUT    (Optional) Full path to a file where stdout and stderr
#                   will be redirected.
#                   Default is $CATALINA_BASE/logs/catalina.out

I found the guilty like and updated the path to match my actual folder path, changed 'logs' to 'log'.

if [ -z "$CATALINA_OUT" ] ; then
   CATALINA_OUT="$CATALINA_BASE"/log/catalina.out
fi

After I made this update I ran the script again:

touch: cannot touch '/usr/share/tomcat8/log/catalina.out': Permission denied
/usr/share/tomcat8/bin/catalina.sh: 402:         
/usr/share/tomcat8/bin/catalina.sh: cannot create     
/usr/share/tomcat8/log/catalina.out: Permission denied

This time I had to deal with the permissions for the folders. Make sure that which ever user is calling your script has permissions.

V. Keating
  • 56
  • 4