Tuesday, April 30, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 32502  / 2 Years ago, fri, october 7, 2022, 7:53:22

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)

More From » 14.04

 Answers
0

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


[#24460] Friday, October 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
naldis

Total Points: 257
Total Questions: 101
Total Answers: 111

Location: Kenya
Member since Sat, Feb 25, 2023
1 Year ago
;