1

I am not so into system engineer (I am a Java developer) and I am finding some difficulties trying to understand if a Tomcat server (on a remote server) on which I have to deploy an application is well configured or if have some configuration problem.

The operating system is Linux CentOS release 6.7 (Final)

I need your help to understand what is the situation and what I have to say when I will contact the system administrator of this server.

So to restart Tomcat I have the following statment:

sudo -i -u projectname

sudo service projectnames top sudo service projectname start

First I have to switch on a user having the same name of the project that I have to deploy and of the Tomcat instance that I have to start that will host this project (these information was provided from the sysadmin of this server).

The server seems starts, this is the output:

[projectname@servername webapps]$ sudo service projectname start
getsebool:  SELinux is disabled
Using CATALINA_BASE:   /usr/local/tomcat/projectname
Using CATALINA_HOME:   /usr/local/tomcat/default
Using CATALINA_TMPDIR: /usr/local/tomcat/projectname/temp
Using JRE_HOME:
Using CLASSPATH:       /usr/local/tomcat/default/bin/tomcat-juli.jar:/usr/local/tomcat/default/bin/bootstrap.jar

The webaps folder should contains the deployed application and it seems to contain the old version of the application that I have to deploy:

[projectname@servername webapps]$ ls
ROOT  ROOT.war

Where ROOT.war is the old war version of my application and the ROOT directory seem to be tha exploded version of this war file.

The problem is that seems that Tomcat does not respond. Trying to open this URL from the browser (this is the server address used to connect via SSH):

http://myservername.hq.mycompany.org:8080/

I obtain a 404 error.

So following these suggestions:

Performing the ps -ef | grep tomcat statment I obtain:

[projectname@servername webapps]$ ps -ef | grep tomcat
projectname      8454     1  1 10:11 ?        00:00:06 /usr/local/jvm/default/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/projectname/conf      /logging.properties -Xmx512m -Xms128m -XX:MaxPermSize=512m -XX:PermSize=256m -XX:+UseConcMarkSweepGC -Djava.util.logging.manager=org.apache      .juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/default/endorsed -classpath /usr/local/tomcat/default/bin/tomcat-juli.ja      r:/usr/local/tomcat/default/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat/projectname -Dcatalina.home=/usr/local/tomcat/default -Djava.io.tm      pdir=/usr/local/tomcat/projectname/temp org.apache.catalina.startup.Bootstrap  start
projectname      8488  8119  0 10:20 pts/0    00:00:00 grep tomcat

So it seems that the server is started.

But if I perform the netstat -a | grep 8080 to see what is listening on the 8080 port I obtain nothing, this is my output:

[projectname@servername webapps]$ netstat -a | grep 8080
[projectname@hqldservername webapps]$

So what it means? That Tomcat is not working on the 8080 port or that it could be missconfigured? (because it starts but not list).

This is the content of the /usr/local/tomcat/projectname/conf/server.xml configuration file:

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005"
shutdown="SHUTDOWN">
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <!--
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  -->
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080"
              protocol="HTTP/1.1"
              connectionTimeout="20000"
               URIEncoding="UTF-8"
              redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <!--
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    -->
   <Connector port="8009"
               protocol="AJP/1.3"
               redirectPort="8443" />

    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

     <Host name="localhost"  appBase="webapps"
            unpackWARs="true"
            autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>

So I have the following doubts and I need some explanation to correctly expose the problem to my sysadmin:

1) Is it this server correctly runned?

2) Is it listing on 8080 port? If not is it listing on another port or could be that is runned but is not listing on any port?

3) The webapps directory contains the war (in my case ROOT.war) file to deploy and the exploded ROOT directory is the deployed version of this file? Or is it elsewhere?

1
  • Please try sudo netstat -nap | egrep ':80|java' and post the result into your question. Notice the different flags to netstat.
    – roaima
    Feb 6, 2017 at 15:05

1 Answer 1

0

http://myservername.hq.mycompany.org:8080/

I obtain a 404 error.

Everything you've described is a correct, expected behavior. The tomcat is listening on 8080, otherwise you would never get a 404. Any 3xx, 4xx, 5xx and all other HTTP codes come from server, hence a TCP session worked, hence connect/listen/bind all worked.

I think what you should ask admin is:

Specifics:

  1. Tomcat looks good.

  2. Instead of netstat -a you should do nestat -an or better netstat -lntp or even better a modern ss -lntp

  3. Tomcat listens on changes to webapps subdirectory. Once you put a .war there, you should expect tomcat to start deploy it automatically. If tomcat was dead, when it starts it will deploy the webapps. There is no other application store. For the deployment restults, check the logs/catalina.out and other logs.

P.S. Many applications have also "ugly" requirements for a successful deployment: always stop tomcat, delete everything from temp, everything from work, start tomcat.

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