following scenario:
SCENARIO:
I developed a Microservice Application with Spring Boot 2 on eclipse. The application works fine. Now I want to run it with docker. In addition, the Image has to interact with a mysql db.
To build the docker image I use the com.spotify plugin in my pom.xml.
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<imageName>usermanagementservice</imageName>
<baseImage>openjdk:8-jre-alpine</baseImage>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<!-- copy the service's jar file from target into the root directory of the image -->
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
this create a docker file and the .jar file in my target folder:
Docker file:
FROM java:8
ENTRYPOINT ["java", "-jar", "/UserManagementService-0.0.1-SNAPSHOT.jar"]
So now I want to run the project with docker compose:
> compose file: version: '2.1' services: usermanagement-service:
> image: usermanagementservice
> restart: on-failure
> ports:
> - "7778:7778"
> depends_on:
> mysqldb:
> condition: service_healthy
>
> mysqldb:
> image: mysql
> volumes:
> - ./mysql-data:/var/lib/mysql
> - ./mysql-init-files:/docker-entrypoint-initdb.d
> restart: always
> environment:
> MYSQL_ROOT_PASSWORD: root
> MYSQL_DATABASE: userdb
> MYSQL_USER: testuser
> MYSQL_PASSWORD: testuser
> expose:
> - "3306"
> healthcheck:
> test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
> timeout: 3s
> retries: 10
Expected behaviour
The usermanagementservice should wait until my sql db is initialized and ready. Once this is done, the service should connect to it and start.
Problem:
The part with the init mysql works but my usermanagementservice crashes on startup. I get a load of unsatisfied bean exceptions.
Stacktrace:
usermanagement-service_1 | ERROR 04-02-2019 08:51:18,870 main o.s.b.w.e.t.TomcatStarter: Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'customBasicAuthenticat
ionFilter': Unsatisfied dependency expressed through field 'mobileUserController'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mobileUserController': Unsatisfied dependency expressed thro
ugh field 'restTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'doctorController': Unsatisfied dependency expressed through field 'restTemplate'; nested exception is org.springframe
work.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'restTemplate': Requested bean is currently in creation: Is there an unresolvable circular reference?
usermanagement-service_1 | Feb 04, 2019 8:51:18 AM org.apache.catalina.core.StandardService stopInternal
usermanagement-service_1 | INFO: Stopping service [Tomcat]
usermanagement-service_1 | Feb 04, 2019 8:51:18 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
usermanagement-service_1 | WARNING: The web application [ROOT] appears to have started a thread named [HikariPool-1 housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
usermanagement-service_1 | sun.misc.Unsafe.park(Native Method)
usermanagement-service_1 | java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
usermanagement-service_1 | java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
usermanagement-service_1 | java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
usermanagement-service_1 | java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
usermanagement-service_1 | java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
usermanagement-service_1 | java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
usermanagement-service_1 | java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
usermanagement-service_1 | java.lang.Thread.run(Thread.java:748)
usermanagement-service_1 | Feb 04, 2019 8:51:18 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
usermanagement-service_1 | WARNING: The web application [ROOT] appears to have started a thread named [HikariPool-1 connection adder] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
usermanagement-service_1 | sun.misc.Unsafe.park(Native Method)
usermanagement-service_1 | java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
usermanagement-service_1 | java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
usermanagement-service_1 | java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
usermanagement-service_1 | java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1073)
usermanagement-service_1 | java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
usermanagement-service_1 | java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
usermanagement-service_1 | java.lang.Thread.run(Thread.java:748)
usermanagement-service_1 | WARN 04-02-2019 08:51:18,918 main o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextExcep
tion: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
usermanagement-service_1 | INFO 04-02-2019 08:51:18,921 main o.s.o.j.LocalContainerEntityManagerFactoryBean: Closing JPA EntityManagerFactory for persistence unit 'default'
usermanagement-service_1 | INFO 04-02-2019 08:51:18,925 main c.z.h.HikariDataSource: HikariPool-1 - Shutdown initiated...
usermanagement-service_1 | INFO 04-02-2019 08:51:18,947 main c.z.h.HikariDataSource: HikariPool-1 - Shutdown completed.
usermanagement-service_1 | INFO 04-02-2019 08:51:18,985 main o.s.b.a.l.ConditionEvaluationReportLoggingListener:
usermanagement-service_1 |
usermanagement-service_1 | Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
usermanagement-service_1 | ERROR 04-02-2019 08:51:18,990 main o.s.b.SpringApplication: Application run failed
usermanagement-service_1 | org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
usermanagement-service_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155)
usermanagement-service_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540)
usermanagement-service_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
usermanagement-service_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
usermanagement-service_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
usermanagement-service_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
usermanagement-service_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
usermanagement-service_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
usermanagement-service_1 | at com.usermanagement.UserManagementServiceApplication.main(UserManagementServiceApplication.java:21)
usermanagement-service_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
usermanagement-service_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
usermanagement-service_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
usermanagement-service_1 | at java.lang.reflect.Method.invoke(Method.java:498)
usermanagement-service_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
usermanagement-service_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
usermanagement-service_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
usermanagement-service_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
usermanagement-service_1 | Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
usermanagement-service_1 | at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:125)
usermanagement-service_1 | at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86)
usermanagement-service_1 | at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:414)
usermanagement-service_1 | at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174)
usermanagement-service_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179)
usermanagement-service_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152)
usermanagement-service_1 | ... 16 more
usermanagement-service_1 | Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customBasicAuthenticationFilter': Unsatisfied dependency expressed through field 'mobileUserController'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mobileUserController': Unsatisfied dependency expressed through field 'restTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyE
xception: Error creating bean with name 'doctorController': Unsatisfied dependency expressed through field 'restTemplate'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'restTemplate': Req
uested bean is currently in creation: Is there an unresolvable circular reference?
usermanagement-service_1 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
usermanagement-service_1 | at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
usermanagement-service_1 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
usermanagement-service_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
usermanagement-service_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
usermanagement-service_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
usermanagement-service_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
usermanagement-service_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
usermanagement-service_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
usermanagement-service_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
usermanagement-service_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:236)
usermanagement-service_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:192)
usermanagement-service_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:187)
usermanagement-service_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:169)
usermanagement-service_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:89)
usermanagement-service_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:250)
usermanagement-service_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:237)
usermanagement-service_1 | at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54)
usermanagement-service_1 | at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5098)
usermanagement-service_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
usermanagement-service_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429)
usermanagement-service_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
usermanagement-service_1 | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
usermanagement-service_1 | at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
usermanagement-service_1 | at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
usermanagement-service_1 | at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
usermanagement-service_1 | at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
usermanagement-service_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
usermanagement-service_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429)
usermanagement-service_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
usermanagement-service_1 | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
usermanagement-service_1 | at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
usermanagement-service_1 | at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
usermanagement-service_1 | at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
usermanagement-service_1 | at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261)
usermanagement-service_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
usermanagement-service_1 | at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
usermanagement-service_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
usermanagement-service_1 | at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
usermanagement-service_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
usermanagement-service_1 | at org.apache.catalina.startup.Tomcat.start(Tomcat.java:370)
usermanagement-service_1 | at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:106)
usermanagement-service_1 | ... 21 more
Attempts
I followed some online tutorials with different Docker Files and so on. But nothing worked.
I guess it might be a Problem ob the entry point because Beans are created before application startup as singletons.
Is there any import in my dockerfile I have to add or any modification on the entrypoint?
Thanks in advance
It causes the same stacktrace.
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customBasicAuthenticationFilter': Unsatisfied dependency expressed through field 'mobileUserController'; nested exception is org.springframework.beans.factory.Unsat
isfiedDependencyException: Error creating bean with name 'mobileUserController': Unsatisfied dependency expressed through field 'restTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'doctorContr
oller': Unsatisfied dependency expressed through field 'restTemplate'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'restTemplate': Requested bean is currently in creation: Is there an unresolvable c
ircular reference?
UPDATE:
POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.usermanagement</groupId>
<artifactId>UserManagementService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>UserManagementService</name>
<description>Microservice for usermanagement</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
<!-- <dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1</version>
</dependency> -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<imageName>usermanagementservice</imageName>
<baseImage>openjdk:8-jre-alpine</baseImage>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<!-- copy the service's jar file from target into the root directory of the image -->
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</project>
Related
I just Created this file from spring.initializer.
It is a brand new file. I am trying to run this because I have a previous project that have similar type of error. So I thought of making a new project and see if any error comes. below i the Error
My Error
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.3)
2022-09-08 20:15:36.021 INFO 8344 --- [ main] c.m.w.webproject.WebProjectApplication : Starting WebProjectApplication using Java 17.0.4 on DESKTOP-4LDNK11 with PID 8344 (C:\Users\Lenovo\Documents\JAVA\WebProject\target\classes started by Lenovo in C:\Users\Lenovo\Documents\JAVA\WebProject)
2022-09-08 20:15:36.027 INFO 8344 --- [ main] c.m.w.webproject.WebProjectApplication : No active profile set, falling back to 1 default profile: "default"
2022-09-08 20:15:37.266 INFO 8344 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-09-08 20:15:37.297 INFO 8344 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 11 ms. Found 0 JPA repository interfaces.
2022-09-08 20:15:38.269 INFO 8344 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-09-08 20:15:38.283 INFO 8344 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-09-08 20:15:38.284 INFO 8344 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-09-08 20:15:38.489 INFO 8344 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-09-08 20:15:38.490 INFO 8344 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2328 ms
2022-09-08 20:15:38.732 WARN 8344 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/boot/model/naming/CamelCaseToUnderscoresNamingStrategy
2022-09-08 20:15:38.737 INFO 8344 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-09-08 20:15:38.755 INFO 8344 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-09-08 20:15:38.789 ERROR 8344 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/boot/model/naming/CamelCaseToUnderscoresNamingStrategy
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.22.jar:5.3.22]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.22.jar:5.3.22]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.22.jar:5.3.22]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.3.jar:2.7.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.3.jar:2.7.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.3.jar:2.7.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.3.jar:2.7.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.3.jar:2.7.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.3.jar:2.7.3]
at com.mandeep.web.webproject.WebProjectApplication.main(WebProjectApplication.java:10) ~[classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/boot/model/naming/CamelCaseToUnderscoresNamingStrategy
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.22.jar:5.3.22]
... 19 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/hibernate/boot/model/naming/CamelCaseToUnderscoresNamingStrategy
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties$Naming.lambda$applyNamingStrategies$1(HibernateProperties.java:178) ~[spring-boot-autoconfigure-2.7.3.jar:2.7.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties$Naming.lambda$applyNamingStrategy$2(HibernateProperties.java:187) ~[spring-boot-autoconfigure-2.7.3.jar:2.7.3]
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220) ~[na:na]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties$Naming.applyNamingStrategy(HibernateProperties.java:187) ~[spring-boot-autoconfigure-2.7.3.jar:2.7.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties$Naming.applyNamingStrategies(HibernateProperties.java:177) ~[spring-boot-autoconfigure-2.7.3.jar:2.7.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties$Naming.access$000(HibernateProperties.java:146) ~[spring-boot-autoconfigure-2.7.3.jar:2.7.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties.getAdditionalProperties(HibernateProperties.java:102) ~[spring-boot-autoconfigure-2.7.3.jar:2.7.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties.determineHibernateProperties(HibernateProperties.java:95) ~[spring-boot-autoconfigure-2.7.3.jar:2.7.3]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.getVendorProperties(HibernateJpaConfiguration.java:132) ~[spring-boot-autoconfigure-2.7.3.jar:2.7.3]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.entityManagerFactory(JpaBaseConfiguration.java:132) ~[spring-boot-autoconfigure-2.7.3.jar:2.7.3]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.22.jar:5.3.22]
... 20 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
... 35 common frames omitted
Process finished with exit code 1
My POM.XML
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.mandeep.web.webproject</groupId>
<artifactId>WebProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>WebProject</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
My properties file
spring.datasource.url=jdbc:mysql://localhost:3306/WebProject
spring.datasource.username=root
spring.datasource.password=Sciman$#2569
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
connection.pool.initialPoolSize=1
connection.pool.minPoolSize=1
connection.pool.maxPoolSize=20
connection.pool.maxIdleTime=3000
My Application File
package com.mandeep.web.webproject;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class WebProjectApplication {
public static void main(String[] args) {
SpringApplication.run(WebProjectApplication.class, args);
}
}
I See this
java.lang.NoClassDefFoundError: org/hibernate/boot/model/naming/CamelCaseToUnderscoresNamingStrategy
Caused by: java.lang.ClassNotFoundException: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
Couple of solutions
Check if you have this class CamelCaseToUnderscoresNamingStrategy under your Maven dependencies -> org.hibernate dependency -> path boot/model/naming
If you can't locate that class, add a hibernate dependency with version >= 5.5.4
Check if this article helps Spring boot application and hibernate are using different naming strategies
I deleted the Hibernate folder from C:\Users{User}.m2\repository.
Then I added below dependency in the pom file.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.5.4.Final</version>
</dependency>
Also add version to maven plugin -:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
**<version>${project.parent.version}</version>**
</plugin>
Do the above steps if anyone gets the same Error.
I want to deploy my springboot rest api to Heroku, I have connected my github and heroku, after I pushed my change to github. Heroku can build successfully, but when I open the application on Heroku, I got the following errors
2020-04-20T03:58:24.636881+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.636881+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.636881+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.636881+00:00 app[web.1]: at com.doggydoggy.DoggyDoggyApplication.main(DoggyDoggyApplication.java:12) [classes!/:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.636881+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_242-heroku]
2020-04-20T03:58:24.636882+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_242-heroku]
2020-04-20T03:58:24.636882+00:00 app[web.1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_242-heroku]
2020-04-20T03:58:24.636882+00:00 app[web.1]: at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_242-heroku]
2020-04-20T03:58:24.636882+00:00 app[web.1]: at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [DoggyDoggyUsers-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.636882+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [DoggyDoggyUsers-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.636883+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [DoggyDoggyUsers-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.636883+00:00 app[web.1]: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [DoggyDoggyUsers-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.636883+00:00 app[web.1]: Caused by: javax.servlet.ServletException: java.lang.IllegalStateException:
2020-04-20T03:58:24.636883+00:00 app[web.1]:
2020-04-20T03:58:24.636883+00:00 app[web.1]: ======================================================================================================
2020-04-20T03:58:24.636884+00:00 app[web.1]: Vaadin requires node.js & npm to be installed. Please install the latest LTS version of node.js (with npm) either by:
2020-04-20T03:58:24.636884+00:00 app[web.1]: 1) following the https://nodejs.org/en/download/ guide to install it globally. This is the recommended way.
2020-04-20T03:58:24.636884+00:00 app[web.1]: 2) running the following Maven plugin goal to install it in this project:
2020-04-20T03:58:24.636884+00:00 app[web.1]: $ mvn com.github.eirslett:frontend-maven-plugin:1.7.6:install-node-and-npm -DnodeVersion="v12.14.0"
2020-04-20T03:58:24.636885+00:00 app[web.1]:
2020-04-20T03:58:24.636895+00:00 app[web.1]: Note that in case you don't install it globally, you'll need to install it again for another Vaadin project.
2020-04-20T03:58:24.636895+00:00 app[web.1]: In case you have just installed node.js globally, it was not discovered, so you need to restart your system to get the path variables updated.
2020-04-20T03:58:24.636896+00:00 app[web.1]: ======================================================================================================
2020-04-20T03:58:24.636896+00:00 app[web.1]:
2020-04-20T03:58:24.636896+00:00 app[web.1]: at com.vaadin.flow.server.startup.DevModeInitializer.initDevModeHandler(DevModeInitializer.java:301) ~[flow-server-2.1.5.jar!/:2.1.5]
2020-04-20T03:58:24.636896+00:00 app[web.1]: at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:344) ~[vaadin-spring-12.1.2.jar!/:na]
2020-04-20T03:58:24.636897+00:00 app[web.1]: ... 46 common frames omitted
2020-04-20T03:58:24.636898+00:00 app[web.1]: Caused by: java.lang.IllegalStateException:
2020-04-20T03:58:24.636898+00:00 app[web.1]:
2020-04-20T03:58:24.636898+00:00 app[web.1]: ======================================================================================================
2020-04-20T03:58:24.636899+00:00 app[web.1]: Vaadin requires node.js & npm to be installed. Please install the latest LTS version of node.js (with npm) either by:
2020-04-20T03:58:24.636899+00:00 app[web.1]: 1) following the https://nodejs.org/en/download/ guide to install it globally. This is the recommended way.
2020-04-20T03:58:24.636906+00:00 app[web.1]: 2) running the following Maven plugin goal to install it in this project:
2020-04-20T03:58:24.636906+00:00 app[web.1]: $ mvn com.github.eirslett:frontend-maven-plugin:1.7.6:install-node-and-npm -DnodeVersion="v12.14.0"
2020-04-20T03:58:24.636906+00:00 app[web.1]:
2020-04-20T03:58:24.636907+00:00 app[web.1]: Note that in case you don't install it globally, you'll need to install it again for another Vaadin project.
2020-04-20T03:58:24.636907+00:00 app[web.1]: In case you have just installed node.js globally, it was not discovered, so you need to restart your system to get the path variables updated.
2020-04-20T03:58:24.636907+00:00 app[web.1]: ======================================================================================================
2020-04-20T03:58:24.636907+00:00 app[web.1]:
2020-04-20T03:58:24.636908+00:00 app[web.1]: at com.vaadin.flow.server.frontend.FrontendUtils.getExecutable(FrontendUtils.java:371) ~[flow-server-2.1.5.jar!/:2.1.5]
2020-04-20T03:58:24.636908+00:00 app[web.1]: at com.vaadin.flow.server.frontend.FrontendUtils.getNodeExecutable(FrontendUtils.java:300) ~[flow-server-2.1.5.jar!/:2.1.5]
2020-04-20T03:58:24.636908+00:00 app[web.1]: at com.vaadin.flow.server.frontend.FrontendUtils.validateNodeAndNpmVersion(FrontendUtils.java:623) ~[flow-server-2.1.5.jar!/:2.1.5]
2020-04-20T03:58:24.636908+00:00 app[web.1]: at com.vaadin.flow.server.DevModeHandler.<init>(DevModeHandler.java:139) ~[flow-server-2.1.5.jar!/:2.1.5]
2020-04-20T03:58:24.636909+00:00 app[web.1]: at com.vaadin.flow.server.DevModeHandler.createInstance(DevModeHandler.java:299) ~[flow-server-2.1.5.jar!/:2.1.5]
2020-04-20T03:58:24.636909+00:00 app[web.1]: at com.vaadin.flow.server.DevModeHandler.start(DevModeHandler.java:249) ~[flow-server-2.1.5.jar!/:2.1.5]
2020-04-20T03:58:24.636909+00:00 app[web.1]: at com.vaadin.flow.server.DevModeHandler.start(DevModeHandler.java:226) ~[flow-server-2.1.5.jar!/:2.1.5]
2020-04-20T03:58:24.636910+00:00 app[web.1]: at com.vaadin.flow.server.startup.DevModeInitializer.initDevModeHandler(DevModeInitializer.java:297) ~[flow-server-2.1.5.jar!/:2.1.5]
2020-04-20T03:58:24.636910+00:00 app[web.1]: ... 47 common frames omitted
2020-04-20T03:58:24.636910+00:00 app[web.1]:
2020-04-20T03:58:24.663094+00:00 app[web.1]: 2020-04-20 03:58:24.662 ERROR 4 --- [ main] o.apache.catalina.core.StandardContext : One or more listeners failed to start. Full details will be found in the appropriate container log file
2020-04-20T03:58:24.663714+00:00 app[web.1]: 2020-04-20 03:58:24.663 ERROR 4 --- [ main] o.apache.catalina.core.StandardContext : Context [] startup failed due to previous errors
2020-04-20T03:58:24.667161+00:00 app[web.1]: 2020-04-20 03:58:24.667 WARN 4 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [Thread-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
2020-04-20T03:58:24.667162+00:00 app[web.1]: java.net.PlainSocketImpl.socketAccept(Native Method)
2020-04-20T03:58:24.667162+00:00 app[web.1]: java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
2020-04-20T03:58:24.667162+00:00 app[web.1]: java.net.ServerSocket.implAccept(ServerSocket.java:560)
2020-04-20T03:58:24.667163+00:00 app[web.1]: java.net.ServerSocket.accept(ServerSocket.java:528)
2020-04-20T03:58:24.667163+00:00 app[web.1]: com.vaadin.flow.server.DevServerWatchDog$WatchDogServer.run(DevServerWatchDog.java:58)
2020-04-20T03:58:24.667164+00:00 app[web.1]: java.lang.Thread.run(Thread.java:748)
2020-04-20T03:58:24.696178+00:00 app[web.1]: 2020-04-20 03:58:24.695 INFO 4 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-04-20T03:58:24.703061+00:00 app[web.1]: 2020-04-20 03:58:24.702 WARN 4 --- [ 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
2020-04-20T03:58:24.714248+00:00 app[web.1]: 2020-04-20 03:58:24.714 INFO 4 --- [ main] org.mongodb.driver.connection : Closed connection [connectionId{localValue:2, serverValue:586888}] to ds111598.mlab.com:11598 because the pool has been closed.
2020-04-20T03:58:24.729224+00:00 app[web.1]: 2020-04-20 03:58:24.729 INFO 4 --- [ main] ConditionEvaluationReportLoggingListener :
2020-04-20T03:58:24.729226+00:00 app[web.1]:
2020-04-20T03:58:24.729227+00:00 app[web.1]: Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-04-20T03:58:24.732562+00:00 app[web.1]: 2020-04-20 03:58:24.732 ERROR 4 --- [ main] o.s.boot.SpringApplication : Application run failed
2020-04-20T03:58:24.732562+00:00 app[web.1]:
2020-04-20T03:58:24.732563+00:00 app[web.1]: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2020-04-20T03:58:24.732584+00:00 app[web.1]: at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732592+00:00 app[web.1]: at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
2020-04-20T03:58:24.732593+00:00 app[web.1]: at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732601+00:00 app[web.1]: at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732602+00:00 app[web.1]: at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732602+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732603+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732603+00:00 app[web.1]: at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732604+00:00 app[web.1]: at com.doggydoggy.DoggyDoggyApplication.main(DoggyDoggyApplication.java:12) [classes!/:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.732604+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_242-heroku]
2020-04-20T03:58:24.732605+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_242-heroku]
2020-04-20T03:58:24.732605+00:00 app[web.1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_242-heroku]
2020-04-20T03:58:24.732606+00:00 app[web.1]: at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_242-heroku]
2020-04-20T03:58:24.732606+00:00 app[web.1]: at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [DoggyDoggyUsers-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.732606+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [DoggyDoggyUsers-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.732607+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [DoggyDoggyUsers-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.732607+00:00 app[web.1]: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [DoggyDoggyUsers-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
2020-04-20T03:58:24.732607+00:00 app[web.1]: Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2020-04-20T03:58:24.732608+00:00 app[web.1]: at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732608+00:00 app[web.1]: at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:88) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732609+00:00 app[web.1]: at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:438) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732609+00:00 app[web.1]: at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:191) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732610+00:00 app[web.1]: at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732610+00:00 app[web.1]: at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732611+00:00 app[web.1]: ... 16 common frames omitted
2020-04-20T03:58:24.732611+00:00 app[web.1]: Caused by: java.lang.IllegalStateException: StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[] failed to start
2020-04-20T03:58:24.732611+00:00 app[web.1]: at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.rethrowDeferredStartupExceptions(TomcatWebServer.java:171) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732618+00:00 app[web.1]: at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:110) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
2020-04-20T03:58:24.732618+00:00 app[web.1]: ... 21 common frames omitted
2020-04-20T03:58:24.732619+00:00 app[web.1]:
2020-04-20T03:58:25.134818+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-20T04:00:36.584773+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=quantum-vaping-back.herokuapp.com request_id=a66b761b-c882-44b5-a6fe-6ac680d49354 fwd="99.228.194.163" dyno= connect= service= status=503 bytes= protocol=https
2020-04-20T04:00:36.957827+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quantum-vaping-back.herokuapp.com request_id=042770ee-6911-45b1-83b2-5fa007819207 fwd="99.228.194.163" dyno= connect= service= status=503 bytes= protocol=https
Here is my pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.doggydoggy.users</groupId>
<artifactId>DoggyDoggyUsers</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>DoggyDoggyUsers</name>
<description>Doggy Doggy backend user service</description>
<properties>
<java.version>1.8</java.version>
<vaadin.version>14.1.17</vaadin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>17.12.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>copy</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.heroku</groupId>
<artifactId>webapp-runner</artifactId>
<version>9.0.30.0</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The project works fine locally, but always get the same error once I deployed to Heroku. Please help
I had the same problem, my error was in the Procfile file. Try to add
web: java -jar target/[your-jar-file-name].jar --server.port=$PORT
and then run in command line:
git push heroku master
I hope this help you,
regards
I'm quite new to spring and spring boot application. Getting the error creating bean with name 'entityManagerFactory' defined in class path resource. It says unable to build EntityManagerFactory. Error displayed in console:
when i tried to run embeded apache tomcat i got this erroe
please tell me what is problem
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
Apr 23, 2019 1:44:19 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
Apr 23, 2019 1:44:19 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.17]
Apr 23, 2019 1:44:20 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Apr 23, 2019 1:44:20 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring embedded WebApplicationContext
Apr 23, 2019 1:44:25 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service [Tomcat]
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/metadata/ClassMetadata
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.amol.location.LocationwebApplication.main(LocationwebApplication.java:10)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/metadata/ClassMetadata
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.hibernate.persister.internal.StandardPersisterClassResolver.singleTableEntityPersister(StandardPersisterClassResolver.java:59)
at org.hibernate.persister.internal.StandardPersisterClassResolver.getEntityPersisterClass(StandardPersisterClassResolver.java:39)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:74)
at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:154)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
... 16 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.metadata.ClassMetadata
at java.net.URLClassLoader$1.run(URLClassLoader.java:370)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 54 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$1400(ZipFile.java:60)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717)
at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at sun.misc.Resource.getBytes(Resource.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:462)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
... 60 more
**The pom.xml file
**
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.amol.location</groupId>
<artifactId>locationweb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>locationweb</name>
<description>Location Module</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/projectdb
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.show-sql=true
spring.mvc.view.prefix=/WEB-INF/jsps/
spring.mvc.view.suffix=.jsp
Usually, invalid LOC header means your local maven repository got corrupted.
Go to ~/.m2/repository directory, find the hibernate directory, delete it, and rebuild the project.
I'm creating gateway using Zuul. I'm unable to start the Zuul application. Is spring boot 2.x is not supporting Zuul?
Instead of Zuul is it recommended to use Spring Cloud Gateway from 2.x onwards?
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.erps.imsx</groupId>
<artifactId>zuul</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>zuul</name>
<description>zuul</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>zuul</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
and my resuorce file is
application.yml
spring:
application:
name: zuul
server:
port: 9999
zuul:
host:
socket-timeout-millis: 30000
and my spring boot application is
ZuulApplication.java
package org.erps.imsx.zuul;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
#SpringBootApplication
#EnableZuulProxy
#EnableDiscoveryClient
public class ZuulApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(ZuulApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ZuulApplication.class);
}
}
Can you please help why am I getting below error?
2018-09-08 16:56:05.405 INFO 22320 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#52e6fdee: startup date [Sat Sep 08 16:56:05 IST 2018]; root of context hierarchy
2018-09-08 16:56:05.647 INFO 22320 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-09-08 16:56:05.663 INFO 22320 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$61cba0e2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
2018-09-08 16:56:05.924 INFO 22320 --- [ main] org.erps.imsx.zuul.ZuulApplication : No active profile set, falling back to default profiles: default
2018-09-08 16:56:05.940 INFO 22320 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#457c9034: startup date [Sat Sep 08 16:56:05 IST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#52e6fdee
2018-09-08 16:56:06.627 INFO 22320 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'counterFactory' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.zuul.ZuulServerAutoConfiguration$ZuulMetricsConfiguration; factoryMethodName=counterFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration$ZuulMetricsConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.zuul.ZuulServerAutoConfiguration$ZuulCounterFactoryConfiguration; factoryMethodName=counterFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulServerAutoConfiguration$ZuulCounterFactoryConfiguration.class]]
2018-09-08 16:56:06.909 INFO 22320 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=b0e2af60-650b-3cff-9a4f-7683e744c3b3
2018-09-08 16:56:06.929 INFO 22320 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-09-08 16:56:06.992 WARN 22320 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/netflix/hystrix/exception/HystrixRuntimeException
2018-09-08 16:56:07.002 INFO 22320 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-09-08 16:56:07.008 ERROR 22320 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistryPostProcessor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/netflix/hystrix/exception/HystrixRuntimeException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:490) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:236) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.erps.imsx.zuul.ZuulApplication.main(ZuulApplication.java:16) [classes/:na]
Caused by: java.lang.NoClassDefFoundError: com/netflix/hystrix/exception/HystrixRuntimeException
at java.lang.Class.getDeclaredFields0(Native Method) ~[na:1.8.0_181]
at java.lang.Class.privateGetDeclaredFields(Class.java:2583) ~[na:1.8.0_181]
at java.lang.Class.getDeclaredFields(Class.java:1916) ~[na:1.8.0_181]
at org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.compiledByAjc(AbstractAspectJAdvisorFactory.java:93) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.isAspect(AbstractAspectJAdvisorFactory.java:78) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.aop.aspectj.annotation.BeanFactoryAspectJAdvisorsBuilder.buildAspectJAdvisors(BeanFactoryAspectJAdvisorsBuilder.java:104) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:95) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:101) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:254) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1060) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1033) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:484) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
... 14 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.netflix.hystrix.exception.HystrixRuntimeException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_181]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_181]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_181]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_181]
... 26 common frames omitted
Check if the hystrix-coreXX.jar is corrupted in your .m2 folder. If not then try adding the exclusion for hystrix-core jar to eureka, zuul and add dependency for hystrix core like below.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<exclusions>
<exclusion>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<exclusions>
<exclusion>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
<version>1.5.12</version>
</dependency>
By looking at the exception that you've got, looks like you are trying to use Netflix Hystrix without adding the necessary dependency on pom.xml. Either correct your code to not use Netflix Hystrix or add the necessary dependencies...
Can you please update your pom.xml to add the following as well?
<!-- https://mvnrepository.com/artifact/com.netflix.hystrix/hystrix-core -->
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
<version>1.5.12</version>
</dependency>
Hope this helps!
Try adding spring-cloud-starter-eureka as a dependency
this is my first question at stackoverflow, so I try my best to describe everything in detail.
I have a simple spring-cloud-starter-netflix-eureka-server gradle based project which should only start the eureka server inside a docker container.
I am really new to spring. I tried some older versions of spring cloud starter but nothing worked.
I am building the jar on ubuntu 18.04 with openjdk 10.
It would be really nice if someone could help me!
Thanks a lot!
My SpringBootApplication class looks like this:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
#SpringBootApplication
#EnableEurekaServer
public class EurekaServiceRegistryApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServiceRegistryApplication.class, args);
}
}
Here is my build.gradle:
plugins {
id 'java'
id 'org.springframework.boot' version '2.0.3.RELEASE'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-server', version: '2.0.0.RELEASE'
}
And my dockerfile:
FROM openjdk:8-jre-alpine
ADD ./build/libs/eureka-service-registry-1.0-SNAPSHOT.jar /app/
CMD ["java", "-jar", "/app/eureka-service-registry-1.0-SNAPSHOT.jar"]
EXPOSE 8761
When I run my docker container (and also when I start the application from within IntelliJ) I get the following:
2018-07-02 19:31:51.732 INFO 1 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#3aa9e816: startup date [Mon Jul 02 19:31:51 GMT 2018]; root of context hierarchy
2018-07-02 19:31:51.987 INFO 1 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-02 19:31:52.025 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$5a4e4f18] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.3.RELEASE)
2018-07-02 19:31:52.381 INFO 1 --- [ main] r.a.m.e.EurekaServiceRegistryApplication : No active profile set, falling back to default profiles: default
2018-07-02 19:31:52.404 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#72d818d1: startup date [Mon Jul 02 19:31:52 GMT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#3aa9e816
2018-07-02 19:31:53.495 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=0823e893-dcb5-3d08-bbb3-dc67f56037ba
2018-07-02 19:31:53.524 INFO 1 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-02 19:31:53.657 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$5a4e4f18] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-02 19:31:54.053 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8761 (http)
2018-07-02 19:31:54.082 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-02 19:31:54.083 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-02 19:31:54.097 INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-07-02 19:31:54.169 ERROR 1 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase : A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_171]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_171]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941) ~[tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_171]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_171]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_171]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5166) ~[tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.authenticator.NonLoginAuthenticator[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:182) ~[tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
... 8 common frames omitted
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1186) ~[tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
... 10 common frames omitted
2018-07-02 19:31:54.170 ERROR 1 --- [ main] org.apache.catalina.core.ContainerBase : A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_171]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_171]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941) ~[tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:367) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:107) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:413) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) [spring-context-5.0.7.RELEASE.jar!/:5.0.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
at de.tudresden.inf.rn.amcs.microservices.eurekaserviceregistry.EurekaServiceRegistryApplication.main(EurekaServiceRegistryApplication.java:11) [classes!/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [eureka-service-registry-1.0-SNAPSHOT.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [eureka-service-registry-1.0-SNAPSHOT.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [eureka-service-registry-1.0-SNAPSHOT.jar:na]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [eureka-service-registry-1.0-SNAPSHOT.jar:na]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421) ~[tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411) ~[tomcat-embed-core-8.5.31.jar!/:8.5.31]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_171]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_171]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_171]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_171]
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949) ~[tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) ~[tomcat-embed-core-8.5.31.jar!/:8.5.31]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.31.jar!/:8.5.31]
... 6 common frames omitted
2018-07-02 19:31:54.171 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-07-02 19:31:54.172 WARN 1 --- [ 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
I've had the same problem.that spring-boot version must one-to-one match eureka version.you can reference to http://projects.spring.io/spring-cloud/
example:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.12.RELEASE</version>
<parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
You need to select proper spring boot and spring cloud version. Also, i was getting error for jettison hence added dependency for jettison to resolve this.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.3.5</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<finalName>eureka-server</finalName>
</build>
Thank you so much for your comments! I first added the spring-boot-starter-web, then the error changed to something with gson.
The answer from here solved my problem at the end.