반응형

Issue

Maven 으로 build Spring boot war 파일을 tomcat 에서 실행시 아래와 같은 에러 발생

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
01-Jul-2019 11:28:09.100 정보 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.23
01-Jul-2019 11:28:09.126 정보 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [{tomcat}/webapps/module.war]
01-Jul-2019 11:28:09.271 심각 [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/module]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@e5ca407]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4860)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4995)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 10 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@6a8a7487]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:113)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
        at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:724)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 13 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: error in opening zip file
        at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:113)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
        ... 16 more
Caused by: java.util.zip.ZipException: error in opening zip file
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:225)
        at java.util.zip.ZipFile.<init>(ZipFile.java:155)
        at java.util.jar.JarFile.<init>(JarFile.java:166)
        at java.util.jar.JarFile.<init>(JarFile.java:103)
        at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:110)
        ... 17 more
 
01-Jul-2019 11:28:09.272 심각 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [{tomcat}/webapps/module.war]
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/module]]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
 
01-Jul-2019 11:28:09.274 정보 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [{tomcat}/webapps/module.war] has finished in [148] ms
01-Jul-2019 11:28:09.276 정보 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-12200"]
01-Jul-2019 11:28:09.384 정보 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-12202"]
01-Jul-2019 11:28:09.386 정보 [main] org.apache.catalina.startup.Catalina.start Server startup in 307 ms
cs

 

원인

여러가지 원인이 있겠지만 일단 public respository 에서 받아온 jar 가 아닌 프로젝트 폴더내에 추가한 jar 파일을 war 로 빌드시 잘못들어간 것으로 보임.

원본 jar 와 war를 압축해제 하여 안에있는 jar 파일의 크기를 비교하니 다름.

pom.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
<project>
    ...
    <build>
        <finalName>module</finalName>
        <plugins>
            ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>${project.basedir}/libs/${build.os}</directory>
                            <targetPath>WEB-INF/lib</targetPath>
                            <filtering>true</filtering>
                            <includes>
                                <include>*.*</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
cs

war 빌드시 특정 파일을 include 하는 방법을 무작정 검색해서 복붙한 결과.....

위 xml 에서 filtering, include 태그를 잘못 사용하고 있었다.

자세한 내용은 : https://maven.apache.org/plugins-archives/maven-war-plugin-2.5/examples/adding-filtering-webresources.html

 

Apache Maven WAR Plugin - Adding and Filtering External Web Resources

Adding and Filtering External Web Resources The default resource directory for all Maven projects is src/main/resources which will end up in target/classes and in WEB-INF/classes in the WAR. The directory structure will be preserved in the process. The WAR

maven.apache.org

pom.xml 을 아래와 같이 수정 후 원본 jar 와 용량체크를 한뒤 배포 하니 잘 구동된다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<project>
    ...
    <build>
        <finalName>module</finalName>
        <plugins>
            ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>${project.basedir}/libs/${build.os}</directory>
                            <targetPath>WEB-INF/lib</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
cs
반응형

'IT > 언어' 카테고리의 다른 글

spring boot embedded tomcat letsencrypt ssl 적용  (0) 2019.02.08
import os  (0) 2015.11.25
[c#] 파일 출력  (0) 2014.08.19
페이징 처리용 소스(예제?)  (0) 2014.07.08
POI Excel 파일 쓰기  (0) 2014.06.26
반응형

출처 : https://dzone.com/articles/spring-boot-secured-by-lets-encrypt


1. Lets encrypt 설치

1
2
3
$ git clone https://github.com/certbot/certbot 
$ cd certbot
$ ./certbot-auto --help
cs


2. ssl 인증서 발급

1
2
$ ./certbot-auto certonly -a standalone \
     -d abc.com -d www.abc.com
cs


3. PKCS12 형식 파일로 변환 (linux openssl 사용)

1
2
3
4
5
6
$ openssl pkcs12 -export -in fullchain.pem \ 
                 -inkey privkey.pem \ 
                 -out keystore.p12 
                 -name tomcat \
                 -CAfile chain.pem \
                 -caname root

cs


3.1 local 에서 테스트 하기 위해 linux 에 생성된 keystore.p12 파일을 local 로 복사.

4. spring boot application.yml (spring boot version = 2.1.2.RELEASE)

1
2
3
4
5
6
7
8
9
server:
  port: 8443
  servlet:
    context-path: /
  ssl:
    key-store: c:\\www.abc.com\\keystore.p12
    key-store-password: <비밀번호>
    key-store-type: pkcs12
    key-alias: tomcat
cs


출처 : https://dzone.com/articles/spring-boot-secured-by-lets-encrypt

반응형

'IT > 언어' 카테고리의 다른 글

Caused by: java.util.zip.ZipException: error in opening zip file  (0) 2019.07.01
import os  (0) 2015.11.25
[c#] 파일 출력  (0) 2014.08.19
페이징 처리용 소스(예제?)  (0) 2014.07.08
POI Excel 파일 쓰기  (0) 2014.06.26

+ Recent posts