質問編集履歴

10

説明を更新

2021/12/29 03:44

投稿

Linkey
Linkey

スコア77

test CHANGED
File without changes
test CHANGED
@@ -292,23 +292,9 @@
292
292
 
293
293
  ```ここに言語を入力
294
294
 
295
- 28-Dec-2021 15:18:24.821 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.31] using APR version [1.7.0].
296
-
297
- 28-Dec-2021 15:18:24.822 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
298
-
299
- 28-Dec-2021 15:18:24.824 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1k 25 Mar 2021]
300
-
301
- 28-Dec-2021 15:18:25.088 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
302
-
303
- 28-Dec-2021 15:18:25.106 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [454] milliseconds
304
-
305
- 28-Dec-2021 15:18:25.153 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
306
-
307
- 28-Dec-2021 15:18:25.153 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.0.14]
308
-
309
295
  28-Dec-2021 15:18:25.166 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps/sample1.war]
310
296
 
311
- 28-Dec-2021 15:18:26.098 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
297
+
312
298
 
313
299
  28-Dec-2021 15:18:26.137 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/sample1.war] has finished in [971] ms
314
300
 
@@ -404,13 +390,111 @@
404
390
 
405
391
 
406
392
 
393
+ orgフォルダの中身を確認。
394
+
395
+ ```
396
+
397
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# cd org/
398
+
399
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org# ls -la
400
+
401
+ total 12
402
+
403
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 .
404
+
405
+ drwxr-x--- 5 root root 4096 Dec 29 03:12 ..
406
+
407
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 springframework
408
+
409
+ root@cd66d6f2186c:/usr/local/tomcat/webapps/sample1/org#
410
+
411
+ root@cd66d6f2186c:/usr/local/tomcat/webapps/sample1/org# cd springframework/
412
+
413
+ root@cd66d6f2186c:/usr/local/tomcat/webapps/sample1/org/springframework# ls -la
414
+
415
+ total 12
416
+
417
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 .
418
+
419
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 ..
420
+
421
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 boot
422
+
423
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework#
424
+
425
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework# cd boot/
426
+
427
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework/boot# ls -la
428
+
429
+ total 12
430
+
431
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 .
432
+
433
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 ..
434
+
435
+ drwxr-x--- 7 root root 4096 Dec 29 03:12 loader
436
+
437
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework/boot# cd loader
438
+
439
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework/boot/loader# ls -la
440
+
441
+ total 124
442
+
443
+ drwxr-x--- 7 root root 4096 Dec 29 03:12 .
444
+
445
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 ..
446
+
447
+ -rw-r----- 1 root root 5871 Feb 1 1980 ClassPathIndexFile.class
448
+
449
+ -rw-r----- 1 root root 6806 Feb 1 1980 ExecutableArchiveLauncher.class
450
+
451
+ -rw-r----- 1 root root 3966 Feb 1 1980 JarLauncher.class
452
+
453
+ -rw-r----- 1 root root 1483 Feb 1 1980 'LaunchedURLClassLoader$DefinePackageCallType.class'
454
+
455
+ -rw-r----- 1 root root 1535 Feb 1 1980 'LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.class'
456
+
457
+ -rw-r----- 1 root root 11154 Feb 1 1980 LaunchedURLClassLoader.class
458
+
459
+ -rw-r----- 1 root root 5932 Feb 1 1980 Launcher.class
460
+
461
+ -rw-r----- 1 root root 1536 Feb 1 1980 MainMethodRunner.class
462
+
463
+ -rw-r----- 1 root root 266 Feb 1 1980 'PropertiesLauncher$1.class'
464
+
465
+ -rw-r----- 1 root root 1484 Feb 1 1980 'PropertiesLauncher$ArchiveEntryFilter.class'
466
+
467
+ -rw-r----- 1 root root 8128 Feb 1 1980 'PropertiesLauncher$ClassPathArchives.class'
468
+
469
+ -rw-r----- 1 root root 1953 Feb 1 1980 'PropertiesLauncher$PrefixMatchingArchiveFilter.class'
470
+
471
+ -rw-r----- 1 root root 18267 Feb 1 1980 PropertiesLauncher.class
472
+
473
+ -rw-r----- 1 root root 1750 Feb 1 1980 WarLauncher.class
474
+
475
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 archive
476
+
477
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 data
478
+
479
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 jar
480
+
481
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 jarmode
482
+
483
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 util
484
+
485
+ ```
486
+
487
+
488
+
407
489
  curlコマンドでアクセス確認をするがTomcatの404が返却されてしまう
408
490
 
409
491
  ```ここに言語を入力
410
492
 
411
493
  root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# curl http://localhost:8080/sample1/sample/
412
494
 
413
- <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [&#47;sample1&#47;sample&#47;] is not available</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/10.0.14</h3></body></html>
495
+ <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} ~
496
+
497
+ <h3>Apache Tomcat/10.0.14</h3></body></html>
414
498
 
