Translate

[Java][Spring Boot] Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean 에러




Spring Boot Version: 1.3.0.RELEASE



증상

개발한 프로그램을 IntelliJ 에서 구동 시 문제없이 구동이 되나 실행가능한 jar 파일로 만든 후 구동 시 아래와 같은 로그가 발생하며 프로그램이 종료된다.


00:43:51.874 [main] INFO  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4157f54e: startup date [Sun Jan 31 00:43:51 KST 2016]; root of context hierarchy
'
00:43:53.016 [main] WARN  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
00:43:53.027 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[testApp.jar:na]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[testApp.jar:na]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[testApp.jar:na]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [testApp.jar:na]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [testApp.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [testApp.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [testApp.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [testApp.jar:na]
at {PackageName}.{ClassName}.main(MsPushSchApplication.java:14) [testApp.jar:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183) ~[testApp.jar:na]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156) ~[testApp.jar:na]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[testApp.jar:na]
... 8 common frames omitted







원인

Spring Boot 를 포함한 의존성 jar 파일을 만들려는 jar 파일에 모두 포함되도록 설정하여 1개의 jar 파일을 생성 시 위와같은 증상이 발생하는 것으로 보아 IDE 버그나 CLASS 충돌로 의심이 된다.

=================================
2016.02.02 업데이트
1004lucifer
Maven 을 사용하지 않고 IDE(Eclipse, IntelliJ) 툴에서 바로 Export 받았기 때문에 문제가 된 것이며 Maven 을 통해 빌드하여 jar 파일 생성 시 정상적으로 되는것을 확인했다.
=================================








해결방법

반나절 넘게 해결방법을 찾아봤지만 찾을 수 없어서 결국 의존성 jar 파일을 합치지 않는 방법으로 생성 후 실행 하니 정상적으로 프로그램이 구동되었다.

* 나와 동일한 증상을 가지고 있는 사람이 있었다.
http://stackoverflow.com/questions/35078117/error-unable-to-start-embeddedwebapplicationcontext-due-to-missing-embeddedser


PS.
IntelliJ 에서 jar 파일을 만들기 위해 'artifact' 생성 시 아래와 같이 설정을 변경해 준다.
(IntelliJ 에서 'META-INF/MANIFEST.MF' 버그가 있다. => 링크)




=================================
2016.02.02 업데이트

Maven 을 사용해서 빌드하여 jar 파일 생성 시 정상적으로 구동 되는것을 확인했다.

IntelliJ 에서 아래와 같이 빌드를 했다.



=================================


댓글