Oracle Fusion Middleware/Coherence

8장. Tomcat - Coherence 세션 그리드 서비스

수상한 김토끼 2023. 3. 16. 19:25

안녕하세요.

'수상한 김토끼' 입니다.

5장과 6장의 WebLogic - Coherence 세션 그리드 서비스를 통해 같은 Oracle 제품인 WebLogic에 Coherence-Web을 적용하는 방법을 확인 해 보았습니다.

8장에서는 오픈소스로 가장 많은 점유율을 가지고 있는 Tomcat - Coherence 세션 그리드 서비스를 구성해 보고

알아가는 시간을 갖도록 하겠습니다.

 

6장에서 진행한 Coherence 설치 및 설정 부분과 JDK는 동일하게 사용되므로 이번 장에서는 다루지 않겠습니다.

 

이번 장 진행에 참고한 Oracle 공식 문서입니다.

https://docs.oracle.com/en/middleware/standalone/coherence/14.1.1.0/administer-http-sessions/using-coherenceweb-other-application-servers.html#GUID-200A06F4-E7E4-4209-B0CB-FD40DE2C361F

 

Administering HTTP Session Management with Oracle Coherence*Web

You can configure and deploy Coherence*Web, the session state persistence and management module, for use with a variety of application servers.

docs.oracle.com

진행에 문제가 있거나 추가적인 내용은 위 문서를 참조해 주세요.

 

이 블로그 글은 미들웨어 경험이 없으신 분들도 쉽게 따라 하실 수 있도록 쉽게 작성하는 것이 목표입니다.

설명을 보고 진행하시다가 궁금하신 내용은 댓글로 문의하시면 가능한 범위 내에서 알려 드리도록 하겠습니다.


1. Tomcat 설치

Tomcat - Coherence 세션 그리드 서비스를 구현하기 위해 가장 먼저 Tomcat을 설치해야 합니다.

Tomcat 공식 홈페이지에서 Tomcat 8.5를 다운로드 받아 줍니다.

 

https://tomcat.apache.org/download-80.cgi

 

Apache Tomcat® - Apache Tomcat 8 Software Downloads

Welcome to the Apache Tomcat® 8.x software download page. This page provides download links for obtaining the latest versions of Tomcat 8.x software, as well as links to the archives of older releases. Unsure which version you need? Specification versions

tomcat.apache.org

 

세션 클러스터 구성을 위해 다운로드 받은 Tomcat Binary 파일의 압축을 푼 후에 2개의 서로 다른 경로에 풀어줍니다.

 

예제에서는 apache-tomcat-8.5.87_1st, apache-tomcat-8.5.87_2nd 2개의 경로에 Tomcat을 설치했습니다.

1
2
3
4
5
6
7
8
[tomcat@coherence ~]$ pwd
/home/tomcat
[tomcat@coherence ~]$ ll
total 0
drwxrwxr-x. 9 tomcat tomcat 220 Mar 16 14:59 apache-tomcat-8.5.87_1st
drwxrwxr-x. 9 tomcat tomcat 220 Mar 16 14:59 apache-tomcat-8.5.87_2nd
drwxrwxr-x. 3 tomcat tomcat 257 Mar 16 16:12 downloads
drwxr-xr-x. 8 tomcat tomcat 273 Dec 16  2021 jdk1.8.0_321
cs
 
하나의 서버에 2개의 Tomcat을 구성함으로 port 번호를 분리하여 Tomcat 2개가 구동될 수 있도록 $CATALINA_HOME/conf/server.xml 파일을 수정해 줍니다.
apache-tomcat-8.5.87_1st은 기본 포트에 10000을 더해서 18080과 같이 변경해 줍니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="UTF-8"?>
 
<Server port="18005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
 
  <GlobalNamingResources>
    <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>
 
  <Service name="Catalina">
 
    <Connector port="18080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="18443" />
 
      <Realm className="org.apache.catalina.realm.LockOutRealm">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
 
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
 
        <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>
cs

 

apache-tomcat-8.5.87_2nd는 기본 포트에 20000을 더해서 28080과 같이 변경해 줍니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="UTF-8"?>
 
<Server port="28005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
 
  <GlobalNamingResources>
    <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>
 
  <Service name="Catalina">
 
    <Connector port="28080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="28443" />
 
      <Realm className="org.apache.catalina.realm.LockOutRealm">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
 
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
 
        <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>
cs

Tomcat 설치 및 설정이 완료 되었습니다.


2. Tomcat 세션 클러스터링 설정

Tomcat의 세션 설정을 클러스터링이 가능하도록 변경해 줍니다.

 

Coherence를 사용해 세션 클러스터를 구성하지만 Tomcat에서도 세션저장 방식 변경이 되어야 Coherence에서 세션을 관리하도록 구성할 수 있습니다.

 

Tomcat 세션 클러스터링을 설명하고 있는 Tomcat 공식 문서입니다.

https://tomcat.apache.org/connectors-doc/reference/workers.html

 

The Apache Tomcat Connectors - Reference Guide (1.2.48) - workers.properties configuration

This table lists more advanced configuration options. Most of them only apply to some types of workers. We use the abbreviations AJP for ajp13/ajp14 workers used directly via the workers.list, LB for load balancer workers, and SUB for the workers used indi

tomcat.apache.org

 

SimpleTcpCluster 적용

$CATALINA_HOME/conf/server.xml 파일에 SimpleTcpCluster를 설정합니다.

 

다음 내용을 Server.xml 파일에 추가하는 것으로 설정이 가능합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="8">
 
          <Manager className="org.apache.catalina.ha.session.DeltaManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"/>
            
            <!-- 멀티캐스트 포트(45564) 필요에 따라 변경 -->
          <Channel className="org.apache.catalina.tribes.group.GroupChannel">
            <Membership className="org.apache.catalina.tribes.membership.McastService"
                        address="228.0.0.4"
                        port="45564"
                        frequency="500"
                        dropTime="3000"/>
            <!-- replication 메시지 수신 포트는 4000 - 4100 사이 -->
            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="auto"
                      port="4000"
                      autoBind="100"
                      selectorTimeout="5000"
                      maxThreads="6"/>
 
            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
            </Sender>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
            <!-- Tomcat 7 버전 이하 -->
            <!-- <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/> -->
            <!-- Tomcat 8 버전 이상 -->
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor"/>
          </Channel>
 
          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
                 filter=""/>
          <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
            
          <!-- war 를 하나에 반영하면 클러스터에 자동으로 배포되는 FarmWarDeployer 기능시에만 필요
          <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
                    tempDir="/tmp/war-temp/"
                    deployDir="/tmp/war-deploy/"
                    watchDir="/tmp/war-listen/"
                    watchEnabled="false"/>
            -->
 
          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
cs

30번째 라인의 'MessageDispatch15Interceptor' 클래스는 Tomcat 버전에 따라 클래스명이 달라집니다.

예제에서는 Tomcat 8.5가 사용되었음으로 MessageDispatchInterceptor 클래스를 적용하였습니다.