415
499
  ```
416
500
 
@@ -465,3 +549,7 @@
465
549
  ![イメージ説明](f0af86a6f2cbfcbe36b8e395c5454681.png)
466
550
 
467
551
  ![イメージ説明](04f55890beafd5fa4b654b7eade9fca6.png)
552
+
553
+
554
+
555
+ orgフォルダが悪さをしているように見えますが、どうしてそのフォルダが出来てしまったのか分からず、解決方法は調査中です。

9

説明を更新

2021/12/29 03:44

投稿

Linkey
Linkey

スコア77

test CHANGED
File without changes
test CHANGED
@@ -426,7 +426,7 @@
426
426
 
427
427
  GPG_KEYS=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
428
428
 
429
- PWD=/
429
+ PWD=/usr/local/tomcat/webapps
430
430
 
431
431
  TOMCAT_SHA512=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
432
432
 

8

説明を更新

2021/12/29 03:15

投稿

Linkey
Linkey

スコア77

test CHANGED
File without changes
test CHANGED
@@ -454,6 +454,8 @@
454
454
 
455
455
  _=/usr/bin/printenv
456
456
 
457
+ OLDPWD=/usr/local/tomcat
458
+
457
459
  ```
458
460
 
459
461
 

7

説明を更新

2021/12/29 03:14

投稿

Linkey
Linkey

スコア77

test CHANGED
File without changes
test CHANGED
@@ -414,6 +414,48 @@
414
414
 
415
415
  ```
416
416
 
417
+ コンテナの環境変数は以下のようになっています。
418
+
419
+ ```ここに言語を入力
420
+
421
+ root@abd9ba51180a:/# printenv
422
+
423
+ HOSTNAME=abd9ba51180a
424
+
425
+ JAVA_HOME=/usr/local/openjdk-8
426
+
427
+ GPG_KEYS=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
428
+
429
+ PWD=/
430
+
431
+ TOMCAT_SHA512=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
432
+
433
+ TOMCAT_MAJOR=10
434
+
435
+ HOME=/root
436
+
437
+ LANG=C.UTF-8
438
+
439
+ TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib
440
+
441
+ TERM=xterm
442
+
443
+ CATALINA_HOME=/usr/local/tomcat
444
+
445
+ SHLVL=1
446
+
447
+ LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib
448
+
449
+ PATH=/usr/local/tomcat/bin:/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/sbin
450
+
451
+ TOMCAT_VERSION=10.0.14
452
+
453
+ JAVA_VERSION=8u312
454
+
455
+ _=/usr/bin/printenv
456
+
457
+ ```
458
+
417
459
 
418
460
 
419
461
  ローカル環境(Spring Tool Suite4)ではページが表示できます。

6

説明を更新

2021/12/29 03:07

投稿

Linkey
Linkey

スコア77

test CHANGED
File without changes
test CHANGED
@@ -413,3 +413,11 @@
413
413
  <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [&#47;sample1&#47;sample&#47;] is not available</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/10.0.14</h3></body></html>
414
414
 
415
415
  ```
416
+
417
+
418
+
419
+ ローカル環境(Spring Tool Suite4)ではページが表示できます。
420
+
421
+ ![イメージ説明](f0af86a6f2cbfcbe36b8e395c5454681.png)
422
+
423
+ ![イメージ説明](04f55890beafd5fa4b654b7eade9fca6.png)

5

説明の更新

2021/12/29 02:50

投稿

Linkey
Linkey

スコア77

test CHANGED
File without changes
test CHANGED
@@ -6,6 +6,52 @@
6
6
 
7
7
 
8
8
 
9
+ /sample1/src/main/java/com/example/sample1/Sample1Application.java
10
+
11
+ ```java
12
+
13
+ package com.example.sample1;
14
+
15
+
16
+
17
+ import org.springframework.boot.SpringApplication;
18
+
19
+ import org.springframework.boot.autoconfigure.SpringBootApplication;
20
+
21
+ import org.springframework.boot.builder.SpringApplicationBuilder;
22
+
23
+ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
24
+
25
+
26
+
27
+ @SpringBootApplication
28
+
29
+ public class Sample1Application extends SpringBootServletInitializer {
30
+
31
+
32
+
33
+ public static void main(String[] args) {
34
+
35
+ SpringApplication.run(Sample1Application.class, args);
36
+
37
+ }
38
+
39
+
40
+
41
+ @Override
42
+
43
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
44
+
45
+ return builder.sources(Sample1Application.class);
46
+
47
+ }
48
+
49
+ }
50
+
51
+ ```
52
+
53
+
54
+
9
55
  /sample1/src/main/java/com/example/sample1/controller/SampleController.java
10
56
 
