0

I'm trying to put in a Tomcat server on our unix machine (access remotely) which will be used for test projects.

I used Tomcat 5.0.25 (as our production is using the same version).

For now i don't want to run it through Apache and instead just want to access tomcat directly.

So i've deployed Tomcat and configured server.xml (see below) but when i start it i am not able to see the tomcat 5 welcome page using this URL: global.int.com:9082

<?xml version='1.0' encoding='utf-8'?>

<Server port="9007" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
            debug="0"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
            debug="0"/>

  <!-- Global JNDI resources -->
  <GlobalNamingResources>

    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <!-- 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">
    </Resource>
    <ResourceParams name="UserDatabase">
      <parameter>
        <name>factory</name>
        <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
      </parameter>
      <parameter>
        <name>pathname</name>
        <value>conf/tomcat-users.xml</value>
      </parameter>
    </ResourceParams>

  </GlobalNamingResources>

  <Service name="Catalina">


    <Connector port="9082" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />


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


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


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

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

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

I can see Tomcat is running as Catalina.out says:

Jan 27, 2012 8:21:56 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-9082 Jan 27, 2012 8:21:56 PM org.apache.jk.common.ChannelSocket init INFO: JK2: ajp13 listening on /0.0.0.0:9020 Jan 27, 2012 8:21:56 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=1/14 config=/home/tomcat/tomcat5_fcl_uat/conf/jk2.properties Jan 27, 2012 8:21:56 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 2173 ms

And Command lsof -i TCP Shows:

java 29923 tomcat 5u IPv6 373023 TCP *:9082 (LISTEN)

I can't figure out why i can't see the tomcat page. I have another Tomcat server running on port 9081 and we can access it just fine by using url global.int.com:9081 and the above server.xml is a carbon copy of that except the port numbers are changed. Can anyone please give me a hint on where things are falling apart. Thanks

UPDATE2:

Result of wget -S from Remote Desktop:

    --2012-01-30 17:35:42--  http://global.int.com:9082/
    Resolving global.int.com... 10.215.222.78
    Connecting to global.int.com|10.215.222.78|:9082... failed: No route
    to host.

Below is the result of wget -S on LocalHost machine:

    [tomcat@global logs]$ wget -S  http://global.int.com:9082/
    --16:17:03--  http://global.int.com:9082/
    Resolving global.int.com:9082... 10.213.210.78
    Connecting to global.int.com:9082|10.213.210.78|:9082... connected.
    HTTP request sent, awaiting response...
      HTTP/1.1 200 OK
      Content-Type: text/html;charset=ISO-8859-1
      Date: Sat, 28 Jan 2012 05:17:03 GMT
      Server: Apache-Coyote/1.1
      Connection: close
    Length: unspecified [text/html]
    Saving to: `index.html'

        [ <=>                                                                                          ] 9,312       --.-K/s   in 0s

    16:17:03 (297 MB/s) - `index.html' saved [9312]

    [tomcat@global logs]$

UPDATE 3: Result of iptables -L -v -n:

  106  5920 ACCEPT     tcp  --  *      *       10.0.0.0/8           0.0.0.0/0           tcp dpt:8080
    6   312 ACCEPT     tcp  --  *      *       10.0.0.0/8           0.0.0.0/0           tcp dpt:8180
    0     0 ACCEPT     tcp  --  *      *       10.0.0.0/8           0.0.0.0/0           tcp dpt:9080
   19   988 ACCEPT     tcp  --  *      *       10.0.0.0/8           0.0.0.0/0           tcp dpt:9081

Correct me if I am wrong - but result of above shows the reason why I cannot access tomcat given I've assigned port 9082 to tomcat and that port does not exist in the above list.

All port numbers used in server.xml are unique (I've double checked). Any suggestions on why I can't get to see the Tomcat main page and how to fix it?

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
ke3pup
  • 1,835
  • 4
  • 36
  • 66
  • Check if you are not using the same shutdown port (9007) as the other tomcat on the same machine. Also, `wget -S` output would definitely be useful. – mindas Jan 27 '12 at 21:53
  • hi, I checked the Shutdown ports as you suggested and 9007 is unique. I also updated my post with result of wget -S. – ke3pup Jan 28 '12 at 05:20
  • Can you access the content if physically coming from the same server (e.g. running `wget` from localhost)? Maybe you have got some firewall which is blocking the access to all ports? – mindas Jan 28 '12 at 16:00
  • Hi @mindas - Thanks for trying to help- The above wget -S result i posted first was from localhost (Same server) which shows all is well so it might have confused people. The result from computer i am trying is also now updated in the question. Would you point your finger at the firewall for being the issue ? – ke3pup Jan 30 '12 at 06:37
  • Yes, this is the most likely. If you're running on Linux, `iptables -L -v -n` (from root shell) would probably show the cause. Or you might have your outgoing connections (from remote desktop) firewalled, but this is far less likely. – mindas Jan 30 '12 at 10:12
  • Thanks for the command you mentioned, it clears things up - I updated my answer with the result of your command. Please check – ke3pup Jan 30 '12 at 22:42
  • And Confirmed - @mindas You get the credit for mentioning the iptables command . I modified the iptables file and all is well now. thank you. IF you like you can put your comment as an answer and i will marked it as such. Thanks – ke3pup Jan 30 '12 at 23:36
  • Just posted the answer, thanks. By the way, technically this question is off-topic and probably belongs to superuser.com (which is more related to system administration rather than programming). – mindas Jan 31 '12 at 09:55

1 Answers1

1

Turns out this was a firewall issue which was blocking the incoming connections. iptables -L -v -n (on Linux) has helped to reveal the actual problem. See comments under the article for more details.

mindas
  • 26,463
  • 15
  • 97
  • 154