*Tomcat 8, 9버전의 경우 위 설정에서 30번째 라인의 MessageDispatch15Interceptor 부분 MessageDispatchInterceptor 로 수정해주면 동일하게 동작합니다. 수정하지 않을 경우 catalina.out 로그에 java.lang.ClassNotFoundException 에러가 발생합니다.

 

distributable 적용

클러스터링이 가능하도록 Application의 web.xml에 다음 element를 추가 해 줍니다.

1
<distributable/>
cs

적용이 완료된 apache-tomcat-8.5.87_1st의 server.xml 과 web.xml 파일을 올려드립니다.

apache-tomcat-8.5.87_2nd도 동일하게 구성되어 있습니다.

 

server.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?xml version="1.0" encoding="UTF-8"?>
 
<Server port="18005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
 
  <GlobalNamingResources>
 
    <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>
 
  <Service name="Catalina">
 
    <Connector port="18080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="18443" />
 
    <Engine name="Catalina" defaultHost="localhost">
 
 
 <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="8">
 
          <Manager className="org.apache.catalina.ha.session.DeltaManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"/>
 
  
          <Channel className="org.apache.catalina.tribes.group.GroupChannel">
            <Membership className="org.apache.catalina.tribes.membership.McastService"
                        address="228.0.0.4"
                        port="45564"
                        frequency="500"
                        dropTime="3000"/>
 
            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="auto"
                      port="4000"
                      autoBind="100"
                      selectorTimeout="5000"
                      maxThreads="6"/>
 
            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
            </Sender>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor"/>
          </Channel>
 
          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
                 filter=""/>
          <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
 
 
          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
        </Cluster>
 
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
 
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
 
            <Context path="/" docBase="Lab6A"  reloadable="false" />
 
        <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>
cs

73번째 줄의 <Context path="/" docBase="Lab6A"  reloadable="false" />는 Session Test를 위해 배포한 Application(war)파일 입니다.

 

web.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Lab6A</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <distributable/>
</web-app>
cs

Tomcat 세션 클러스터 설정이 마무리 되었습니다. 


3. Application Coherence Tomcat 세션 클러스터링 설정

Coherence 세션 클러스터를 적용하기 위해 Application(war)에도 Coherence-Web 관련 설정 추가가 필요합니다.

 

관련 내용이 정리된 Oracle 공식 문서입니다.

https://docs.oracle.com/en/middleware/standalone/coherence/14.1.1.0/administer-http-sessions/using-coherenceweb-other-application-servers.html#GUID-DA8485B0-A4C0-43E5-A303-8D73AB71ED2D

 

Administering HTTP Session Management with Oracle Coherence*Web

You can configure and deploy Coherence*Web, the session state persistence and management module, for use with a variety of application servers.

docs.oracle.com

기존 Application(war)에 Coherence-web 적용을 위해서는 다음 3가지 단계의 작업이 필요합니다.

 

1. Coherence.jar, Coherence-web.jar 파일 Tomcat 라이브러리 추가

Tomcat에서 Coherence-web관련 클래스를 사용하기 위해서 세션 저장소로 사용될 $COHERENCE_HOME/lib 폴더에서 Coherence.jar, Coherence-web.jar 파일을 $CATALINA_HOME/lib 아래 경로에 복사 해 줍니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[tomcat@coherence lib]$ pwd
/home/tomcat/apache-tomcat-8.5.87_1st/lib
[tomcat@coherence lib]$ ll
total 22452
-rw-r-----1 tomcat tomcat    12356 Feb 28 04:32 annotations-api.jar
-rw-r-----1 tomcat tomcat    54229 Feb 28 04:32 catalina-ant.jar
-rw-r-----1 tomcat tomcat   121872 Feb 28 04:32 catalina-ha.jar
-rw-r-----1 tomcat tomcat  1732270 Feb 28 04:32 catalina.jar
-rw-r-----1 tomcat tomcat    77608 Feb 28 04:32 catalina-storeconfig.jar
-rw-r-----1 tomcat tomcat   294161 Feb 28 04:32 catalina-tribes.jar
-rw-r-----1 tomcat tomcat 13763107 Mar 16 16:00 coherence.jar
-rw-r-----1 tomcat tomcat   241893 Mar 16 16:00 coherence-web.jar
-rw-r-----1 tomcat tomcat  2450404 Feb 28 04:32 ecj-4.6.3.jar
-rw-r-----1 tomcat tomcat    88641 Feb 28 04:32 el-api.jar
-rw-r-----1 tomcat tomcat   171001 Feb 28 04:32 jasper-el.jar
-rw-r-----1 tomcat tomcat   603195 Feb 28 04:32 jasper.jar
-rw-r-----1 tomcat tomcat    26800 Feb 28 04:32 jaspic-api.jar
-rw-r-----1 tomcat tomcat    61919 Feb 28 04:32 jsp-api.jar
-rw-r-----1 tomcat tomcat   249372 Feb 28 04:32 servlet-api.jar
-rw-r-----1 tomcat tomcat    10650 Feb 28 04:32 tomcat-api.jar
-rw-r-----1 tomcat tomcat   894061 Feb 28 04:32 tomcat-coyote.jar
-rw-r-----1 tomcat tomcat   285969 Feb 28 04:32 tomcat-dbcp.jar
-rw-r-----1 tomcat tomcat    76587 Feb 28 04:32 tomcat-i18n-de.jar
-rw-r-----1 tomcat tomcat   106340 Feb 28 04:32 tomcat-i18n-es.jar
-rw-r-----1 tomcat tomcat   160930 Feb 28 04:32 tomcat-i18n-fr.jar
-rw-r-----1 tomcat tomcat   181636 Feb 28 04:32 tomcat-i18n-ja.jar
-rw-r-----1 tomcat tomcat   180804 Feb 28 04:32 tomcat-i18n-ko.jar
-rw-r-----1 tomcat tomcat    48429 Feb 28 04:32 tomcat-i18n-ru.jar
-rw-r-----1 tomcat tomcat   165172 Feb 28 04:32 tomcat-i18n-zh-CN.jar
-rw-r-----1 tomcat tomcat   149082 Feb 28 04:32 tomcat-jdbc.jar
-rw-r-----1 tomcat tomcat    36411 Feb 28 04:32 tomcat-jni.jar
-rw-r-----1 tomcat tomcat   191493 Feb 28 04:32 tomcat-util.jar
-rw-r-----1 tomcat tomcat   215504 Feb 28 04:32 tomcat-util-scan.jar
-rw-r-----1 tomcat tomcat   240486 Feb 28 04:32 tomcat-websocket.jar
-rw-r-----1 tomcat tomcat    38450 Feb 28 04:32 websocket-api.jar
cs

 

2. Coherence-web 관련 설정 Tomcat JAVA_OPTS 추가

6장. WebLogic - Coherence 세션 그리드 서비스 2의 4번째 항목인 cache-server.sh 파일 수정에 사용된 내용을

%CATALINA_HOME/bin/catalina.sh 파일 내부의 JAVA_OPTS에 추가 해 줍니다.

 