11
57
  ```java

4

タイトルと説明を修正

2021/12/29 02:19

投稿

Linkey
Linkey

スコア77

test CHANGED
@@ -1 +1 @@
1
- warアプリケーションのDockerコンテナにブラウザからアクセスできない
1
+ Spring BootのwarアプリケーションのDockerコンテナにブラウザからアクセスできない
test CHANGED
@@ -355,3 +355,15 @@
355
355
  drwxr-x--- 3 root root 4096 Dec 29 01:52 org
356
356
 
357
357
  ```
358
+
359
+
360
+
361
+ curlコマンドでアクセス確認をするがTomcatの404が返却されてしまう
362
+
363
+ ```ここに言語を入力
364
+
365
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# curl http://localhost:8080/sample1/sample/
366
+
367
+ <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [&#47;sample1&#47;sample&#47;] is not available</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/10.0.14</h3></body></html>
368
+
369
+ ```

3

説明を修正

2021/12/29 02:15

投稿

Linkey
Linkey

スコア77

test CHANGED
File without changes
test CHANGED
@@ -304,21 +304,19 @@
304
304
 
305
305
  --- 追記 ----
306
306
 
307
+ Dockerfileのcatalina.sh実行コマンドを以下のように修正して確認
308
+
309
+ CMD ["sh", "/usr/local/tomcat/bin/catalina.sh", "run"]
310
+
311
+
312
+
307
- 以下のコマンドでイメージからコンテナを作成して確認してみました。
313
+ Dockerイメージを作り直してから以下のコマンドでイメージからコンテナを作成
308
314
 
309
315
  docker container run -it -p 8080:8080 --name test (Dockerユーザ名)/springboot-sample1:v1 /bin/bash
310
316
 
311
317
 
312
318
 
313
- /usr/local/tomcat/webapps配下をみたところwarファイルしか配置されていなかったので手動でDockerfileに記載されている
314
-
315
- catalina.sh実行がうまくいっていなそうだったので手動でcatalina.shを実行
316
-
317
- sh /usr/local/tomcat/bin/catalina.sh start -security
318
-
319
-
320
-
321
- catalina.sh実施後の資材の配置状態は以下のような状態です。
319
+ 資材の配置状態は以下のような状態です。
322
320
 
323
321
  ```ここに言語を入力
324
322
 

2

説明を更新

2021/12/29 02:11

投稿

Linkey
Linkey

スコア77

test CHANGED
File without changes
test CHANGED
@@ -304,7 +304,21 @@
304
304
 
305
305
  --- 追記 ----
306
306
 
307
+ 以下のコマンドでイメージからコンテナを作成して確認してみました。
308
+
309
+ docker container run -it -p 8080:8080 --name test (Dockerユーザ名)/springboot-sample1:v1 /bin/bash
310
+
311
+
312
+
313
+ /usr/local/tomcat/webapps配下をみたところwarファイルしか配置されていなかったので手動でDockerfileに記載されている
314
+
315
+ catalina.sh実行がうまくいっていなそうだったので手動でcatalina.shを実行
316
+
317
+ sh /usr/local/tomcat/bin/catalina.sh start -security
318
+
319
+
320
+
307
- 資材の配置状態は以下のような状態です。
321
+ catalina.sh実施後の資材の配置状態は以下のような状態です。
308
322
 
309
323
  ```ここに言語を入力
310
324
 

1

説明の更新

2021/12/29 02:01

投稿

Linkey
Linkey

スコア77

test CHANGED
File without changes
test CHANGED
@@ -299,3 +299,47 @@
299
299
  DockerとTomcatにお詳しい方がいましたらご回答いただけないでしょうか?
300
300
 
301
301
  よろしくお願いいたします。
302
+
303
+
304
+
305
+ --- 追記 ----
306
+
307
+ 資材の配置状態は以下のような状態です。
308
+
309
+ ```ここに言語を入力
310
+
311
+ root@abd9ba51180a:/usr/local/tomcat/webapps# ls -la
312
+
313
+ total 13096
314
+
315
+ drwxr-xr-x 1 root root 4096 Dec 29 01:45 .
316
+
317
+ drwxr-xr-x 1 root root 4096 Dec 22 17:10 ..
318
+
319
+ drwxr-x--- 4 root root 4096 Dec 29 01:45 sample1
320
+
321
+ -rwxr-xr-x 1 root root 13391545 Dec 29 01:43 sample1.war
322
+
323
+ ```
324
+
325
+
326
+
327
+ /usr/local/tomcat/webapps/sample1
328
+
329
+ ```ここに言語を入力
330
+
331
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# ls -la
332
+
333
+ total 20
334
+
335
+ drwxr-x--- 5 root root 4096 Dec 29 01:52 .
336
+
337
+ drwxr-xr-x 1 root root 4096 Dec 29 01:52 ..
338
+
339
+ drwxr-x--- 3 root root 4096 Dec 29 01:52 META-INF
340
+
341
+ drwxr-x--- 5 root root 4096 Dec 29 01:52 WEB-INF
342
+
343
+ drwxr-x--- 3 root root 4096 Dec 29 01:52 org
344
+
345
+ ```