9

If I apt-get install tomcat7 it is installing a broken tomcat7. A simple startup.sh will give me errors, than when fixed says that tomcat has started but nothing shows up in localhost:8080. shutdown.sh will give me errors and even throw Java exceptions. This wasn't happening in some previous Ubuntu release, where it simply worked. So, it is looks like tomcat package it been not maintained lately.

I can get it working from Eclipse (which by the way it is not been properly maintain too) when I am testing my web app. However there are things I need to test in an standalone tomcat installation. So far, Google hasn't helped.

Have any of you managed to properly installing tomcat7 in Ubuntu 14.4LTS? If so, can you point me to the right direction?

Edit:

Here is some logs.

Starting tomcat:

$ sudo /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
Tomcat started.

Browsing to localhost:8080 (and http://127.0.0.1:8080, http://127.0.0.1, http://[my network ip here]):

Oops! Google Chrome could not connect to localhost:8080

Stopping tomcat also fails:

$ sudo /usr/share/tomcat7/bin/shutdown.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
Jul 03, 2014 7:15:55 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
Jul 03, 2014 7:15:55 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
Jul 03, 2014 7:15:55 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Jul 03, 2014 7:15:55 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
Jul 03, 2014 7:15:55 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Jul 03, 2014 7:15:55 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]
Jul 03, 2014 7:15:55 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop: 
java.io.FileNotFoundException: /usr/share/tomcat7/conf/server.xml (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:466)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:370)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:457)
  • could you post startup.sh and shutdown.sh output? – Lety Jun 29 '14 at 18:11
  • 5
    What is meant by apt-get install tomcat7 is installing broken tomcat7 ? – Pandya Jun 30 '14 at 6:38
  • 1
    Unfortunately there's not enough details here. What exactly makes you think that Tomcat7 is broken from the repositories? What symptoms suggest this? – Thomas Ward Jul 2 '14 at 0:17
  • Post the error logs. And also: what does 'but nothing shows up in localhost:8080' means? void page? connection error page? 404? – eddieferetro Jul 2 '14 at 8:59
  • 1
    @Pandya by broken I mean that apt-get is installing a not working package. It can be not configured, not updated, incomplete, buggy... – Juan Garcia Jul 3 '14 at 10:53
3

I believe your CATALINA_BASE is incorrect it runs out of the /var/lib/tomcat7 directory and CATALINA_HOME is proper in regards to how you have declared the variable. Add CATALINA_HOME and CATALINA_BASE to /etc/default/tomcat7 along with JAVA_HOME and JRE_HOME. That executable notifies the tomcat servlet of how the environment is set upon start up of the servlet.

It could also be considered to put them in /etc/profile and then export them in /etc/bash.bashrc (i.e. export CATALINA_HOME). This should only be done if and only if your site doesn't have user login or registration. With out exporting the variables they would still be declared locally.

To globally declare the variables an approach, if you are the admin (group 4, you might also want to think about moving syslog to group 37, purging rsyslog and just keep the daemon running for logs as well so you preserve mandatory access control) you could ponder creating a ~/.bash_completion or ~/.bash_expert file in your home directory where you have something like this:

# ~/.bash_expert in regards to servlet alias
if [ -f /etc/bash_completion.d/.tomservlet ]; then
    . /etc/bash_completion.d/.tomservlet
fi
export CATALINA_HOME
export CATALINA_BASE
export JRE_HOME
export JAVA_HOME

Then create the .tomservlet file in /etc/bash_completion.d/.tomservlet and add the following:

CATALINA_HOME=/usr/share/tomcat7
CATALINA_BASE=/var/lib/tomcat7
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
JRE_HOME=$JAVA_HOME:/jre

Once that is completed add the following lines to ~/.bashrc

if [ -f "$HOME/.bash_expert" ];then
    . "$HOME/.bash_expert"
fi

Then source the ~/.bashrc file as shown below:

:~$ source .bashrc

