I have installed the tomcat and Java on my Amazon EC2 Instance by followingthe instructions on the following tutorial. http://sites.google.com/site/amistrongeryet/setting-up-java-tomcat-on-ec2. But after installing when I run the "updatedb; locate javac | grep bin" command it did not recognize the update and locate command and gives me the error message locate: command not found and after installing the tomcat everything went sommoth during installation according to the instructions in above mentioned tutorial but at the end when I run the command "bin/startup.sh" and try to navigate the url http://my_public_dns_key:8080 it gives me the connection timed out error.

Also please find below the command reference for my linux commands that I am using to run Java and tomcat.

Command References:

[ec2-user@domU-12-31-39-09-D1-AA ~]$ cd /env/tomcat/
[ec2-user@domU-12-31-39-09-D1-AA tomcat]$ ls
apache-tomcat-6.0.33  apache-tomcat-6.0.33.tar.gz
[ec2-user@domU-12-31-39-09-D1-AA tomcat]$ cd apache-tomcat-6.0.33
[ec2-user@domU-12-31-39-09-D1-AA apache-tomcat-6.0.33]$ sudo bin/startup.sh
Using CATALINA_BASE:   /env/tomcat/apache-tomcat-6.0.33
Using CATALINA_HOME:   /env/tomcat/apache-tomcat-6.0.33
Using CATALINA_TMPDIR: /env/tomcat/apache-tomcat-6.0.33/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /env/tomcat/apache-tomcat-6.0.33/bin/bootstrap.jar
[ec2-user@domU-12-31-39-09-D1-AA apache-tomcat-6.0.33]$ rpm -q tomcat
package tomcat is not installed
[ec2-user@domU-12-31-39-09-D1-AA apache-tomcat-6.0.33]$ cd /usr/local/java/
[ec2-user@domU-12-31-39-09-D1-AA java]$ ls
jdk-6u20-ea-bin-b02-linux-amd64-01_apr_2010-rpm.bin  sun-javadb-client-10.5.3-0.2.i386.rpm  sun-javadb-core-10.5.3-0.2.i386.r
jdk-6u20-ea-linux-amd64.rpm                          sun-javadb-common-10.5.3-0.2.i386.rpm  sun-javadb-demo-10.5.3-0.2.i386.r
[ec2-user@domU-12-31-39-09-D1-AA java]$ cd env/tom
-bash: cd: env/tom: No such file or directory
[ec2-user@domU-12-31-39-09-D1-AA java]$ cd /env/tomcat/
[ec2-user@domU-12-31-39-09-D1-AA tomcat]$ cd apache-tomcat-6.0.33
[ec2-user@domU-12-31-39-09-D1-AA apache-tomcat-6.0.33]$ sudo bin/startup.sh
Using CATALINA_BASE:   /env/tomcat/apache-tomcat-6.0.33
Using CATALINA_HOME:   /env/tomcat/apache-tomcat-6.0.33
Using CATALINA_TMPDIR: /env/tomcat/apache-tomcat-6.0.33/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /env/tomcat/apache-tomcat-6.0.33/bin/bootstrap.jar
[ec2-user@domU-12-31-39-09-D1-AA apache-tomcat-6.0.33]$

Please provide any help that you can provide and help me to sort the issue out. Thanks in advance.

  • 1
    In shell, which javac, what do you got? Command not found? – Coder4 Sep 28 '11 at 11:46
  • updatadb is just for you can use locate, you may refer the location of javac by system environment setting. – Coder4 Sep 28 '11 at 11:46
  • This is not an answer to your question but it might be a solution for your problem: take a look at Amazon's Elastic Beanstalk. Instead of a linux instance you get a tomcat instance. – Kees de Kooter Sep 28 '11 at 11:48

Here are the steps I documented for myself in setting up java and tomcat in a 32 bit small instance. (lame that they support 32/64 bit on micro, but only 32 bit on small!)

Installing Tomcat

# make the directory that is going to hold tomcat
sudo mkdir /opt/tomcat
cd /opt/tomcat
# download tomcat
curl http://mirror.olnevhost.net/pub/apache/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.zip > tomcat6.zip
unzip tomcat6.zip
# now go into apache-tomcat-.../conf/server.xml and change all 8080 to 80 so we are running on the regular web port.
# then start tomcat.
sudo /opt/tomcat/apache-tomcat-.../bin/startup.sh

I later change it to use sudo wget http://apache.tradebit.com/pub/tomcat/tomcat-7/v7.0.16/bin/apache-tomcat-7.0.16.tar.gz

At this point, you should be able to hit http:/// and get the tomcat management page.

Installing Sun JDK 6 Download Sun JDK 6. You must agree to the terms and conditions in order to download, so I think you'll have to download and then sftp it over. I downloaded from http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html the 32 bit .bin version.

unzip the jdk into /opt/jdk1.6.xxx and then install it as a java alternative using the following:

sudo alternatives --install /usr/bin/java java /opt/jdk1.6.0_26/bin/java 1500
sudo alternatives --install /usr/lib/jvm/jre jre /opt/jdk1.6.0_26 1500
sudo alternatives --set java /opt/jdk1.6.0_26/bin/java
sudo alternatives --set jre /opt/jdk1.6.0_26

Then make sure you are running java by checking java -version. Since tomcat will be starting as root, I used sudo to test it.

$ sudo java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)
| improve this answer | |
  • Both the links for tomcat are dead. Please advice. – Sohail Khan Sep 28 '11 at 17:45
  • go to the tomcat download page and find whatever version you need and get the appropriate url from that download page. – digitaljoel Sep 28 '11 at 19:12
  • I have done the following steps to install tomcat but no success 1- make the dir tomcat in opt 2- download the tomcat6 in tomcat folder 3- unzip the zip file in tomcat folder 4- do the necessary changes in conf/server.xml 5- run the bin/startup.sh file and it gives me the command not found. – Sohail Khan Sep 29 '11 at 17:50
  • make sure the script is executable and you have the correct path. – digitaljoel Sep 29 '11 at 19:44

Have you checked that the security group of that instance allows inbound connections to port 8080

| improve this answer | |

It looks as if Tomcat had started. Run

sudo fuser -v -n tcp 8080

It should output something like:

                     USER        PID ACCESS COMMAND
8080/tcp:            tomcat      pid F.... java

Then probe Tomcat right from the instance using wget or curl:

wget --spider localhost:8080

If you get 200 OK in response, it must be the firewall settings that prevent connection. Check your security group setting as David has already suggested - there must be a Custom TCP rule for port 8080.

You may also find it easier to install Java and Tomcat from the repo next time. There is a step-by-step guide for Amazon Linux in my article on Tomcat and EC2.

| 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.