# Tomcat 5.0.27-r4: veeeery slow startup

## moldarion

Hello all,

I am running tomcat-5.0.27-r4 with sun-jdk-1.4.2.07 and the startup time is always more than 3 minutes! Everything works fine excpet this very long time to start the service. Here's my catalina.out:

```
Mar 7, 2005 11:42:27 AM org.apache.coyote.http11.Http11Protocol init

INFO: Initializing Coyote HTTP/1.1 on http-8080

Mar 7, 2005 11:42:27 AM org.apache.coyote.http11.Http11Protocol init

INFO: Initializing Coyote HTTP/1.1 on http-8082

Mar 7, 2005 11:42:27 AM org.apache.catalina.startup.Catalina load

INFO: Initialization processed in 190909 ms

Mar 7, 2005 11:42:27 AM org.apache.catalina.core.StandardService start

INFO: Starting service Catalina

Mar 7, 2005 11:42:27 AM org.apache.catalina.core.StandardEngine start

INFO: Starting Servlet Engine: Apache Tomcat/5.0.27

Mar 7, 2005 11:42:27 AM org.apache.catalina.core.StandardHost start

INFO: XML validation disabled

Mar 7, 2005 11:42:27 AM org.apache.catalina.core.StandardHost getDeployer

INFO: Create Host deployer for direct deployment ( non-jmx )

Mar 7, 2005 11:42:27 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Processing Context configuration file URL file:/etc/tomcat5/Catalina/localhost/admin.xml

Mar 7, 2005 11:42:29 AM org.apache.struts.util.PropertyMessageResources <init>

INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true

Mar 7, 2005 11:42:29 AM org.apache.struts.util.PropertyMessageResources <init>

INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNull=true

Mar 7, 2005 11:42:29 AM org.apache.struts.util.PropertyMessageResources <init>

INFO: Initializing, config='org.apache.webapp.admin.ApplicationResources', returnNull=true

Mar 7, 2005 11:42:31 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Processing Context configuration file URL file:/etc/tomcat5/Catalina/localhost/balancer.xml

Mar 7, 2005 11:42:31 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Processing Context configuration file URL file:/etc/tomcat5/Catalina/localhost/manager.xml

Mar 7, 2005 11:42:31 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path  from URL file:/opt/tomcat5/webapps/ROOT

Mar 7, 2005 11:42:32 AM org.apache.catalina.core.StandardHostDeployer install

INFO: Installing web application at context path /webdav from URL file:/opt/tomcat5/webapps/webdav

Mar 7, 2005 11:42:32 AM org.apache.coyote.http11.Http11Protocol start

INFO: Starting Coyote HTTP/1.1 on http-8080

Mar 7, 2005 11:42:32 AM org.apache.jk.common.ChannelSocket init

INFO: JK2: ajp13 listening on /0.0.0.0:8009

Mar 7, 2005 11:42:32 AM org.apache.jk.server.JkMain start

INFO: Jk running ID=0 time=13/32  config=/opt/tomcat5/conf/jk2.properties

Mar 7, 2005 11:42:32 AM org.apache.coyote.http11.Http11Protocol start

INFO: Starting Coyote HTTP/1.1 on http-8082

Mar 7, 2005 11:42:32 AM org.apache.catalina.startup.Catalina start

INFO: Server startup in 5247 ms

```

Notice the following line:

```
Mar 7, 2005 11:42:27 AM org.apache.catalina.startup.Catalina load

INFO: Initialization processed in 190909 ms

```

That's way too long for my taste (and my long experiences with Tomcat on different Windows and Linux machines)!

Starting the service using the JVM option "-verbose" in /etc/conf.d/tomcat5 let's me spot where most of the startup time is being wasted (somewhat stripped output of catalina.out):

```
...

[Loaded org.apache.coyote.http11.Http11Protocol]

[Loaded org.apache.tomcat.util.threads.ThreadPool$ThreadPoolListener]

[Loaded org.apache.tomcat.util.net.TcpConnectionHandler]

[Loaded org.apache.tomcat.util.threads.ThreadPool]

[Loaded org.apache.tomcat.util.net.PoolTcpEndpoint]

[Loaded java.io.InterruptedIOException from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded org.apache.tomcat.util.threads.ThreadPoolRunnable]

[Loaded java.net.SocketException from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.net.BindException from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler]

[Loaded org.apache.coyote.ActionHook]

[Loaded org.apache.coyote.RequestGroupInfo]

[Loaded org.apache.tomcat.util.net.ServerSocketFactory]

[Loaded org.apache.tomcat.util.net.DefaultServerSocketFactory]

[Loaded java.net.ServerSocket from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.net.SocketOptions from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.net.SocketImpl from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.net.PlainSocketImpl from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

```

