Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Tomcat Native breaks Tomcat
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
SwordAngel
n00b
n00b


Joined: 31 Jul 2008
Posts: 1
Location: Hong Kong

PostPosted: Thu Jul 31, 2008 3:27 pm    Post subject: Tomcat Native breaks Tomcat Reply with quote

Hi guys,

I have the following packages emerged:

  • www-servers/tomcat (6.0.16)
  • dev-java/sun-jdk (1.6.0.05)
  • dev-java/tomcat-servlet-api (6.0.16)
  • dev-libs/apr (1.2.11)
  • dev-libs/apr-util (1.2.10)
  • dev-libs/openssl (0.9.8g)


I wanted to use Tomcat Native for improved performance and OpenSSL. However, as soon as I emerge dev-java/tomcat-native (1.1.13-r1), Tomcat stops working. I can start and stop Tomcat without error, using /etc/init.d/tomcat-6, as shown in the following catalina log output:
Code:
Jul 31, 2008 11:13:31 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.13.
Jul 31, 2008 11:13:31 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].


However, when I try to access the server through the web browser, I get connection refused instead of the web page I expect.

There is absolutly no rule in my iptables, as the following output of "iptables --list" demonstrates:
Code:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination


"netstat -pane --tcp" reveals that Tomcat has stopped listening on 8080 altogether:
Code:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name
tcp        0      0 0.0.0.0:20000           0.0.0.0:*               LISTEN      0          7829       6801/perl
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      0          7696       6673/smbd
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN      0          8046       6915/perl
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      0          7695       6673/smbd
tcp        0      0 :::80                   :::*                    LISTEN      0          7469       1281/apache2
tcp        0      0 :::22                   :::*                    LISTEN      0          7361       6560/sshd
tcp        0      0 :::443                  :::*                    LISTEN      0          7464       1281/apache2
tcp        0      0 ::ffff:127.0.0.1:24572  ::ffff:127.0.0.1:8080   TIME_WAIT   0          0          -
tcp        0    972 ::ffff:192.168.168.5:22 ::ffff:192.168.168:1635 ESTABLISHED 0          75588      2969/0


So here is my server.xml:
Code:
<?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="c31b193991091fd">

  <!--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" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- 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"
               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"
               sslProtocol="TLS" SSLCertificateFile="/root/host.crt"
               SSLCertificateKeyFile="/root/host.pem" />


    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <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="Standalone" 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"/>
      -->

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

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

        <!-- 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 -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

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


And my /etc/conf.d/tomcat-6:
Code:
# $Header: /var/cvsroot/gentoo-x86/www-servers/tomcat/files/6/tomcat.conf,v 1.4 2007/05/31 23:01:57 wltjr Exp $

# JVM Runtime
# Using the default setting, it will determine your JVM from the system-vm
# set using java-config.
# See java-config(1) manual page for assistance in determining this value.
#
# You can override this value with whatever path you wish.
# Example: export GENTOO_VM="sun-jdk-1.6"

#export GENTOO_VM="sun-jdk-1.6"

# (Optional) Java runtime options used when the "start", "stop", or "run"
# commands are executed.
# Example to set library path for tomcat-native
# JAVA_OPTS="-Djava.library.path=/usr/lib"
# JAVA_OPTS=""

# Where your web applications are located
CATALINA_HOME=/usr/share/tomcat-6/
CATALINA_BASE=/var/lib/tomcat-6/

# Tomcat's User/Group
# Change these at your own risk!!! These are not supported so if it
# breaks something, you are on your own.
CATALINA_USER=tomcat
CATALINA_GROUP=tomcat

# Location of the Tomcat JARs and classes
CATALINA_LIBDIR=/usr/share/tomcat-6/lib/

# The CLASSPATH for Tomcat to use, plus any others you need.
CLASSPATH=${CATALINA_LIBDIR}

# (Optional) Directory path location of temporary directory the JVM should
# use (java.io.tmpdir).  Defaults to $CATALINA_BASE/temp.
CATALINA_TMPDIR="/var/tmp/tomcat-6/"

