인프런 커뮤니티 질문&답변

톨게이트님의 프로필 이미지
톨게이트

작성한 질문수

스프링 부트 - 핵심 원리와 활용

내장 톰캣2-서블릿 (톰켓 실행 에러)

해결된 질문

작성

·

992

·

수정됨

0

자료 코드 복붙해도 에러가 그대로네요...

> Task :EmbedTomcatServletMain.main() FAILED
EmbedTomcatServletMain.main
7�� 14, 2023 1:53:21 ���� org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
7�� 14, 2023 1:53:21 ���� org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
7�� 14, 2023 1:53:21 ���� org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/10.1.5]
7�� 14, 2023 1:53:21 ���� org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:923)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:886)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:252)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:926)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:485)
	at hello.embed.EmbedTomcatServletMain.main(EmbedTomcatServletMain.java:21)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]
	at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
	at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4829)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4962)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
	... 16 more
Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\Users\�Ӹ�\OneDrive\���� ȭ��\Spring\start\embed\tomcat.8080\webapps\] is not valid
	at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:777)
	at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:734)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	... 25 more

7�� 14, 2023 1:53:21 ���� org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:923)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:252)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:926)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:485)
	at hello.embed.EmbedTomcatServletMain.main(EmbedTomcatServletMain.java:21)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:935)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:886)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
	... 8 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:923)
	... 16 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]
	at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
	at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4829)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4962)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]

	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
	... 16 more
Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\Users\�Ӹ�\OneDrive\���� ȭ��\Spring\start\embed\tomcat.8080\webapps\] is not valid
	at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:777)
	at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:734)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\Users\�Ӹ�\OneDrive\���� ȭ��\Spring\start\embed\tomcat.8080\webapps\] is not valid

	... 25 more

Exception in thread "main" org.apache.catalina.LifecycleException: A child container failed during start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:935)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:252)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:926)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:485)
	at hello.embed.EmbedTomcatServletMain.main(EmbedTomcatServletMain.java:21)
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:923)
	... 8 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:935)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:886)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start

	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
	... 8 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]

	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:923)
	... 16 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]

	at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
	at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4829)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4962)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\Users\�Ӹ�\OneDrive\���� ȭ��\Spring\start\embed\tomcat.8080\webapps\] is not valid

	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
	... 16 more
Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\Users\�Ӹ�\OneDrive\���� ȭ��\Spring\start\embed\tomcat.8080\webapps\] is not valid
	at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:777)
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start

	at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:734)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	... 25 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start


Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]

Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@35cabb2a]

Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\Users\�Ӹ�\OneDrive\���� ȭ��\Spring\start\embed\tomcat.8080\webapps\] is not valid

Execution failed for task ':EmbedTomcatServletMain.main()'.
> Process 'command 'C:/Users/java/jdk-17.0.7/bin/java.exe'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

사진은 복붙한 코드입니다.

마지막 줄 tomcat.start()만 없으면, 에러는 안뜹니다.
LifecycleException 에러로 보이는데,,

https://www.inflearn.com/questions/5283/%EC%8B%AC%EA%B0%81-a-child-container-failed-during-start
유사한
에러가 이거 같은데, 봐도 기존 코드가 달라 해결법을 모르겠네요..

윈도우 11 // 인텔리제이 23.01 // 외장 라이브러리 : spring-core-6.0.4

답변 2

2

김영한님의 프로필 이미지
김영한
지식공유자

안녕하세요. 톨게이트님

내장 톰캣2 - 서블릿 마지막 부분을 보면 다음 내용이 추가되어 있는데요. 이 부분을 확인해주세요.

 

주의

실행시 특정 환경에서 다음과 같은 오류가 발생하는 경우가 있다.

Caused by: java.lang.IllegalArgumentException: The main resource set specified [...\tomcat\tomcat.8080\webapps] is not valid

이런 경우에는 다음을 참고해서 코드를 추가해주면 된다.

//서블릿 등록

Context context = tomcat.addContext("", "/");

//== 코드 추가 시작==

File docBaseFile = new File(context.getDocBase());

if (!docBaseFile.isAbsolute()) {

    docBaseFile = new File(((org.apache.catalina.Host) context.getParent()).getAppBaseFile(), docBaseFile.getPath());

}

docBaseFile.mkdirs();

//== 코드 추가 종료==

tomcat.addServlet("", "helloServlet", new HelloServlet());

context.addServletMappingDecoded("/hello-servlet", "helloServlet");

tomcat.start();

감사합니다.

 

톨게이트님의 프로필 이미지
톨게이트
질문자

와 ㅠㅠ 드디어 실행됐습니다.
그냥 spring boot 사용해서 톰캣 돌리는건 돼서
포기하고 있었는데 감사합니다. 다시 복습해야겠네요

0

안녕하세요. gleam님, 공식 서포터즈 OMG입니다.

에러메시지를 확인해보니 OneDrive에 프로그램/파일 등을 설치하고 사용하고 계신것 같습니다.

경험상 동일한 오류는 아니지만 OneDrive안에 저장하던 것을 Local PC (C드라이브 경로)에 옮겨서 해결한적이 있어 Onedrive에 설치한 것을 C경로 로 옮겨서 확인 부탁드립니다.

해결이 안될 경우 댓글 남겨주세요 :)

 

감사합니다.

톨게이트님의 프로필 이미지
톨게이트
질문자

image
옮겨봤는데도 에러가 그대로네요 ㅠ

톨게이트님의 프로필 이미지
톨게이트

작성한 질문수

질문하기