Home > Enterprise >  A child container failed during start SpringBoot project converted into Jar
A child container failed during start SpringBoot project converted into Jar

Time:05-24

I come back again with one of my problem.

I have developped a SpringBoot app but I have now some errors. When I launch the app with Eclipse I don't have any error. But when I convert it in a runnable jar file and I lauch it I have these errors : I don't understand why is it working with eclipse and not in a jar file.

:: Spring Boot ::(v2.6.7)

2022-05-19 08:05:29.366  INFO 5520 --- [main] com.example.demo.DemoApplication: Starting DemoApplication using Java 1.8.0_333 on machinetest with PID 5520 (started by tdriss in C:\Users\tdriss\Desktop\Documents)
2022-05-19 08:05:29.378  INFO 5520 --- [main] com.example.demo.DemoApplication: No active profile set, falling back to 1 default profile: "default"
2022-05-19 08:06:00.841  INFO 5520 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-05-19 08:06:01.501  INFO 5520 --- [main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-05-19 08:06:01.501  INFO 5520 --- [main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.62]
2022-05-19 08:06:01.811 ERROR 5520 --- [main] org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.StandardRoot@14d81f2c]
        at java.util.concurrent.FutureTask.report(Unknown Source) [na:1.8.0_333]
        at java.util.concurrent.FutureTask.get(Unknown Source) [na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:926) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_333]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) [na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:479) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) [jar:rsrc:spring-context-5.3.19.jar!/:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at com.example.demo.DemoApplication.main(DemoApplication.java:22) [rsrc:./:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_333]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_333]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_333]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_333]
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61) [OPAL2022tomcatenable.jar:na]
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.StandardRoot@14d81f2c]
        at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:139) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:173) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4885) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5023) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_333]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) [na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 34 common frames omitted
Caused by: java.lang.Error: factory already defined
        at java.net.URL.setURLStreamHandlerFactory(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.<init>(TomcatURLStreamHandlerFactory.java:130) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.getInstanceInternal(TomcatURLStreamHandlerFactory.java:53) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.register(TomcatURLStreamHandlerFactory.java:77) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.StandardRoot.registerURLStreamHandlerFactory(StandardRoot.java:711) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.StandardRoot.initInternal(StandardRoot.java:698) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 44 common frames omitted

2022-05-19 08:06:01.820 ERROR 5520 --- [main] org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
        at java.util.concurrent.FutureTask.report(Unknown Source) ~[na:1.8.0_333]
        at java.util.concurrent.FutureTask.get(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:926) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:479) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) [jar:rsrc:spring-context-5.3.19.jar!/:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at com.example.demo.DemoApplication.main(DemoApplication.java:22) [rsrc:./:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_333]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_333]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_333]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_333]
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61) [OPAL2022tomcatenable.jar:na]
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:938) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.FutureTask.run(Unknown Source) ~[na:1.8.0_333]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 26 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.StandardRoot@14d81f2c]
        at java.util.concurrent.FutureTask.report(Unknown Source) ~[na:1.8.0_333]
        at java.util.concurrent.FutureTask.get(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:926) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 34 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.StandardRoot@14d81f2c]
        at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:139) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:173) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4885) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5023) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.FutureTask.run(Unknown Source) ~[na:1.8.0_333]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 34 common frames omitted
Caused by: java.lang.Error: factory already defined
        at java.net.URL.setURLStreamHandlerFactory(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.<init>(TomcatURLStreamHandlerFactory.java:130) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.getInstanceInternal(TomcatURLStreamHandlerFactory.java:53) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.register(TomcatURLStreamHandlerFactory.java:77) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.StandardRoot.registerURLStreamHandlerFactory(StandardRoot.java:711) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.StandardRoot.initInternal(StandardRoot.java:698) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) [jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 44 common frames omitted

2022-05-19 08:06:01.830  INFO 5520 --- [main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-05-19 08:06:03.335  WARN 5520 --- [main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2022-05-19 08:06:03.363  INFO 5520 --- [main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-05-19 08:06:03.428 ERROR 5520 --- [main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163) ~[jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[jar:rsrc:spring-context-5.3.19.jar!/:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) [jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at com.example.demo.DemoApplication.main(DemoApplication.java:22) [rsrc:./:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_333]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_333]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_333]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_333]
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61) [OPAL2022tomcatenable.jar:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142) ~[jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) ~[jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:479) ~[jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) ~[jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182) ~[jar:rsrc:spring-boot-2.6.7.jar!/:na]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160) ~[jar:rsrc:spring-boot-2.6.7.jar!/:na]
        ... 13 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:938) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) ~[jar:rsrc:spring-boot-2.6.7.jar!/:na]
        ... 18 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
        at java.util.concurrent.FutureTask.report(Unknown Source) ~[na:1.8.0_333]
        at java.util.concurrent.FutureTask.get(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:926) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 26 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:938) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.FutureTask.run(Unknown Source) ~[na:1.8.0_333]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 26 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.StandardRoot@14d81f2c]
        at java.util.concurrent.FutureTask.report(Unknown Source) ~[na:1.8.0_333]
        at java.util.concurrent.FutureTask.get(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:926) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 34 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.StandardRoot@14d81f2c]
        at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:139) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:173) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4885) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5023) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.FutureTask.run(Unknown Source) ~[na:1.8.0_333]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 34 common frames omitted
Caused by: java.lang.Error: factory already defined
        at java.net.URL.setURLStreamHandlerFactory(Unknown Source) ~[na:1.8.0_333]
        at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.<init>(TomcatURLStreamHandlerFactory.java:130) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.getInstanceInternal(TomcatURLStreamHandlerFactory.java:53) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.register(TomcatURLStreamHandlerFactory.java:77)~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.StandardRoot.registerURLStreamHandlerFactory(StandardRoot.java:711)~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.webresources.StandardRoot.initInternal(StandardRoot.java:698) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) ~[jar:rsrc:tomcat-embed-core-9.0.62.jar!/:na]
        ... 44 common frames omitted

I have already try to resolve this by adding

TomcatURLStreamHandlerFactory.disable();

The problem is solved with that but when I want to make an api request on localhost:8080 in my browser, I have this in the console

2022-05-19 09:29:03.166  INFO 972 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-05-19 09:29:03.195  INFO 972 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-05-19 09:29:03.212  INFO 972 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 13 ms

And I have a 404 Error in my browser, I precise that I don't have this problem with the project on eclipse.

And this is my POM file

https://codebeautify.org/alleditor/y2226566c

CodePudding user response:

The problem was just linked with the version of Java and the Java library version. There was also a problem with the export in jar, it was necessary to choose copy required libraries into a sub folder and not the two other options, when we makethe runnable jar file export.

  • Related