# TOMCAT STARTUP/SHUTDOWN
#       debug             Start Catalina in a debugger
#       -security debug   Debug Catalina with a security manager
#       jpda start        Start Catalina under JPDA debugger
#       start             Start Catalina in a separate window
#       -security start   Start in a separate window with security manager
#       stop              Stop Catalina"
#
# NOTE: -security requires JSSE (see below)
# NOTE: jpda requires JPDA (see below)
TOMCAT_START="start"
TOMCAT_STOP="stop"

# (Optional) Java runtime options used when the "start", "stop", or "run"
# commands are executed.
# CATALINA_OPTS="-Djava.library.path=/usr/lib"

# Java Platform Debugger Architecture (JPDA)
# http://java.sun.com/products/jpda/
# Included with Java SDK 1.3 and later.  No need to specify location.
#
#   JPDA_TRANSPORT  (Optional) JPDA transport used when the "jpda start"
#                   command is executed. The default is "dt_socket".
#
#   JPDA_ADDRESS    (Optional) Java runtime options used when the "jpda start"
#                   command is executed. The default is 8000.
#
# JPDA_TRANSPORT="dt_socket"
# JPDA_ADDRESS="8000"

# Java Secure Socket Extension (JSSE)
# http://java.sun.com/products/jsse/
# Included with Java SDK 1.4 and later.
#
#   JSSE_HOME       (Optional) May point at your Java Secure Sockets Extension
#                   (JSSE) installation, whose JAR files will be added to the
#                   system class path used to start Tomcat.
#
# JSSE_HOME="/opt/sun-jdk-1.6.0.05/jre/lib/"


Does anybody know what's going on? I have been trying to make this work since two days ago.

Update
It looks like Tomcat was simply taking its sweet sweet time to startup, get initialised, and bind to the ports. Still, if Tomcat actually took so long to start, then the /etc/init.d/tomcat-6 should not have displayed success messages and exited so quickly; it's very misleading. Port 8080 works once again. The Catalina log still shows some anomaly and I'll try again to fix them myself before asking for help here.
Back to top
View user's profile Send private message
hoyanf
Tux's lil' helper
Tux's lil' helper


Joined: 27 Aug 2005
Posts: 80
Location: Malaysia

PostPosted: Sat Oct 25, 2008 7:57 pm    Post subject: Reply with quote

I'm no expert but you could try to re-emerge tomcat again


Regards,
hoyanf :D
_________________
WorkPC -> Xeon x3440 | Gigabyte P55-UD6 | 16GB DDR3 | HDD1 - 600GB | HDD2 - 500 GB | HDD3 - 1TB
HomePC -> Xeon x3320 | Gigabyte GA-EP45-UD3P | 8GB DDR2 | HDD1 - 500GB | HDD2 - 1TB
Back to top
View user's profile Send private message
mieses
Tux's lil' helper
Tux's lil' helper


Joined: 28 Feb 2004
Posts: 110

PostPosted: Thu Nov 13, 2008 6:37 am    Post subject: Reply with quote

re-emerge dev-libs/apr with the 'urandom' USE flag.

it might be the issue described here:
https://bugs.gentoo.org/show_bug.cgi?id=198223#c17
Back to top
View user's profile Send private message
hoyanf
Tux's lil' helper
Tux's lil' helper


Joined: 27 Aug 2005
Posts: 80
Location: Malaysia

PostPosted: Thu Nov 13, 2008 7:22 am    Post subject: Reply with quote

That should work...

emerge tomcat-native


Regards,
hoyanf
_________________
WorkPC -> Xeon x3440 | Gigabyte P55-UD6 | 16GB DDR3 | HDD1 - 600GB | HDD2 - 500 GB | HDD3 - 1TB
HomePC -> Xeon x3320 | Gigabyte GA-EP45-UD3P | 8GB DDR2 | HDD1 - 500GB | HDD2 - 1TB
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum