해결된 질문
작성
·
1K
·
수정됨
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 사용해서 톰캣 돌리는건 돼서
포기하고 있었는데 감사합니다. 다시 복습해야겠네요