추가할 내용

Coherence-web을 사용하여 Tomcat 세션 클러스터링을 구성하기 위해서는 JAVA_OPTS 부분에 대한 수정이 필요하며,
추가 항목은 다음과 같습니다.

1
2
3
4
5
6
7
JAVA_OPTS="$JAVA_OPTS -Dcoherence.cacheconfig=default-session-cache-config.xml"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.session.localstorage=true"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.cluster=my_cluster"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.clusteraddress=224.2.1.2"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.clusterport=14199"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.ttl=1"
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true "
cs

 

추가가 완료된 catalina.sh 파일을 올려 드립니다.

catalina.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
#!/bin/sh
 
# OS specific support.  $var _must_ be set to either true or false.
cygwin=false
darwin=false
os400=false
hpux=false
case "`uname`" in
CYGWIN*) cygwin=true;;
Darwin*) darwin=true;;
OS400*) os400=true;;
HP-UX*) hpux=true;;
esac
 
# resolve links - $0 may be a softlink
PRG="$0"
 
while [ -"$PRG" ]; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done
 
# Get standard environment variables
PRGDIR=`dirname "$PRG"`
 
# Only set CATALINA_HOME if not already set
-"$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
 
# Copy CATALINA_BASE from CATALINA_HOME if not already set
-"$CATALINA_BASE" ] && CATALINA_BASE="$CATALINA_HOME"
 
# Ensure that any user defined CLASSPATH variables are not used on startup,
# but allow them to be specified in setenv.sh, in rare case when it is needed.
CLASSPATH=
 
if [ -"$CATALINA_BASE/bin/setenv.sh" ]; then
  . "$CATALINA_BASE/bin/setenv.sh"
elif [ -"$CATALINA_HOME/bin/setenv.sh" ]; then
  . "$CATALINA_HOME/bin/setenv.sh"
