woniper

spring boot 버전에 따른 외부 톰캣 버전 설정 본문

Spring

spring boot 버전에 따른 외부 톰캣 버전 설정

Woniper 2015.06.17 21:54

  현재 오픈소스로 개발 중인 설치형 블로그를 서버에 올려서 테스트하기 위해서 jenkins를 사용해 자동 배포 설정을 하고 외장 톰캣을 사용하려고 했는데 문제가 생겼다.

현재 개발 중인 프로젝트는 spring boot를 사용하는데 boot 버전마다 기본 톰캣 버전이 다르다.

기본적으로 boot는 내장 톰캣을 사용하는데, 서버에 올려서 사용할 때 외장 톰캣을 사용하기 위해서 톰캣7으로 테스트 했는데 위와 같은 에러가 발생했다.

정확히 문제가 무엇이냐면 boot가 버전마다 내장 톰캣 버전이 다르기 때문에 발생하는 에러다.

  • spring boot 1.2.4 이상 : 내장 톰캣8
  • spring boot 1.2.4 이하 : 내장 톰캣7


로컬 환경에서 외장 톰캣7을 사용했을 경우 발생한 에러

심각: ContainerBase.addChild: start: 

org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1740)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)

at sun.rmi.transport.Transport$1.run(Transport.java:200)

at sun.rmi.transport.Transport$1.run(Transport.java:197)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Transport.java:196)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$254(TCPTransport.java:683)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/741129856.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.AbstractMethodError: org.apache.catalina.core.ApplicationContextFacade.getVirtualServerName()Ljava/lang/String;

at org.apache.tomcat.websocket.server.WsServerContainer.<init>(WsServerContainer.java:147)

at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)

at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5456)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 43 more


6월 17, 2015 9:28:05 오후 org.apache.tomcat.util.modeler.BaseModelMBean invoke

심각: Exception invoking method manageApp

java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1740)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)

at sun.rmi.transport.Transport$1.run(Transport.java:200)

at sun.rmi.transport.Transport$1.run(Transport.java:197)

at java.security.AccessController.doPrivileged(Native Method)

[2015-06-17 09:28:05,551] Artifact spooBlog:war exploded: Error during artifact deployment. See server log for details.

at sun.rmi.transport.Transport.serviceCall(Transport.java:196)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$254(TCPTransport.java:683)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/741129856.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)


jenkins 빌드 시 발생한 에러

ERROR: Build step failed with exception

org.codehaus.cargo.container.ContainerException: Failed to deploy [/home/ubuntu/.jenkins/workspace/Spoon/spooBlog/target/spooBlog-0.0.1-SNAPSHOT.war]

at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:107)

at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:185)

at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)

at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)

at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)

at hudson.FilePath.act(FilePath.java:991)

at hudson.FilePath.act(FilePath.java:969)

at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)

at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)

at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)

at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)

at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)

at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1046)

at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)

at hudson.model.Run.execute(Run.java:1769)

at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)

at hudson.model.ResourceController.execute(ResourceController.java:98)

at hudson.model.Executor.run(Executor.java:374)

Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Deployed application at context path / but context failed to start


at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)

at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:611)

at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:291)

at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:102)

... 17 more

org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Deployed application at context path / but context failed to start


at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)

at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:611)

at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:291)

at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:102)

at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:185)

at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)

at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)

at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)

at hudson.FilePath.act(FilePath.java:991)

at hudson.FilePath.act(FilePath.java:969)

at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)

at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)

at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)

at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)

at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)

at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1046)

at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)

at hudson.model.Run.execute(Run.java:1769)

at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)

at hudson.model.ResourceController.execute(ResourceController.java:98)

at hudson.model.Executor.run(Executor.java:374)

Build step 'Deploy war/ear to a container' marked build as failure

Finished: FAILURE


해결 방법

  1. maven embedded tomcat exclusion
  2. maven properties tomcat version 설정
  3. 외장 톰캣8 사용
진행 중인 프로젝트는 내장 톰캣, 외장 톰캣 아무거나 선택해서 사용하기 위해서 1번 방법은 사용하지 않았다.

maven embedded tomcat exclusion (1번 방법)

        org.springframework.boot
        spring-boot-starter-web
        
            
                org.springframework.boot
                spring-boot-starter-tomcat
            
        
 

위 방법은 앞서 말했듯이 내장 톰캣을 아예 사용할 수 없다.


maven properties tomcat version 설정 (2번 방법)


        7.0.59
 

2번 방법은 굉장히 간단하다. 눈치 챘겠지만 spring boot 1.2.4 버전 이상을 사용할 경우에는 아래와 같이 설정하면 된다.


    8.0.8


3번 방법은 따로 글로 설명할 필요 없이 외장 톰캣8을 사용하면 간단하게 해결가능하다. 사실 3번 방법이 가장 간단하고 권장? 하는 것 같다.


참고 URL


0 Comments
댓글쓰기 폼