and that should take care of your problems, in a secure fashion no matter what type of client side interaction is taken place. (Don't hold me to that, you never know what martians are lurking in cyberspace, it can be a scary realm sometimes).

P.S. I previously was referring to the oracle-sun jdk7 or I guess its just Oracle Jdk7 so if you are using the Open Jdk replace it as necessary, if using the oracle go back into the /etc/init.d/tomcat file and change openjdk to your version where the script refers to "$OPENJDK". This also assumes you installed from the repositories.

Good luck, and may your tomcat purr!!

| improve this answer | |
8

I tried this on a fresh container:

sudo apt-get install tomcat7
sudo dpkg-reconfigure tomcat7

It seems to fix the issue in my case.

Edit : dpkg-reconfigure will replace your custom config for tomcat7 with the default packet manager configuration, or, where given, it will present a menu to customize.

| improve this answer | |
  • Tried this, didnt fix the error for me sadly. Broke my install also, bind exceptions etc. – John Little Jun 15 '16 at 13:31
  • Should have added that reconfigure replaces any custom files with the package manager's defaults for the given package. – user283885 Jun 16 '16 at 15:33
2
  1. Download the official tomcat from their website

    wget http://mirrors.fe.up.pt/pub/apache/tomcat/tomcat-7/v7.0.54/bin/apache-tomcat-7.0.54.zip
    
  2. Decompress it

    unzip apache-tomcat-7.0.54.zip       
    
  3. Make sure you have Java installed and JAVA_HOME defined

  4. Start your tomcat.

| improve this answer | |
0

Try launching it like a service with service tomcat7 start.

I've tried and it in my local (ubuntu 14.04) and works. It gave me a problem with de JAVA_HOME, but I've fix this way it and works:

1- Edit tomcat's config file:

vim /etc/default/tomcat7

2- Search JAVA_HOME line (it's commented), and put something like:

JAVA_HOME=/usr/lib/jvm/<your-jvm>

p.e:

JAVA_HOME=/usr/lib/jvm/java-7-oracle

Save and start tomcat like a service:

root@skynet:/etc/init.d# service tomcat7 start
 * Starting Tomcat servlet engine tomcat7  

and

root@skynet:/etc/init.d# service tomcat7 stop
 * Stopping Tomcat servlet engine tomcat7
| improve this answer | |
0

installing eclipse & defult jdk & git

$ sudo apt-get eclipse
$ sudo apt-get eclipse-jdt
$ sudo apt-get eclipse-pde
$ sudo apt-get eclipse-platform
$ sudo apt-get eclipse-rcp

$ sudo apt-get install default-jdk
$ sudo apt-get install ant git

i'm using ssh because it's a Virtual Machine 'for test'
1 download the file 'tomcat7.0 apache download'

$ wget http://apache.claz.org/tomcat/tomcat-7/v7.0.54/bin/apache-tomcat-7.0.54.tar.gz

2 extract it ls

$ sudo tar -xvf apache-tomcat-7.0.54.tar.gz

3 make dir at

$ sudo mkdir /usr/local/tomcat7

4 move the file to the dir

$ mv apache-tomcat-7.0.54 /usr/local/tomcat7

5 installing

$ cd /usr/local/tomcat7/apache-tomcat-7.0.54
$ sudo ln -s /var/lib/tomcat/conf conf
$ sudo ln -s /etc/tomcat7/policy.d/03catalina.policy/conf/catalina.policy
$ sudo ln -s /var/log/tomcat7 log
$ sudo chmor -R 777 /usr/local/tomcat7/apach*/conf

6 configuration now we go to the ubuntu desktop

Lunch eclipse => window => Preferences => Server => Runtime Envirenment


select the version browse the dir => finish

$ cd ../../apach*/bin
$ ls -la 

shut it down

$ sudo ./shutdown.sh

lets make a test

eclipse => file => new => other... => web project

doulble click it => right click web content => test.htm 

<html>
<head>
<title> testing tomcat7 & eclipse</title>
</head>
<h2>Job's Done !</h2>

click on 'no servers are ....' => tomcat version => next => add to configured 
menu => run => run as => fninish
localhost:8080/test/test.htm
localhost:8080/project name/page name

Video tutorial : 'http://www.youtube.com/watch?v=n5joqK07-NE'

| improve this answer | |
  • The $ sudo service tomcat7 restart output is tomcat7: unrecognized service – Juan Garcia Jul 3 '14 at 9:38
  • $ cd /opt/local/tomcat7/bin $ ls you will find shell script file im not exactly sure about the name it could be restart.sh excute it by $ sudo sh restart.sh if the restart.sh dont exist try to start then close then start again by $ sudo startup.sh $ sudo shutdown.sh $ sudo startup.sh – hwez Jul 3 '14 at 9:48
  • /opt/local/tomcat7/bin doesn't exist, it is under /usr/share/tomcat7/bin. startup.sh said that tomcat has started but the browser can't see anythin in localhost:8080 (trying with local ip too). shutdown.sh show warnings and throws an exception. I will update the question with the log – Juan Garcia Jul 3 '14 at 10:10
  • Update: I have posted my logs – Juan Garcia Jul 3 '14 at 10:22
  • /opt/tomcat/bin or /opt/tomcat7 or /etc/tomcat7 or /etc/tomcat if you dont find it cd /opt; ls -lh && cd /etc; ls -ls put in pastebin & comment it im going to install tocat7 & check it for u – hwez Jul 3 '14 at 10:24
0

I had no problems installing and running Tomcat 7 in Ubuntu 14.04 LTS. Just to make sure, I looked up the bash history. Note that I first installed Oracle Java (in case it makes a difference)

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

then Tomcat

sudo apt-get install tomcat7

The command

sudo service tomcat7 restart

gives

 * Stopping Tomcat servlet engine tomcat7           [ OK ] 
 * Starting Tomcat servlet engine tomcat7           [ OK ]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.