fi
 
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin; then
  [ -"$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  [ -"$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"`
  [ -"$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"`
  [ -"$CATALINA_BASE" ] && CATALINA_BASE=`cygpath --unix "$CATALINA_BASE"`
  [ -"$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
 
# Ensure that neither CATALINA_HOME nor CATALINA_BASE contains a colon
# as this is used as the separator in the classpath and Java provides no
# mechanism for escaping if the same character appears in the path.
case $CATALINA_HOME in
  *:*echo "Using CATALINA_HOME:   $CATALINA_HOME";
       echo "Unable to start as CATALINA_HOME contains a colon (:) character";
       exit 1;
esac
case $CATALINA_BASE in
  *:*echo "Using CATALINA_BASE:   $CATALINA_BASE";
       echo "Unable to start as CATALINA_BASE contains a colon (:) character";
       exit 1;
esac
 
# For OS400
if $os400; then
  # Set job priority to standard for interactive (interactive - 6) by using
  # the interactive priority - 6, the helper threads that respond to requests
  # will be running at the same priority as interactive jobs.
  COMMAND='chgjob job('$JOBNAME') runpty(6)'
  system $COMMAND
 
  # Enable multi threading
  export QIBM_MULTI_THREADED=Y
fi
 
# Get standard Java environment variables
if $os400; then
  # -r will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  . "$CATALINA_HOME"/bin/setclasspath.sh
else
  if [ -"$CATALINA_HOME"/bin/setclasspath.sh ]; then
    . "$CATALINA_HOME"/bin/setclasspath.sh
  else
    echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
    echo "This file is needed to run this program"
    exit 1
  fi
fi
 
# Add on extra jar files to CLASSPATH
if [ ! -"$CLASSPATH" ] ; then
  CLASSPATH="$CLASSPATH":
fi
CLASSPATH="$CLASSPATH""$CATALINA_HOME"/bin/bootstrap.jar
 
if [ -"$CATALINA_OUT" ] ; then
  CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi
 
if [ -"$CATALINA_TMPDIR" ] ; then
  # Define the java.io.tmpdir to use for Catalina
  CATALINA_TMPDIR="$CATALINA_BASE"/temp
fi
 
# Add tomcat-juli.jar to classpath
# tomcat-juli.jar can be over-ridden per instance
if [ -"$CATALINA_BASE/bin/tomcat-juli.jar" ] ; then
  CLASSPATH=$CLASSPATH:$CATALINA_BASE/bin/tomcat-juli.jar
else
  CLASSPATH=$CLASSPATH:$CATALINA_HOME/bin/tomcat-juli.jar
fi
 
# Bugzilla 37848: When no TTY is available, don't output to console
have_tty=0
if [ -0 ]; then
    have_tty=1
fi
 
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
  JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
  JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"`
  CATALINA_HOME=`cygpath --absolute --windows "$CATALINA_HOME"`
  CATALINA_BASE=`cygpath --absolute --windows "$CATALINA_BASE"`
  CATALINA_TMPDIR=`cygpath --absolute --windows "$CATALINA_TMPDIR"`
  CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
  [ -"$JAVA_ENDORSED_DIRS" ] && JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
fi
 
if [ -"$JSSE_OPTS" ] ; then
  JSSE_OPTS="-Djdk.tls.ephemeralDHKeySize=2048"
fi
JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS"
 
# Register custom URL handlers
# Do this here so custom URL handles (specifically 'war:...') can be used in the security policy
JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources"
 
# Check for the deprecated LOGGING_CONFIG
# Only use it if CATALINA_LOGGING_CONFIG is not set and LOGGING_CONFIG starts with "-D..."
if [ -"$CATALINA_LOGGING_CONFIG" ]; then
  case $LOGGING_CONFIG in
    -D*) CATALINA_LOGGING_CONFIG="$LOGGING_CONFIG"
  esac
fi
 
# Set juli LogManager config file if it is present and an override has not been issued
if [ -"$CATALINA_LOGGING_CONFIG" ]; then
  if [ -"$CATALINA_BASE"/conf/logging.properties ]; then
    CATALINA_LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
  else
    # Bugzilla 45585
    CATALINA_LOGGING_CONFIG="-Dnop"
  fi
fi
 
if [ -"$LOGGING_MANAGER" ]; then
  LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
fi
 
# Set UMASK unless it has been overridden
if [ -"$UMASK" ]; then
    UMASK="0027"
fi
umask $UMASK
 
# Java 9 no longer supports the java.endorsed.dirs
# system property. Only try to use it if
# JAVA_ENDORSED_DIRS was explicitly set
# or CATALINA_HOME/endorsed exists.
ENDORSED_PROP=ignore.endorsed.dirs
if [ -"$JAVA_ENDORSED_DIRS" ]; then
    ENDORSED_PROP=java.endorsed.dirs
fi
if [ -"$CATALINA_HOME/endorsed" ]; then
    ENDORSED_PROP=java.endorsed.dirs
fi
 
# Make the umask available when using the org.apache.catalina.security.SecurityListener
JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.security.SecurityListener.UMASK=`umask`"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.cacheconfig=default-session-cache-config.xml"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.session.localstorage=true"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.cluster=my_cluster"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.clusteraddress=224.2.1.2"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.clusterport=14199"
JAVA_OPTS="$JAVA_OPTS -Dcoherence.ttl=1"
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true "
 
if [ -"$USE_NOHUP" ]; then
    if $hpux; then
        USE_NOHUP="true"
    else
        USE_NOHUP="false"
    fi
fi
unset _NOHUP
if [ "$USE_NOHUP" = "true" ]; then
    _NOHUP="nohup"
fi
 
# Add the JAVA 9 specific start-up parameters required by Tomcat
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.lang=ALL-UNNAMED"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.io=ALL-UNNAMED"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.util=ALL-UNNAMED"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.base/java.util.concurrent=ALL-UNNAMED"
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED"
export JDK_JAVA_OPTIONS
 
# ----- Execute The Requested Command -----------------------------------------
 
# Bugzilla 37848: only output this if we have a TTY
if [ $have_tty -eq 1 ]; then
  echo "Using CATALINA_BASE:   $CATALINA_BASE"
  echo "Using CATALINA_HOME:   $CATALINA_HOME"
  echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
  if [ "$1" = "debug" ] ; then
    echo "Using JAVA_HOME:       $JAVA_HOME"
  else
    echo "Using JRE_HOME:        $JRE_HOME"
  fi
  echo "Using CLASSPATH:       $CLASSPATH"
  echo "Using CATALINA_OPTS:   $CATALINA_OPTS"
  if [ ! -"$CATALINA_PID" ]; then
    echo "Using CATALINA_PID:    $CATALINA_PID"
  fi
fi
 
if [ "$1" = "jpda" ] ; then
  if [ -"$JPDA_TRANSPORT" ]; then
    JPDA_TRANSPORT="dt_socket"
  fi
  if [ -"$JPDA_ADDRESS" ]; then
    JPDA_ADDRESS="localhost:8000"
  fi
  if [ -"$JPDA_SUSPEND" ]; then
    JPDA_SUSPEND="n"
  fi
  if [ -"$JPDA_OPTS" ]; then
    JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
  fi
  CATALINA_OPTS="$JPDA_OPTS $CATALINA_OPTS"
  shift
fi
 
if [ "$1" = "debug" ] ; then
  if $os400; then
    echo "Debug command not available on OS400"
    exit 1
  else
    shift
    if [ "$1" = "-security" ] ; then
      if [ $have_tty -eq 1 ]; then
        echo "Using Security Manager"
      fi
      shift
      eval exec "\"$_RUNJDB\"" "\"$CATALINA_LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
        -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
        -classpath "$CLASSPATH" \
        -sourcepath "$CATALINA_HOME"/../../java \
        -Djava.security.manager \
        -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \
        -Dcatalina.base="$CATALINA_BASE" \
        -Dcatalina.home="$CATALINA_HOME" \
        -Djava.io.tmpdir="$CATALINA_TMPDIR" \
        org.apache.catalina.startup.Bootstrap "$@" start
    else
      eval exec "\"$_RUNJDB\"" "\"$CATALINA_LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
        -D$ENDORSED_PROP="$JAVA_ENDORSED_DIRS" \
        -classpath "$CLASSPATH" \
        -sourcepath "$CATALINA_HOME"/../../java \
        -Dcatalina.base="$CATALINA_BASE" \
        -Dcatalina.home="$CATALINA_HOME" \
        -Djava.io.tmpdir="$CATALINA_TMPDIR" \
        org.apache.catalina.startup.Bootstrap "$@" start
    fi
  fi
 
elif [ "$1" = "run" ]; then
 
  shift
  if [ "$1" = "-security" ] ; then
    if [ $have_tty -eq 1 ]; then
      echo "Using Security Manager"
    fi
    shift
    eval exec "\"$_RUNJAVA\"" "\"$CATALINA_LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
      -classpath "\"$CLASSPATH\"" \
      -Djava.security.manager \
      -Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
      org.apache.catalina.startup.Bootstrap "$@" start
  else
    eval exec "\"$_RUNJAVA\"" "\"$CATALINA_LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
      -classpath "\"$CLASSPATH\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
      org.apache.catalina.startup.Bootstrap "$@" start
  fi
 
elif [ "$1" = "start" ] ; then
 
  if [ ! -"$CATALINA_PID" ]; then
    if [ -"$CATALINA_PID" ]; then
      if [ -"$CATALINA_PID" ]; then
        echo "Existing PID file found during start."
        if [ -"$CATALINA_PID" ]; then
          PID=`cat "$CATALINA_PID"`
          ps -p $PID >/dev/null 2>&1
          if [ $? -eq 0 ] ; then
            echo "Tomcat appears to still be running with PID $PID. Start aborted."
            echo "If the following process is not a Tomcat process, remove the PID file and try again:"
            ps --p $PID
            exit 1
          else
            echo "Removing/clearing stale PID file."
            rm -"$CATALINA_PID" >/dev/null 2>&1
            if [ $? != 0 ]; then
              if [ -"$CATALINA_PID" ]; then
                cat /dev/null > "$CATALINA_PID"
              else
                echo "Unable to remove or clear stale PID file. Start aborted."
                exit 1
              fi
            fi
          fi
        else
          echo "Unable to read PID file. Start aborted."
          exit 1
        fi
      else
        rm -"$CATALINA_PID" >/dev/null 2>&1
        if [ $? != 0 ]; then
          if [ ! -"$CATALINA_PID" ]; then
            echo "Unable to remove or write to empty PID file. Start aborted."
            exit 1
          fi
        fi
      fi
    fi
  fi
 
  shift
  if [ -"$CATALINA_OUT_CMD" ] ; then
    touch "$CATALINA_OUT"
  else
    if [ ! -"$CATALINA_OUT" ]; then
      if ! mkfifo "$CATALINA_OUT"then
        echo "cannot create named pipe $CATALINA_OUT. Start aborted."
        exit 1
      fi
    elif [ ! -"$CATALINA_OUT" ]; then
      echo "$CATALINA_OUT exists and is not a named pipe. Start aborted."
      exit 1
    fi
    $CATALINA_OUT_CMD <"$CATALINA_OUT" &
  fi
  if [ "$1" = "-security" ] ; then
    if [ $have_tty -eq 1 ]; then
      echo "Using Security Manager"
    fi
    shift
    eval $_NOHUP "\"$_RUNJAVA\"" "\"$CATALINA_LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
      -classpath "\"$CLASSPATH\"" \
      -Djava.security.manager \
      -Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
      org.apache.catalina.startup.Bootstrap "$@" start \
      >> "$CATALINA_OUT" 2>&1 "&"
 
  else
    eval $_NOHUP "\"$_RUNJAVA\"" "\"$CATALINA_LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
      -classpath "\"$CLASSPATH\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
      org.apache.catalina.startup.Bootstrap "$@" start \
      >> "$CATALINA_OUT" 2>&1 "&"
 
  fi
 
  if [ ! -"$CATALINA_PID" ]; then
    echo $! > "$CATALINA_PID"
  fi
 
  echo "Tomcat started."
 
elif [ "$1" = "stop" ] ; then
 
  shift
 
  SLEEP=5
  if [ ! -"$1" ]; then
    echo $1 | grep "[^0-9]" >/dev/null 2>&1
    if [ $? -gt 0 ]; then
      SLEEP=$1
      shift
    fi
  fi
 
  FORCE=0
  if [ "$1" = "-force" ]; then
    shift
    FORCE=1
  fi
 
  if [ ! -"$CATALINA_PID" ]; then
    if [ -"$CATALINA_PID" ]; then
      if [ -"$CATALINA_PID" ]; then
        kill -0 `cat "$CATALINA_PID">/dev/null 2>&1
        if [ $? -gt 0 ]; then
          echo "PID file found but either no matching process was found or the current user does not have permission to stop the process. Stop aborted."
          exit 1
        fi
      else
        echo "PID file is empty and has been ignored."
      fi
    else
      echo "\$CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted."
      exit 1
    fi
  fi
 
  eval "\"$_RUNJAVA\"" $LOGGING_MANAGER "$JAVA_OPTS" \
    -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
    -classpath "\"$CLASSPATH\"" \
    -Dcatalina.base="\"$CATALINA_BASE\"" \
    -Dcatalina.home="\"$CATALINA_HOME\"" \
    -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
    org.apache.catalina.startup.Bootstrap "$@" stop
 
  # stop failed. Shutdown port disabled? Try a normal kill.
  if [ $? != 0 ]; then
    if [ ! -"$CATALINA_PID" ]; then
      echo "The stop command failed. Attempting to signal the process to stop through OS signal."
      kill -15 `cat "$CATALINA_PID">/dev/null 2>&1
    fi
  fi
 
  if [ ! -"$CATALINA_PID" ]; then
    if [ -"$CATALINA_PID" ]; then
      while [ $SLEEP -ge 0 ]; do
        kill -0 `cat "$CATALINA_PID">/dev/null 2>&1
        if [ $? -gt 0 ]; then
          rm -"$CATALINA_PID" >/dev/null 2>&1
          if [ $? != 0 ]; then
            if [ -"$CATALINA_PID" ]; then
              cat /dev/null > "$CATALINA_PID"
              # If Tomcat has stopped don't try and force a stop with an empty PID file
              FORCE=0
            else
              echo "The PID file could not be removed or cleared."
            fi
          fi
          echo "Tomcat stopped."
          break
        fi
        if [ $SLEEP -gt 0 ]; then
          sleep 1
        fi
        if [ $SLEEP -eq 0 ]; then
          echo "Tomcat did not stop in time."
          if [ $FORCE -eq 0 ]; then
            echo "PID file was not removed."
          fi
          echo "To aid diagnostics a thread dump has been written to standard out."
          kill -3 `cat "$CATALINA_PID"`
        fi
        SLEEP=`expr $SLEEP - 1 `
      done
    fi
  fi
 
  KILL_SLEEP_INTERVAL=5
  if [ $FORCE -eq 1 ]; then
    if [ -"$CATALINA_PID" ]; then
      echo "Kill failed: \$CATALINA_PID not set"
    else
      if [ -"$CATALINA_PID" ]; then
        PID=`cat "$CATALINA_PID"`
        echo "Killing Tomcat with the PID: $PID"
        kill -9 $PID
        while [ $KILL_SLEEP_INTERVAL -ge 0 ]; do
            kill -0 `cat "$CATALINA_PID">/dev/null 2>&1
            if [ $? -gt 0 ]; then
                rm -"$CATALINA_PID" >/dev/null 2>&1
                if [ $? != 0 ]; then
                    if [ -"$CATALINA_PID" ]; then
                        cat /dev/null > "$CATALINA_PID"
                    else
                        echo "The PID file could not be removed."
                    fi
                fi
                echo "The Tomcat process has been killed."
                break
            fi
            if [ $KILL_SLEEP_INTERVAL -gt 0 ]; then
                sleep 1
            fi
            KILL_SLEEP_INTERVAL=`expr $KILL_SLEEP_INTERVAL - 1 `
        done
        if [ $KILL_SLEEP_INTERVAL -lt 0 ]; then
            echo "Tomcat has not been killed completely yet. The process might be waiting on some system call or might be UNINTERRUPTIBLE."
        fi
      fi
    fi
  fi
 
elif [ "$1" = "configtest" ] ; then
 
    eval "\"$_RUNJAVA\"" $LOGGING_MANAGER "$JAVA_OPTS" \
      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
      -classpath "\"$CLASSPATH\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
      org.apache.catalina.startup.Bootstrap configtest
    result=$?
    if [ $result -ne 0 ]; then
        echo "Configuration error detected!"
    fi
    exit $result
 
elif [ "$1" = "version" ] ; then
 
    "$_RUNJAVA"   \
      -classpath "$CATALINA_HOME/lib/catalina.jar" \
      org.apache.catalina.util.ServerInfo
 
else
 
  echo "Usage: catalina.sh ( commands ... )"
  echo "commands:"
  if $os400; then
    echo "  debug             Start Catalina in a debugger (not available on OS400)"
    echo "  debug -security   Debug Catalina with a security manager (not available on OS400)"
  else
    echo "  debug             Start Catalina in a debugger"
    echo "  debug -security   Debug Catalina with a security manager"
  fi
  echo "  jpda start        Start Catalina under JPDA debugger"
  echo "  run               Start Catalina in the current window"
  echo "  run -security     Start in the current window with security manager"
  echo "  start             Start Catalina in a separate window"
  echo "  start -security   Start in a separate window with security manager"
  echo "  stop              Stop Catalina, waiting up to 5 seconds for the process to end"
  echo "  stop n            Stop Catalina, waiting up to n seconds for the process to end"
  echo "  stop -force       Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running"
  echo "  stop n -force     Stop Catalina, wait up to n seconds and then use kill -KILL if still running"
  echo "  configtest        Run a basic syntax check on server.xml - check exit code for result"
  echo "  version           What version of tomcat are you running?"
  echo "Note: Waiting for the process to end and use of the -force option require that \$CATALINA_PID is defined"
  exit 1
 
fi
cs

 

3. Application(war) Coherence-web 관련 webInstaller 수행

Coherence-web을 사용하기 위해서 Application(war)에 Coherence webInstaller 적용이 필요합니다.

 

관련 내용이 정리된 Oracle 공식 문서입니다.

https://docs.oracle.com/en/middleware/standalone/coherence/14.1.1.0/administer-http-sessions/using-coherenceweb-other-application-servers.html#GUID-B9C84803-E998-4988-8267-E84A6A916D6F

 

Administering HTTP Session Management with Oracle Coherence*Web

You can configure and deploy Coherence*Web, the session state persistence and management module, for use with a variety of application servers.

docs.oracle.com

 

해당 Application(war)을 분석해서 Coherence에 세션을 저장하도록 web.xml 파일을 변경 해 주는 과정이며 다음과 같이 적용이 가능합니다.

 

webInstaller.jar 파일 복사

$COHERENCE_HOME/lib 경로에서 coherence.jar, coherence-web.jar webInstaller.jar 파일을 Application war파일이 있는 경로로 복사 해 줍니다.

1
2
3
4
5
6
7
[tomcat@coherence tmp]$ ll
total 19272
-rw-r-----1 tomcat tomcat 13763107 Mar 16 18:42 coherence.jar
-rw-r-----1 tomcat tomcat   241893 Mar 16 18:42 coherence-web.jar
-rw-rw-r--1 tomcat tomcat  5635401 Mar 16 18:36 Lab6A.war
-rw-r-----1 tomcat tomcat    84242 Mar 16 18:42 webInstaller.jar
 
cs

 

webInstaller inspect 수행

webInstaller.jar 파일을 사용해 다음과 같이 Application inspect를 수행 해 줍니다.

java -jar webInstaller.jar Lab6A.war -inspect -server:tomcat/8.x

server 옵션 뒤에는 사용하는 WAS 정보를 입력 하면 됩니다.

https://docs.oracle.com/en/middleware/standalone/coherence/14.1.1.0/administer-http-sessions/introduction-coherenceweb.html#GUID-4202FA59-819E-445C-8BCA-2648510914A3

 

Administering HTTP Session Management with Oracle Coherence*Web

Learn the advantages of using Coherence*Web for managing session state in clustered environments.

docs.oracle.com

관련 내용이 상세히 정리되어 있는 Oracle 공식 문서입니다.

사용하시는 WAS에 맞는 server 옵션 확인 시 참조 해 주세요.

 

1
2
3
4
5
6
7
8
[tomcat@coherence tmp]$ java -jar webInstaller.jar Lab6A.war -inspect -server:tomcat/8.x
[tomcat@coherence tmp]$ ll
total 19296
-rw-r-----1 tomcat tomcat 13763107 Mar 16 18:42 coherence.jar
-rw-r-----1 tomcat tomcat   241893 Mar 16 18:42 coherence-web.jar
-rw-rw-r--1 tomcat tomcat    23134 Mar 16 18:43 coherence-web.xml
-rw-rw-r--1 tomcat tomcat  5635401 Mar 16 18:36 Lab6A.war
-rw-r-----1 tomcat tomcat    84242 Mar 16 18:42 webInstaller.jar
cs

 

webInstaller install 수행

inspect가 완료되고 coherence-web.xml 파일이 생성된 것을 확인 후 다음과 같이 Application install을 수행 해 줍니다.

java -jar webInstaller.jar Lab6A.war -install
1
2
3
4
5
6
7
8
9
10
11
[tomcat@coherence tmp]$ java -jar webInstaller.jar Lab6A.war -install
The original application is saved as /home/tomcat/downloads/tmp/tmp/Lab6A.war.installer-backup
Successfully installed: /home/tomcat/downloads/tmp/tmp/Lab6A.war
[tomcat@coherence tmp]$ ll
total 37260
-rw-r-----1 tomcat tomcat 13763107 Mar 16 18:42 coherence.jar
-rw-r-----1 tomcat tomcat   241893 Mar 16 18:42 coherence-web.jar
-rw-rw-r--1 tomcat tomcat    23134 Mar 16 18:43 coherence-web.xml
-rw-rw-r--1 tomcat tomcat 18392820 Mar 16 18:43 Lab6A.war
-rw-rw-r--1 tomcat tomcat  5635401 Mar 16 18:36 Lab6A.war.installer-backup
-rw-r-----1 tomcat tomcat    84242 Mar 16 18:42 webInstaller.jar
cs

install이 완료되면 새로운 war 파일(Lab6A.war)이 생성되며 기존 war파일은 installer-backup 확장자의 파일로 zip을 통해 압축됩니다.

 

webInstaller 수행 완료 후 Application의 web.xml 파일입니다.

web.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<?xml version='1.0' encoding='UTF-8'?>
<!--
NOTE: This web.xml file was generated by the Coherence*Web installer and must
not be modified. If you need to make changes to the web application
configuration, uninstall Coherence*Web from the web application, modify the
original web application web.xml file, reinspect the web application, and
then reinstall Coherence*Web.
-->
<web-app xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://java.sun.com/xml/ns/javaee' xmlns:web='http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd' xsi:schemaLocation='http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd' id='WebApp_ID' version='3.0'>
  <display-name>Lab6A</display-name>
  <context-param>
    <description>"true" to enable a configuration consistency check during startup. This
      check will enforce that the configuration used by all web tier JVMs which use the
      same set of cache services are compatible. Defaults to "false".</description>
    <param-name>coherence-configuration-consistency</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The fully qualified class name of the SessionHelper Factory
      to use. Defaults to "com.tangosol.coherence.servlet.apiXX.DefaultFactory"
      where "XX" is "23", "24" or "25" for Servlet 2.3, 2.4 and 2.5 containers
      respectively.</description>
    <param-name>coherence-factory-class</param-name>
    <param-value>com.tangosol.coherence.servlet.tomcat80.DefaultFactory</param-value>
  </context-param>
  <context-param>
    <description>The fully qualified class name of the HttpSessionCollection
      implementation to use. Possible values include
      "com.tangosol.coherence.servlet.MonolithicHttpSessionCollection",
      "com.tangosol.coherence.servlet.SplitHttpSessionCollection", or
      "com.tangosol.coherence.servlet.TraditionalHttpSessionCollection".</description>
    <param-name>coherence-sessioncollection-class</param-name>
    <param-value>com.tangosol.coherence.servlet.SplitHttpSessionCollection</param-value>
  </context-param>
  <context-param>
    <description>Either "true" or "false" to indicate whether the cluster
      software is deployed as part of the application and thus must be shut
      down fully by the application when it shuts down. For example, this
      should be set to "true" if coherence.jar is deployed within the
      application "WAR" file. Defaults to "false".</description>
    <param-name>coherence-cluster-owned</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <description>Either "true" or "false" to indicate whether the attributes
      of the ServletContext will be clustered. If "true", then all
      serializable ServletContext attribute values will be shared among
      all cluster nodes. The default is "false", primarily because the Servlet
      specification indicates that the ServletContext attributes are local
      to a JVM and should not be clustered.</description>
    <param-name>coherence-servletcontext-clustered</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The name of the Coherence cache that will be used to hold the
      servlet context data if the servlet context is clustered. Defaults to
      "servletcontext-storage".</description>
    <param-name>coherence-servletcontext-cachename</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The comma-delimited list of names of application classes that
      wish to receive events from the web container. (Servlet 2.3 and later.)
      This list comes from the application listeners declared in the web.xml
      "listener" elements.</description>
    <param-name>coherence-eventlisteners</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>"true" to allow the application to iterate sessions from the
      session context, thus disobeying the deprecation in the servlet spec.
      Defaults to "false".</description>
    <param-name>coherence-enable-sessioncontext</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The number of milliseconds that a server will hold a lock on
      a session while accessing that session without the session being implied
      by the current request context. A session is implied by the current
      request context if and only if the current thread is processing a Serlvet
      request, and the request is associated with that session. All other
      access to a session object is "out of context", for example if a
      reference to an arbitrary session is obtained from a SessionContext
      object (if that option is enabled), or if the application has code
      that holds on to session object references to manage sessions directly.
      Since session access requires session ownership, "out of context"
      access to the session object will automatically obtain ownership on
      behalf of the caller; that ownership will be retained for the number
      of milliseconds specified by this option so that repeated calls to the
      session do not individually obtain and release ownership, which is
      potentially an expensive operation. The legal range is 10 to 10000
      (from 1/100th of a second up to 10 seconds). Defaults to 200.</description>
    <param-name>coherence-contextless-session-retain-millis</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>"true" to enable session cookies. Defaults to "true".</description>
    <param-name>coherence-session-cookies-enabled</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The name of the session cookie. Defaults to "JSESSIONID".</description>
    <param-name>coherence-session-cookie-name</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The domain of the session cookie as defined by RFC 2109.
      By default, no domain is set explicitly by the session management
      implementation.</description>
    <param-name>coherence-session-cookie-domain</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The path of the session cookie as defined by RFC 2109.
      By default, no path is set explicitly by the session management
      implementation.</description>
    <param-name>coherence-session-cookie-path</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The maximum age in seconds of the session cookie as
      defined by RFC 2109. A value of -1 indicates that the cookie
      will not be persistent on the client; a positive value gives
      the maximum age that the cookie will be persisted by the client.
      Zero is not permitted. Defaults to -1.</description>
    <param-name>coherence-session-cookie-max-age</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>"true" to ensure that the session cookie will only be
      sent from a web client over a SSL connection. Defaults to "false".</description>
    <param-name>coherence-session-cookie-secure</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>"true" to enable URL encoding of session IDs. Defaults to
      "false".</description>
    <param-name>coherence-session-urlencode-enabled</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The parameter name to encode the session ID into the URL
      with. On some containers, this value cannot be overriden. Defaults to
      "jsessionid".</description>
    <param-name>coherence-session-urlencode-name</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>"true" to use the container's decoding of the URL session ID.
      If "coherence-session-urlencode-name" has been overridden, this must be
      set to "false". Setting this to "false" will not work in some containers.
      Defaults to "true".</description>
    <param-name>coherence-session-urldecode-bycontainer</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>"true" to use the container's encoding of the URL session ID.
      Setting this to "true" may conflict with the setting for
      "coherence-session-urlencode-name" if it has been specified. Defaults
      to "false".</description>
    <param-name>coherence-session-urlencode-bycontainer</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>"true" to coordinate reaping in the cluster such that only one
      server will perform reaping within a given reaping cycle, and it will
      be responsible for checking all of the sessions that are being managed
      in the cluster. Defaults to "false".</description>
    <param-name>coherence-reaperdaemon-cluster-coordinated</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The number of times that the reaper reaps the sessions that
      are being used locally before it will check sessions that may be
      orphaned or expired elsewhere in the cluster. This setting is only used
      when coordinate reaping is disabled. Setting it to 1 for example will
      cause the daemon to check this server's fair share of the session IDs
      in the cluster every time that it wakes up to check for expired
      sessions (for example every 60 seconds). Setting it to ten will
      cause those sessions to be checked every 600 seconds instead, but the
      sessions that are being used on this server will still be checked every
      60 seconds. Defaults to 4.</description>
    <param-name>coherence-reaperdaemon-sweep-modulo</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This setting allows the reaper to assume that the sessions
      that are stored on this node (for example, by a distributed cache
      service) are the only sessions that this node needs to check for
      expiry. This value must be set to "false" if the session storage cache
      is being managed by nodes that are not running a reaper, for example
      if cache servers are being used to manage the session storage cache.
      (It is suggested that if cache servers are being used, that the
      "split" model be selected, and that the session overflow storage be
      run in a separate distributed cache service that is managed entirely
      by the cache servers, while the session storage cache itself remain
      in a distributed cache service that is managed entirely by the
      application server JVMs in order to be able to take advantage of this
      "assume locality" feature.) Defaults to "true".</description>
    <param-name>coherence-reaperdaemon-assume-locality</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The number of seconds that the daemon rests between reaping.
      For production clusters with long session timeouts, this can safely be
      set higher. For testing, particularly with short session timeouts, it
      can be set much lower. Setting it too low can cause more network traffic
      and use more processing cycles, and only has benefit if the application
      requires the sessions to be invalidated quickly once they have expired.
      Defaults to 300.</description>
    <param-name>coherence-reaperdaemon-cycle-seconds</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The priority for the session reaper daemon.
      For more information, see the source for the "java.lang.Thread" class.
      Defaults to 5.</description>
    <param-name>coherence-reaperdaemon-priority</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>Reap sessions in parallel. With configuration the session
    reaper will use a thread pool to reap the expired sessions in parallel
    every reap cycle. Defaults to true.</description>
    <param-name>coherence-reaperdaemon-parallel</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The minimum number of threads used for parallel session reaping.
    Defaults to 1.</description>
    <param-name>coherence-reaperdaemon-min-threads</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The maximum number of threads used for parallel session reaping.
    Defaults to 5.</description>
    <param-name>coherence-reaperdaemon-max-threads</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This name overrides the name of the clustered cache that
      stores the sessions. Defaults to "session-storage".</description>
    <param-name>coherence-session-cachename</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This name overrides the name of the clustered cache that
      stores the IDs of "recently departed" sessions. Defaults to
      "session-death-certificates".</description>
    <param-name>coherence-session-deathcert-cachename</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This name overrides the name of the clustered cache that
      stores the management and configuration information for the session
      management implementation. Generally, it should be configured a
      replicated cache. Defaults to "session-management".</description>
    <param-name>coherence-session-management-cachename</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value overrides the session expiry time, and is
      expressed in seconds. Setting it to -1 will cause sessions to
      never expire. Defaults to 1800.</description>
    <param-name>coherence-session-expire-seconds</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This is the length, in characters, of generated session IDs.
      The suggested absolute minimum length is 8. Defaults to 12.</description>
    <param-name>coherence-session-id-length</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value determines how long the session management
      implementation waits before shutting down after receiving the last
      indication that the application has been stopped, either from
      ServletContextListener events (Servlet 2.3 or later) or by the
      destruction of Servlet and Filter objects. This value is expressed
      in seconds. A value of zero indicates synchronous shut-down; any
      positive value indicates asynchronous shut-down. The default is 0,
      because some servers are not capable of asynchronous shut-down.</description>
    <param-name>coherence-shutdown-delay-seconds</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The value determines whether a session is obtained
      lazily during a servlet's service method. If "true", the session is only
      fetched if the getSession method is called by the application. If "false"
      the session is fetched, and locked, on entry into the service method.
      Defaults to "false".</description>
    <param-name>coherence-session-lazy-access</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value, if set to "false", will allow concurrent
      modification to sessions, with the last update winning.
      If "coherence-session-member-locking", "coherence-session-app-locking" or
      "coherence-session-thread-locking" are set to true, this value is ignored
      (being logically "true"). Defaults to "false".</description>
    <param-name>coherence-session-locking</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value, if set to "true", will prevent two threads in
      different JVMs from processing a request for the same session at the
      same time. A value of "false" is incompatible with sticky session
      optimizations, application and thread locking. If set to "true" the
      value of the "coherence-session-locking" parameter will be ignored,
      as member locking implies session locking. Defaults to "false".</description>
    <param-name>coherence-session-member-locking</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value, if set to "true", will prevent two threads in
      different applications from processing a request for the same session
      at the same time. A value of "false" is incompatible with thread locking.
      If set to "true" the value of the "coherence-session-member-locking"
      parameter will be ignored, as application locking implies member locking.
      Defaults to "false".</description>
    <param-name>coherence-session-app-locking</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value, if set to "true", will prevent two threads in the
      same JVM from processing a request for the same session at the same time.
      If set to "true" the value of the "coherence-session-member-locking" and
      "coherence-session-app-locking" parameters will be ignored, as thread
      locking implies both member and application locking. Defaults to "false".</description>
    <param-name>coherence-session-thread-locking</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>The time (in seconds) a Servlet will wait for a lock on a
      session to become available. If the timeout is reached waiting for a
      session lock, a com.tangosol.net.RequestTimeoutException is thrown. A
      negative value indicates that the Servlet should wait indefinitely.
      Defaults to 300 seconds (5 minutes).</description>
    <param-name>coherence-session-get-lock-timeout</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>Specifies whether an diagnostic invocation service is
      executed when a member is unable to acquire the cluster lock for a
      session. The invocation service will cause the member that has ownership
      of the session to log the stack trace of the threads that are currently
      holding the lock. Defaults to "true".</description>
    <param-name>coherence-session-log-threads-holding-lock</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value, if set to "true", will indicate that the
      implementation will strictly adhere to the Servlet specification;
      setting it to "false" will allow the implementation to ignore certain
      types of exceptions, instead of shutting down the application. Defaults
      to "true".</description>
    <param-name>coherence-session-strict-spec</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value, if set to "true", specifies whether sticky
      sessions optimizations will be used. This should only be turned on if a
      sticky load balancer is being used. This feature requires
      Coherence Enterprise edition license. Defaults to "false".</description>
    <param-name>coherence-sticky-sessions</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>With this set to "true", attributes that are deemed to be
      mutable (detected with a simple check) and which are accessed through a get,
      are deemed to be suspect in that they may have been changed in application code.
      Suspect attributes are treated as changed. Defaults to "false".</description>
    <param-name>coherence-enable-suspect-attributes</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value specifies a class name of the optional
      com.tangosol.coherence.servlet.HttpSessionCollection.SessionDistributionController
      interface implementation to use. This feature requires
      "coherence-sticky-sessions" optimization be turned on.</description>
    <param-name>coherence-distributioncontroller-class</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This value specifies a class name of the optional
      com.tangosol.coherence.servlet.HttpSessionCollection.AttributeScopeController
      interface implementation to use.</description>
    <param-name>coherence-scopecontroller-class</param-name>
    <param-value>com.tangosol.coherence.servlet.AbstractHttpSessionCollection$ApplicationScopeController</param-value>
  </context-param>
  <context-param>
    <description>This value, if set to "true", specifies whether non-serializable
      attributes should be preserved as local ones. This feature requires
      "coherence-sticky-sessions" optimization be turned on. Defaults to
      "false".</description>
    <param-name>coherence-preserve-attributes</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This name overrides the name of the local cache that
      stores non-distributed sessions when
      "coherence-distributioncontroller-class" parameter is specified.
      Defaults to "local-session-storage".</description>
    <param-name>coherence-local-session-cachename</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>This name overrides the name of the local cache
      that stores non-distributed sessions when either
      "coherence-sessiondistributioncontroller-class" parameter is
      specified or "coherence-preserve-attributes" parameter is "true".
      Defaults to "local-attribute-storage".</description>
    <param-name>coherence-local-attribute-cachename</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>For the split model, this value overrides the name of the
      clustered cache that stores the "large attributes" that exceed a
      certain size and thus are determined to be more efficiently managed
      as separate cache entries and not as part of the serialized session
      object itself. Defaults to "session-overflow".</description>
    <param-name>coherence-session-overflow-cachename</param-name>
    <param-value/>
  </context-param>
  <context-param>
    <description>For the split model, this value specifies the minimum length
      (in bytes) that the serialized form of an attribute value must be in
      order for that attribute value to be stored in the separate "overflow"
      cache that is reserved for large attributes. Defaults to 1024.</description>
    <param-name>coherence-attribute-overflow-threshold</param-name>
    <param-value/>
  </context-param>
  <listener>
    <listener-class>com.tangosol.coherence.servlet.api23.ServletContextListenerImpl</listener-class>
  </listener>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <distributable/>
</web-app>
cs

 

Tomcat Coherence-web 관련 Application(war) 설정이 마무리 되었습니다.

해당 war 파일을 Tomcat의 webapps 경로에 배포한 후 테스트를 진행해 보겠습니다.


4. Tomcat - Coherence  세션 클러스터링 확인

예제 Application은 Coherence에 세션객체를 저장하도록 구성되어 있습니다.

그렇기 때문에 Tomcat을 기동하기 전에 6장의 Coherence-web 설정과 동일한 Coherence가 실행되어야 합니다.

 

꼭 Coherence cache-server 실행 후 Tomcat 2대를 기동해 주세요.

 

apache-tomcat-8.5.87_1st, apache-tomcat-8.5.87_2nd의 서비스 포트인 18080, 28080간의 세션공유가 정상적으로 이루어 지는지 Application에 작성해둔 세션 체크 jsp 파일을 이용하여 확인 해 보겠습니다.

 

apache-tomcat-8.5.87_1st - 18080 포트

apache-tomcat-8.5.87_2nd - 28080 포트

WebLogic - Coherence 세션 그리드와 마찬가지로 Tomcat에서도 Coherence를 적용한 세션 클러스트링이 적용되는 것을 확인하였습니다.

 

WebLogic을 사용하는 것보다 단계가 추가 되지만 Tomcat과 같은 이기종 WAS에서도 사용이 가능한 것을 확인할 수 있습니다.


Tomcat - Coherence 세션 그리드를 사용하기 위해서 매번 반복되어야 하는 webInstller 작업은 ant 스크립트 등으로 자동화 하는 방법도 Oracle 공식 문서를 통해 가이드 되고 있으니 필요하신 분은 참고 하시기 바랍니다.

 

https://docs.oracle.com/en/middleware/standalone/coherence/14.1.1.0/administer-http-sessions/using-coherenceweb-other-application-servers.html#GUID-78F63E6B-020B-44AE-B363-606571BECE95

 

Administering HTTP Session Management with Oracle Coherence*Web

You can configure and deploy Coherence*Web, the session state persistence and management module, for use with a variety of application servers.

docs.oracle.com