Reputation: 13
Tried everything but it just wont work, im running tomcat7 on an EC2 instance (amazon AWS). I can start up tomcat7 manually by starting startup.sh, but not automatically on startup. The error message I get in logs/catalina.out is the following:
/etc/apache-tomcat-7.0.32/bin/catalina.sh: 1: eval: /etc/jdk1.7.0_07/bin/java: not found
My enviroment variables are also setup properly:
echo $JAVA_HOME -> /etc/jdk1.7.0_07/bin/java
echo $PATH -> /usr/local/sbin:/usr/local/bin:/usr/sbin/:/usr/bin:/sbin:/bin:/usr/games:/etc/jdk1.7.0_07/bin
I can also type "java -version" in shell getting proper output, however "/etc/jdk1.7.0_07/bin/java -version" does not work and only returns "No such file or directory".
Im really not sure what to do now, feels like i tried everything, hope someone can help me! Also the instance is running Ubuntu server 12.04.
Upvotes: 1
Views: 18402
Reputation: 948
The hint for me was modifying the shell script file (set JAVA_HOME variable) and this resolved the issue.
The tomcat script file is generally under /etc/init.d/ directory
Upvotes: 0
Reputation: 539
I do not particularly known about specifics of ubuntu+tomcat7 on EC2. So my answer could be missing a point a bit. It is given from generic ubuntu point of view.
Possibly things will be a bit easier to manage if you use apt-get to manage tomcat and java on ubuntu. In that case the tomcat will automatically started on start up. The commands below are tested on ubuntu 12.10, but also worked on some earlier version.
To install Java you need the following:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
If the first command fails, use the following:
sudo apt-get install software-properties-common
Then install tomcat7 using:
sudo apt-get install tomcat7
After that you need to tell tomcat to use installed java 7. For that purpose modify /etc/default/tomcat7 file either manually or using command like the following:
cat /etc/default/tomcat7 | sed 's/#JAVA_HOME=\/usr\/lib\/jvm\/openjdk-6-jdk/JAVA_HOME=\/usr\/lib\/jvm\/java-7-oracle/' >/tmp/tomcat7-updated
sudo cp /tmp/tomcat7-updated /etc/default/tomcat7
After that tomcat should load on start up. You just need to tune up ports and other configuration information. Note that this tomcat uses /var/lib/tomcat7/webapps/ to store web applications. You could also start or stop tomcat manually using the commands like the following:
sudo /etc/init.d/tomcat7 start
Upvotes: 1
Reputation: 602
For automatic startup of tomcat, it should be started during booting time only.
For that you need to write a script which starts the tomcat and put this file in the etc/init.d or you can put it for different runlevels.
Upvotes: 0
Reputation: 19185
Do sudo su vi /etc/bash.bashrc
and copy following
JAVA_HOME=/etc/jdk1.7.0_07 //you have to only specify path until java dir not bin
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
Upvotes: 1