Same tomcat version, but different behavior, why?

时间:2018-03-25 20:51:00

标签: java docker tomcat tomcat7

I need to migrate one Tomcat app to a docker image.

I am using the same version of tomcat and java:

Instance:

Using CATALINA_BASE:   /services/app
Using CATALINA_HOME:   /fr/third-party/tomcat-7.0.47
Using CATALINA_TMPDIR: /services/app/temp
Using JRE_HOME:        /fr/third-party/jdk1.8.0_66/jre
Using CLASSPATH:       /fr/third-party/tomcat- 
7.0.47/bin/bootstrap.jar:/services/app/bin/tomcat-juli.jar
Using CATALINA_PID:    /services/app/bin/app.pid
Server version: Apache Tomcat/7.0.47
Server built:   Oct 18 2013 01:07:38
Server number:  7.0.47.0
OS Name:        Linux
OS Version:     3.10.0-514.6.1.el7.x86_64
Architecture:   amd64
JVM Version:    1.8.0_66-b17
JVM Vendor:     Oracle Corporation

Container:

Using CATALINA_BASE:   /services/app
Using CATALINA_HOME:   /fr/third-party/tomcat-7.0.47
Using CATALINA_TMPDIR: /services/app/temp
Using JRE_HOME:        /fr/third-party/jdk1.8.0_66/jre
Using CLASSPATH:       /fr/third-party/tomcat- 
7.0.47/bin/bootstrap.jar:/services/app/bin/tomcat-juli.jar
Using CATALINA_PID:    /services/app/bin/app.pid
Server version: Apache Tomcat/7.0.47
Server built:   Oct 18 2013 01:07:38
Server number:  7.0.47.0
OS Name:        Linux
OS Version:     4.14.0-041400-generic
Architecture:   amd64
JVM Version:    1.8.0_66-b17
JVM Vendor:     Oracle Corporation

But my thread connection, for example, are different:

Instance:

[INFO ] [2018-03-25 13:46:37,781] [http-bio-40202-exec-157]

Container

[INFO ] [2018-03-25 13:47:01,928] [http-apr-40202-exec-8]

What have I forgotten to copy? It should be the same, right?

1 个答案:

答案 0 :(得分:2)

It means that in one place you have Apache APR installed, which Tomcat picks up automagically at startup using the APR Listener.

This happens because you have the connector protocol set at to HTTP/1.1 which allows tomcat to select the best protocol it can.

To force BIO use org.apache.coyote.http11.Http11Protocol or to force APR use org.apache.coyote.http11.Http11AprProtocol - note that APR will not work unless the native APR library is installed and on the load library path.

Note that BIO is the old, blocking, HTTP connector and is very slow and resource intensive - it would be better to use the newer NIO connector org.apache.coyote.http11.Http11NioProtocol.


Finally, Tomcat 7 is really rather antiquated - I would suggest moving to Tomcat 9.