Here the output stalls for said 3 minutes and later continues normally with the following output:

```
[Loaded java.net.SocketAddress from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.net.InetSocketAddress from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.logging.LogRecord from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.logging.LogManager$5 from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.logging.StreamHandler from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.logging.ConsoleHandler from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.logging.ErrorManager from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.logging.Formatter from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.logging.SimpleFormatter from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.DateFormat from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.SimpleDateFormat from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.AttributedCharacterIterator$Attribute from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.Format$Field from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.DateFormat$Field from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.AttributedCharacterIterator$1 from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.text.resources.LocaleData from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.text.resources.LocaleData$1 from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.ListResourceBundle from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.text.resources.LocaleElements from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.text.resources.LocaleElements_en from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.text.resources.LocaleElements_en_US from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.DateFormatSymbols from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.text.resources.DateFormatZoneData from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.text.resources.DateFormatZoneData_en from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.text.resources.DateFormatZoneData$1 from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.TimeZone from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.util.calendar.ZoneInfo from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.util.calendar.ZoneInfoFile from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.util.calendar.ZoneInfoFile$1 from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.TimeZone$1 from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.Calendar from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.GregorianCalendar from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.NumberFormat from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.DecimalFormatSymbols from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.Currency from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.Currency$1 from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.util.CurrencyData from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.reflect.UnsafeFieldAccessorFactory from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.reflect.UnsafeStaticFieldAccessorImpl from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.reflect.UnsafeStaticObjectFieldAccessorImpl from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.DecimalFormat from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.FieldPosition from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.DigitList from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.ChoiceFormat from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.Format$FieldDelegate from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded java.text.FieldPosition$Delegate from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded sun.util.logging.resources.logging from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

Mar 7, 2005 11:02:35 AM org.apache.coyote.http11.Http11Protocol init

INFO: Initializing Coyote HTTP/1.1 on http-8080

[Loaded org.apache.jk.core.JkHandler]

[Loaded org.apache.coyote.OutputBuffer]

[Loaded org.apache.coyote.InputBuffer]

[Loaded org.apache.jk.server.JkCoyoteHandler]

[Loaded org.apache.jk.core.Msg]

[Loaded org.apache.jk.common.MsgAjp]

[Loaded java.security.cert.CertificateException from /opt/sun-jdk-1.4.2.07/jre/lib/rt.jar]

[Loaded org.apache.jk.core.MsgContext]

[Loaded org.apache.coyote.ActionCode]

[Loaded org.apache.jk.server.JkMain]

[Loaded org.apache.tomcat.util.buf.ByteChunk]

[Loaded org.apache.coyote.Response]

[Loaded org.apache.coyote.Request]

[Loaded org.apache.jk.core.WorkerEnv]

Mar 7, 2005 11:02:35 AM org.apache.coyote.http11.Http11Protocol init

INFO: Initializing Coyote HTTP/1.1 on http-8082

Mar 7, 2005 11:02:35 AM org.apache.catalina.startup.Catalina load

INFO: Initialization processed in 191341 ms

...

```

From my understanding of this log output the Tomcat service tries to open some TCP socket (apparently the HTTP Connector Port 8080) which takes so painstaking long. Any ideas why this is happening or how to circumvent this behaviour?

TIA!

----------

## krapo

I had the same problem with www-servers/tomcat-5.0.27-r6 and 5.5.12 (manual install)

Tried with both sun-jdk-1.4.2.09 and un-jdk-1.5.05...

Tried to change the default listen port...

Can't find a solution  :Sad: 

----------

## krapo

I've blocked ipv6 support by editing JAVA_OPTS in /etc/conf.d/tomcat5

```
JAVA_OPTS="-Djava.net.preferIPv4Stack=true -verbose"
```

 and now...

```
12 nov. 2005 23:18:38 org.apache.catalina.startup.Catalina load

INFO: Initialization processed in 1145 ms
```

...it works fast   :Wink: 

don't know why java.net.PlainSocketImpl messed with ipv6

----------

## redoverlord

Followed those steps and it does work

initially: 

18:09:36,026  INFO Catalina:563 - Server startup in 10306 ms

after the change:

15:26:43,701  INFO Catalina:563 - Server startup in 7774 ms

redoverlord

http://www.sunbowtech.com

java and tomcat

----------

