[SPRING] 바람둥이에 봄 부트 전쟁 파일 : errorPageFilter는 TomcatEmbeddedServletContainerFactory에 캐스팅 될 수 없습니다.
SPRING바람둥이에 봄 부트 전쟁 파일 : errorPageFilter는 TomcatEmbeddedServletContainerFactory에 캐스팅 될 수 없습니다.
간단한 봄 부팅 응용 프로그램을 내 Tomcat 서버에 배포하기위한 war 파일로 변환하려고하는데이 오류가 계속 발생합니다.
Caused by: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'errorPageFilter': Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.boot.context.web.ErrorPageFilter cannot be cast to org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
이 스프링 부트 응용 프로그램은 항아리로 실행할 때 완벽하게 작동하지만 전쟁을 만들면 오류가 발생합니다. 내가 말할 수있는 한, 나는 이것을 위해 Spring 가이드를 완벽하게 따라왔다 : http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file
이것은 내 응용 프로그램 클래스입니다.
@Configuration
@EnableWebMvc
@ComponentScan({"XXX"})
@EnableAutoConfiguration
@EnableConfigurationProperties
@SpringBootApplication
@EnableAsync
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
이것은 내 build.gradle입니다 :
buildscript {
ext {
springBootVersion = '1.2.6.RELEASE'
}
repositories {
maven { url "http://repo.spring.io/libs-release" }
maven { url "http://repo.spring.io/libs-snapshot" }
mavenCentral()
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'application'
war {
archiveName 'hello-gradle.war'
}
configurations {
providedRuntime
}
compileJava {
targetCompatibility = 1.8
sourceCompatibility = 1.8
}
mainClassName = "XXX.Application"
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "http://maven.springframework.org/milestone" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
compile 'com.fasterxml.jackson.core:jackson-core:2.5.3'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-tomcat'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-aop'
compile 'org.mongodb:mongo-java-driver:3.1.0'
compile 'org.springframework.data:spring-data-mongodb:1.8.0.RELEASE'
compile("org.springframework:spring-context-support")
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.8'
}
이것은 내 catalina.log입니다 :
> 12-Dec-2015 14:53:54.921 INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
> application archive C:\Tomcat8\webapps\hello-gradle.war has finished
> in 4,900 ms 12-Dec-2015 14:53:54.921 INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
> application directory C:\Tomcat8\webapps\docs 12-Dec-2015 14:53:54.993
> INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
> web application directory C:\Tomcat8\webapps\docs has finished in 72
> ms 12-Dec-2015 14:53:54.993 INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
> application directory C:\Tomcat8\webapps\examples 12-Dec-2015
> 14:53:55.239 INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
> web application directory C:\Tomcat8\webapps\examples has finished in
> 246 ms 12-Dec-2015 14:53:55.239 INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
> application directory C:\Tomcat8\webapps\host-manager 12-Dec-2015
> 14:53:55.262 INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
> web application directory C:\Tomcat8\webapps\host-manager has finished
> in 23 ms 12-Dec-2015 14:53:55.262 INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
> application directory C:\Tomcat8\webapps\manager 12-Dec-2015
> 14:53:55.283 INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
> web application directory C:\Tomcat8\webapps\manager has finished in
> 21 ms 12-Dec-2015 14:53:55.284 INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
> application directory C:\Tomcat8\webapps\ROOT 12-Dec-2015 14:53:55.316
> INFO [localhost-startStop-1]
> org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
> web application directory C:\Tomcat8\webapps\ROOT has finished in 32
> ms 12-Dec-2015 14:53:55.328 INFO [main]
> org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler
> ["http-apr-8080"] 12-Dec-2015 14:53:55.337 INFO [main]
> org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler
> ["ajp-apr-8009"] 12-Dec-2015 14:53:55.340 INFO [main]
> org.apache.catalina.startup.Catalina.start Server startup in 5354 ms
> 12-Dec-2015 14:54:25.834 INFO
> [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
> org.apache.catalina.startup.HostConfig.undeploy Undeploying context
> [/hello-gradle] 12-Dec-2015 14:54:25.847 SEVERE
> [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
> org.apache.catalina.startup.ExpandWar.deleteDir
> [C:\Tomcat8\webapps\hello-gradle\WEB-INF\lib] could not be completely
> deleted. The presence of the remaining files may cause problems
> 12-Dec-2015 14:54:25.848 SEVERE
> [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
> org.apache.catalina.startup.ExpandWar.deleteDir
> [C:\Tomcat8\webapps\hello-gradle\WEB-INF] could not be completely
> deleted. The presence of the remaining files may cause problems
> 12-Dec-2015 14:54:25.848 SEVERE
> [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
> org.apache.catalina.startup.ExpandWar.deleteDir
> [C:\Tomcat8\webapps\hello-gradle] could not be completely deleted. The
> presence of the remaining files may cause problems 12-Dec-2015
> 14:54:25.849 SEVERE
> [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
> org.apache.catalina.startup.ExpandWar.delete
> [C:\Tomcat8\webapps\hello-gradle] could not be completely deleted. The
> presence of the remaining files may cause problems 12-Dec-2015
> 14:54:25.851 INFO [localhost-startStop-2]
> org.apache.catalina.startup.HostConfig.deployDirectory Deploying web
> application directory C:\Tomcat8\webapps\hello-gradle 12-Dec-2015
> 14:54:27.196 INFO [localhost-startStop-2]
> org.apache.catalina.startup.HostConfig.deployDirectory Deployment of
> web application directory C:\Tomcat8\webapps\hello-gradle has finished
> in 1,345 ms 12-Dec-2015 14:54:35.176 INFO [http-apr-8080-exec-12]
> org.apache.catalina.startup.HostConfig.undeploy Undeploying context
> [/hello-gradle] 12-Dec-2015 14:54:35.203 INFO [http-apr-8080-exec-12]
> org.apache.catalina.startup.HostConfig.deployWAR Deploying web
> application archive C:\Tomcat8\webapps\hello-gradle.war 12-Dec-2015
> 14:54:39.295 SEVERE [http-apr-8080-exec-12]
> org.apache.catalina.core.ContainerBase.addChildInternal
> ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException: Failed to start component
> [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hello-gradle]]
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
> at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
> at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
> at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
> at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
> at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:466)
> at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1583)
> 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:300)
> at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
> at
> com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
> at
> org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
> at
> org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:288)
> at
> org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:209)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
> at
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
> at
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
> at
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
> at
> org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2500)
> at
> org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2489)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> at java.lang.Thread.run(Thread.java:745) Caused by:
> org.springframework.context.ApplicationContextException: Unable to
> start embedded container; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'errorPageFilter': Initialization of bean
> failed; nested exception is java.lang.ClassCastException:
> org.springframework.boot.context.web.ErrorPageFilter cannot be cast to
> org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
> at
> org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
> at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
> at
> org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
> at
> org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687)
> at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
> at
> org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:133)
> at
> org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:124)
> at
> org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:81)
> at
> org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
> at
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5244)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> ... 45 more Caused by:
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'errorPageFilter': Initialization of bean
> failed; nested exception is java.lang.ClassCastException:
> org.springframework.boot.context.web.ErrorPageFilter cannot be cast to
> org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
> at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
> at
> org.springframework.boot.context.embedded.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:209)
> at
> org.springframework.boot.context.embedded.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:165)
> at
> org.springframework.boot.context.embedded.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:160)
> at
> org.springframework.boot.context.embedded.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:143)
> at
> org.springframework.boot.context.embedded.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:74)
> at
> org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getServletContextInitializerBeans(EmbeddedWebApplicationContext.java:234)
> at
> org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:221)
> at
> org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:84)
> at
> org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:206)
> at
> org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162)
> at
> org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
> ... 55 more Caused by: java.lang.ClassCastException:
> org.springframework.boot.context.web.ErrorPageFilter cannot be cast to
> org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
> at
> com.futureprocessing.spring.ContainerConfiguration$1.customize(ContainerConfiguration.java:34)
> at
> org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:67)
> at
> org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:54)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
> ... 71 more
>
> 12-Dec-2015 14:54:39.321 SEVERE [http-apr-8080-exec-12]
> org.apache.catalina.startup.HostConfig.deployWAR Error deploying web
> application archive C:\Tomcat8\webapps\hello-gradle.war
> java.lang.IllegalStateException: ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException: Failed to start component
> [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hello-gradle]]
> at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
> at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
> at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
> at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
> at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:466)
> at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1583)
> 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:300)
> at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
> at
> com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
> at
> org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
> at
> org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:288)
> at
> org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:209)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
> at
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
> at
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
> at
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
> at
> org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2500)
> at
> org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2489)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> at java.lang.Thread.run(Thread.java:745)
>
> 12-Dec-2015 14:54:39.327 INFO [http-apr-8080-exec-12]
> org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
> application archive C:\Tomcat8\webapps\hello-gradle.war has finished
> in 4,123 ms
그것은 오류가 ContainerConfiguration.java라는 자바 파일에서 발생했다 :
@Configuration
public class ContainerConfiguration {
@Bean
EmbeddedServletContainerCustomizer containerCustomizer(
//all taken from the application.properties file
@Value("${keystore.file}") String keystoreFile,
@Value("${server.port}") final String serverPort,
@Value("${keystore.pass}") final String keystorePass)
throws Exception {
// This is boiler plate code to setup https on embedded Tomcat
// with Spring Boot:
final String absoluteKeystoreFile = new File(keystoreFile)
.getAbsolutePath();
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
tomcat.addConnectorCustomizers(connector -> {
connector.setPort(Integer.parseInt(serverPort));
connector.setSecure(true);
connector.setScheme("https");
Http11NioProtocol proto = (Http11NioProtocol) connector
.getProtocolHandler();
proto.setSSLEnabled(true);
proto.setKeystoreFile(absoluteKeystoreFile);
proto.setKeystorePass(keystorePass);
proto.setKeystoreType("JKS");
proto.setKeyAlias("abcd");
});
}
};
}
}
오류는 다음 행에 있습니다.
tomcat.addConnectorCustomizers(connector -> {
connector.setPort(Integer.parseInt(serverPort));
connector.setSecure(true);
connector.setScheme("https");
errorPageFilter가 TomcatEmbeddedServletContainerFactory에 캐스팅되는 방법을 얻지 못합니까?
누구든지이 오류를 해결할 수있는 방법을 알고 있습니까?
편집하다:
또한이 오류를 보여주기 위해 간단한 SpringBoot 테스트 앱을 만들었습니다. https://github.com/Winghin2517/testSpringBootTomcat에서 찾을 수 있습니다.
github repo에는 두 가지 클래스 만 있습니다.
ContainerConfiguration을 주석 처리하고 war 파일을 작성한 다음 tomcat 서버에 업로드하면 완벽하게 작동합니다. ContainerConfiguration의 주석 처리를 제거하고 war 파일을 빌드하고 업로드하면 오류가 발생합니다.
해결법
-
==============================
1.사용자 정의 프로그램으로 SSL 연결을 사용자 정의하려고합니다. 임베디드 톰캣 서버를 시작하면 100 % 유효합니다. 따라서 흐름은 다음과 같습니다.
사용자 정의 프로그램으로 SSL 연결을 사용자 정의하려고합니다. 임베디드 톰캣 서버를 시작하면 100 % 유효합니다. 따라서 흐름은 다음과 같습니다.
EmbeddedServletContainerCustomizer의 JavaDocs에서
반대로 이미 실행중인 Tomcat에서 이러한 작업을 사용자 정의 할 수는 없습니다.
이미 war 파일을 배포 한 상태에서 이미 실행중인 tomcat의 포트 / 주소를 변경할 수있는 옵션이있는 경우 어떤 종류의 보안 문제가 발생할 수 있다고 상상해보십시오.
ssl 커넥터를 사용자 정의해야하는 경우에는 tomcat의 xml 구성에 대해 자세히 알아야합니다.
크고 간단한 안내서는 여기에서 찾을 수 있습니다.
-
==============================
2.임베디드 Tomcat을 외부 컨테이너에 배포하려는 경우 구성하려는 이유는 무엇입니까? 나는 비슷한 문제가 있었고 마침내 나를 위해 일한 것은 Tomcat 스타터를 프로젝트 의존성에서 완전히 제외시키는 것이었다. spring-boot-starter-tomcat은 spring-boot-starter-web의 의존성이므로 다음과 같이 사용하십시오 :
임베디드 Tomcat을 외부 컨테이너에 배포하려는 경우 구성하려는 이유는 무엇입니까? 나는 비슷한 문제가 있었고 마침내 나를 위해 일한 것은 Tomcat 스타터를 프로젝트 의존성에서 완전히 제외시키는 것이었다. spring-boot-starter-tomcat은 spring-boot-starter-web의 의존성이므로 다음과 같이 사용하십시오 :
compile ('org.springframework.boot:spring-boot-starter-web') { exclude module: 'spring-boot-starter-tomcat' }
물론 spring-boot-starter-tomcat을 명시 적으로 가져 오는 줄을 삭제하십시오 (임베디드 모드에서도 필요하지는 않습니다).
두 가지 방법으로 앱을 배포 할 수있게하려는 경우 문제가 발생할 수 있습니다. 제 경우에는 걱정할 필요가 없습니다.
from https://stackoverflow.com/questions/34240159/spring-boot-war-file-on-tomcat-errorpagefilter-cannot-be-cast-to-tomcatembedded by cc-by-sa and MIT license
'SPRING' 카테고리의 다른 글
[SPRING] 두 개의 MessageProducerSpec에서 Spring Integration Flow를 생성하는 방법은 무엇입니까? (0) | 2019.05.15 |
---|---|
[SPRING] :: 0에서 오류가 참조 된 pointcut 주석을 찾을 수 없습니다. (0) | 2019.05.15 |
[SPRING] JBoss (6.2.0 GA)에서 EJB Jar에서 잭슨 2 주석이 무시되었습니다. (0) | 2019.05.15 |
[SPRING] keycloak을 사용하여 웹 페이지를 제공하는 클라이언트와 함께 예약 된 작업을 사용하려면 어떻게해야합니까? (0) | 2019.05.15 |
[SPRING] Spring 데이터 나머지 : 다른 객체의 키로 검색하는 방법? (0) | 2019.05.15 |