I am trying to containerize my Spring Boot app to work with multiple environments (production and dev). In my dev environment, I use docker-compose to start up an instance of MySQL server which my Spring Boot app is able to connect to when it is running outside a container but when my Spring Boot app is running in a container, it is unable to connect to the MySQL server.
This is the error I get when I run docker-compose up.
app_1 | 19:48:07.708 ERROR -- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource [org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration': Unsatisfied dependency expressed through method 'setTransactionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | 19:48:07.736 INFO -- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
app_1 | 19:48:07.740 WARN -- [ 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
app_1 | 19:48:07.751 INFO -- [ main] ConditionEvaluationReportLoggingListener :
app_1 |
app_1 | Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
app_1 | 19:48:07.757 ERROR -- [ main] o.s.boot.SpringApplication : Application run failed
app_1 |
app_1 | org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:157)
app_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
app_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
app_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
app_1 | at com.brand.app.AppApp.main(AppApp.java:28)
app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
app_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
app_1 | at java.lang.reflect.Method.invoke(Method.java:498)
app_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
app_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
app_1 | Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:125)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:427)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:180)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154)
app_1 | ... 14 common frames omitted
app_1 | Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource [org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration': Unsatisfied dependency expressed through method 'setTransactionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
app_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:235)
app_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:226)
app_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:101)
app_1 | at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:88)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:261)
app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54)
app_1 | at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5139)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
app_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
app_1 | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
app_1 | at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
app_1 | at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
app_1 | at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
app_1 | at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
app_1 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
app_1 | at java.util.concurrent.FutureTask.run(FutureTask.java:266)
app_1 | at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
app_1 | at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
app_1 | at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
app_1 | at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
app_1 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
app_1 | at org.apache.catalina.startup.Tomcat.start(Tomcat.java:455)
app_1 | at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:106)
app_1 | ... 19 common frames omitted
app_1 | Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration': Unsatisfied dependency expressed through method 'setTransactionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:676)
app_1 | at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
app_1 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:392)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
app_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1247)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167)
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
app_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
app_1 | ... 59 common frames omitted
app_1 | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
app_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1247)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167)
app_1 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:668)
app_1 | ... 82 common frames omitted
app_1 | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307)
app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:224)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1115)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:407)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:341)
app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:335)
app_1 | at org.springframework.orm.jpa.EntityManagerFactoryUtils.findEntityManagerFactory(EntityManagerFactoryUtils.java:120)
app_1 | at org.springframework.orm.jpa.JpaTransactionManager.setBeanFactory(JpaTransactionManager.java:313)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1800)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1765)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
app_1 | ... 91 common frames omitted
app_1 | Caused by: org.flywaydb.core.internal.exception.FlywaySqlException:
app_1 | Unable to obtain connection from database (jdbc:mysql://localhost:3306/app) for user 'root': Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
app_1 | SQL State : 08S01
app_1 | Error Code : 0
app_1 | Message : Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 |
app_1 | at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:60)
app_1 | at org.flywaydb.core.internal.database.DatabaseFactory.createDatabase(DatabaseFactory.java:72)
app_1 | at org.flywaydb.core.Flyway.execute(Flyway.java:1670)
app_1 | at org.flywaydb.core.Flyway.migrate(Flyway.java:1356)
app_1 | at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
app_1 | ... 108 common frames omitted
app_1 | Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
app_1 |
app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
app_1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
app_1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
Here are some of the files involved.
docker-compose.yml - starts MySQL server and builds using a Dockerfile
Dockerfile - copies necessary files and runs entrypoint.sh
entrypoint.sh - starts the Spring Boot app jar
application.properties
application-dev.properties
docker-compose.yml
version: "3"
services:
app:
build:
context: ..
dockerfile: Dockerfile
args:
SPRING_PROFILES_ACTIVE: dev
image: app:dev
depends_on:
- mysql
mysql:
image: mysql:5.6
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: app
MYSQL_ROOT_PASSWORD: password
volumes:
- mysql_data:/var/lib/mysql/data
volumes:
mysql_data:
Dockerfile
FROM openjdk:8-jdk-alpine
ARG SPRING_PROFILES_ACTIVE=""
ENV SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE}
COPY target/app.jar /usr/share/
COPY script/entrypoint.sh /bin/entrypoint.sh
ENTRYPOINT /bin/entrypoint.sh
EXPOSE 5050
entrypoint.sh
#!/bin/sh
sleep 15
exec /usr/bin/java \
-jar /usr/share/app.jar \
--spring.profiles.active=${SPRING_PROFILES_ACTIVE}
Any idea why Spring Boot can't connect to MySQL server? Both containers should be on the same default network.
The Spring Boot app is trying to connect to jdbc:mysql://localhost:3306/app which is fine when the app isn't in a container but when it is in a container, localhost is not valid. The name of the MySQL server service is mysql (defined in the docker-compose.yml), so replacing localhost with mysql will resolve the issue.
For connecting from a docker service to another docker service like a database-service must be set local IP in docker-machine, in this state don't know docker service local IP, we can call with service name instead of service IP. so in the inner docker-machine network for connection to the mysql database or any database as docker service should be changed URL connection to docker service IP or service name
for example,
database URL connection
jdbc:mysql://your-mysql-service-name:3306/app
docker-compose declare service
version: '3.1'
services:
your-mysql-service-name:
container_name: your-mysql-service-name
image: mysql:5.6
restart: always
command: --default-authentication-plugin=mysql_native_password
deploy:
replicas: 1
ports:
- 3306:3306
environment:
MYSQL_DATABASE: "db_name"
MYSQL_ROOT_PASSWORD: "your-password"
Related
Starting our Server, we always get an exception starting with:
WARN [localhost-startStop-5] [TenantIgnoreXmlWebApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultDataToWsConverterList': Cannot resolve reference to bean 'cmsPageDataToWsConverter' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultPageDataToWsConverter' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Cannot resolve reference to bean 'cmsDataMapper' while setting bean property 'mapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultCMSDataMapper' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Singleton instance not initialized yet
This only happens on our Testsystem, but everything is fine in the local VM. The beans mentioned are part of hybris (I checked them, but they seem fine and I didn't touch anything and like I said it's working local) and the AddOn should be installed properly
<antcall target="addoninstall">
<param name="addonnames" value="cmsoccaddon"/>
<param name="addonStorefront.ycommercewebservices" value="ycommercewebservices"/>
</antcall>
Stacktrace:
INFO | jvm 1 | main | 2020/05/26 19:17:20.392 | INFO [localhost-startStop-4] [PropertySourcedRequestMappingHandlerMapping] Mapped URL path [/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
INFO | jvm 1 | main | 2020/05/26 19:17:20.392 | WARN [localhost-startStop-5] [TenantIgnoreXmlWebApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultDataToWsConverterList': Cannot resolve reference to bean 'cmsPageDataToWsConverter' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultPageDataToWsConverter' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Cannot resolve reference to bean 'cmsDataMapper' while setting bean property 'mapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultCMSDataMapper' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Singleton instance not initialized yet
INFO | jvm 1 | main | 2020/05/26 19:17:20.392 | INFO [localhost-startStop-5] [TenantAwareEhCacheManagerFactoryBean] Shutting down EhCache CacheManager 'wsCache_master'
INFO | jvm 1 | main | 2020/05/26 19:17:20.492 | ERROR [localhost-startStop-5] [ContextLoader] Context initialization failed
INFO | jvm 1 | main | 2020/05/26 19:17:20.492 | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultDataToWsConverterList': Cannot resolve reference to bean 'cmsPageDataToWsConverter' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultPageDataToWsConverter' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Cannot resolve reference to bean 'cmsDataMapper' while setting bean property 'mapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultCMSDataMapper' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Singleton instance not initialized yet
INFO | jvm 1 | main | 2020/05/26 19:17:20.492 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:314) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.492 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.492 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:399) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:159) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1674) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1426) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:828) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401) ~[spring-web-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292) [spring-web-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at de.hybris.platform.spring.HybrisContextLoaderListener.doInitWebApplicationContext(HybrisContextLoaderListener.java:226) [coreserver.jar:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at de.hybris.platform.spring.HybrisContextLoaderListener.initWebApplicationContext(HybrisContextLoaderListener.java:199) [coreserver.jar:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103) [spring-web-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.493 | at de.hybris.platform.spring.HybrisContextLoaderListener.contextInitialized(HybrisContextLoaderListener.java:95) [coreserver.jar:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.494 | at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4699) [catalina.jar:8.5.51]
INFO | jvm 1 | main | 2020/05/26 19:17:20.494 | at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5165) [catalina.jar:8.5.51]
INFO | jvm 1 | main | 2020/05/26 19:17:20.494 | at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [catalina.jar:8.5.51]
INFO | jvm 1 | main | 2020/05/26 19:17:20.494 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1412) [catalina.jar:8.5.51]
INFO | jvm 1 | main | 2020/05/26 19:17:20.494 | at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1402) [catalina.jar:8.5.51]
INFO | jvm 1 | main | 2020/05/26 19:17:20.494 | at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.494 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.494 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at java.lang.Thread.run(Thread.java:834) [?:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultPageDataToWsConverter' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Cannot resolve reference to bean 'cmsDataMapper' while setting bean property 'mapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultCMSDataMapper' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Singleton instance not initialized yet
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:314) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1674) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1426) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.495 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:303) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | ... 29 more
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultCMSDataMapper' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Singleton instance not initialized yet
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:303) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1674) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1426) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.496 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:303) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | ... 29 more
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | Caused by: java.lang.IllegalStateException: Singleton instance not initialized yet
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.config.AbstractFactoryBean.getSingletonInstance(AbstractFactoryBean.java:188) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.config.AbstractFactoryBean.access$200(AbstractFactoryBean.java:63) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.config.AbstractFactoryBean$EarlySingletonInvocationHandler.invoke(AbstractFactoryBean.java:275) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at com.sun.proxy.$Proxy272.forEach(Unknown Source) ~[?:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at de.hybris.platform.cmsoccaddon.mapping.DefaultCMSDataMapper.configure(DefaultCMSDataMapper.java:43) ~[cmsoccaddonserver.jar:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at ma.glasnost.orika.impl.ConfigurableMapper.init(ConfigurableMapper.java:119) ~[orika-core-1.5.2.jar:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at de.hybris.platform.webservicescommons.mapping.impl.DefaultDataMapper.setApplicationContext(DefaultDataMapper.java:74) ~[webservicescommonsserver.jar:?]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:120) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:96) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:414) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1763) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.497 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.498 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.498 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.498 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.498 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:303) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1674) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1426) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:303) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | ... 29 more
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | Mai 26, 2020 7:17:20 NACHM. org.apache.catalina.core.StandardContext listenerStart
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | SCHWERWIEGEND: Fehler beim Senden der 'Context Initialized' Benachrichtigung an den Listener aus der Klasse [de.hybris.platform.spring.HybrisContextLoaderListener]
INFO | jvm 1 | main | 2020/05/26 19:17:20.499 | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultDataToWsConverterList': Cannot resolve reference to bean 'cmsPageDataToWsConverter' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultPageDataToWsConverter' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Cannot resolve reference to bean 'cmsDataMapper' while setting bean property 'mapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultCMSDataMapper' defined in class path resource [cmsoccaddon/web/spring/cmsoccaddon-web-spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Singleton instance not initialized yet
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:314)
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:399)
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:159)
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1674)
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1426)
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
INFO | jvm 1 | main | 2020/05/26 19:17:20.500 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
After that the server keeps booting and the most things seem to work, but not everthing, like caching
On got installed properly, the above exception comes when having the issue with addon installation.
Please Verify on the test server, your addon is installed properly on the given storefront.
to verify the addon please this property is injected in your addon or not.
XXXstorefront.additionalWebSpringConfigs.XXXsocialwebaddon=classpath\:/XXXsocialwebaddon/web/spring/XXXsocialwebaddon-web-spring.xml
XXXstorefront.wro4jconfigscan.XXXsocialwebaddon=true
Later if you don't want to run ant target to install addon please add this property to local.properties or specific to storefront project.properties.
I'm learning docker. While deploying my application(Angular, SpringBoot, RabbitMQ, MySQL), I'm able to access UI, but services are getting failed due to connection error between services and MySQL and RabbitMq. But individually I'm able to access both MySql and RabbitMq through docker exec command also tables and queues are getting generating while docker-compose up. But while testing, its not working
docker-compose.yml
version: '3.1'
services:
rabbitmq:
image: rabbitmq:management
ports:
- 5672:5672
- 15672:15672
mysql:
image: mysql:8.0.17
ports:
- 3306:3306
environment:
MYSQL_DATABASE: stackroute
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: cmatches
MYSQL_PASSWORD: cmatches
user-app:
image: userservice
build: userservice/
ports:
- 9100:9100
depends_on:
- mysql
network_mode: "host"
fav-app:
image: favouriteservice
build: favouriteservice/
ports:
- 9200:9200
depends_on:
- mysql
- rabbitmq
network_mode: "host"
rec-app:
image: matchrecommendationservice
build: matchrecommendationservice/
ports:
- 9300:9300
depends_on:
- mysql
- rabbitmq
network_mode: "host"
cmatches-ui:
build: CMatchesUI/
container_name: cmatchesUi
ports:
- 4200:4200
Individual dockerfile is working fine.
Error:
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
Do I need to change something in application.properties
server.port=9200
spring.datasource.url=jdbc:mysql://localhost:3306/stackroute?verifyServerCertificate=false&useSSL=false&requireSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=password
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = update
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
spring.cloud.stream.bindings.recommendedMatchesChannel.destination=recommendedMatches
spring.cloud.stream.default.contentType=application/json
=========================================================================
Updates:
1.
Tried changing
spring.datasource.url=jdbc:mysql://mysql:3306/stackroute?verifyServerCertificate=false&useSSL=false&requireSSL=false&allowPublicKeyRetrieval=true
Got following error :
Caused by: java.net.UnknownHostException: mysql
-Reverted-
2.
Removed network_mode: host
got following error
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
user-app_1 |
user-app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
user-app_1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:827) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:447) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:237) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:136) ~[HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369) ~[HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198) ~[HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467) [HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541) [HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) [HikariCP-3.2.0.jar!/:na]
user-app_1 | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) [HikariCP-3.2.0.jar!/:na]
user-app_1 | at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:179) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:119) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:904) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935) [hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
user-app_1 | at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) [spring-orm-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [spring-beans-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:853) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
user-app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
user-app_1 | at com.stackroute.userservice.UserServiceApplication.main(UserServiceApplication.java:10) ~[classes!/:1.0]
user-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111]
user-app_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111]
user-app_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111]
user-app_1 | at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111]
user-app_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[userservice-1.0.jar:1.0]
user-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[userservice-1.0.jar:1.0]
user-app_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) ~[userservice-1.0.jar:1.0]
user-app_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) ~[userservice-1.0.jar:1.0]
user-app_1 | Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
user-app_1 |
user-app_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
user-app_1 | at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_111]
user-app_1 | at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_111]
user-app_1 | at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_111]
user-app_1 | at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_111]
user-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.NativeSession.connect(NativeSession.java:150) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:947) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:817) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | ... 57 common frames omitted
user-app_1 | Caused by: java.net.ConnectException: Connection refused (Connection refused)
user-app_1 | at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_111]
user-app_1 | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_111]
user-app_1 | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_111]
user-app_1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_111]
user-app_1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_111]
user-app_1 | at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_111]
user-app_1 | at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65) ~[mysql-connector-java-8.0.17.jar!/:8.0.17]
user-app_1 | ... 60 common frames omitted
You can't use localhost as the host name since the applications are run in a docker container. Also, to communicate each other, all the containers should be in the same docker network;
version: '3.1'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
ports:
- 5672:5672
- 15672:15672
networks:
- my-net
mysql:
image: mysql:8.0.17
container_name: mysql
ports:
- 3306:3306
environment:
MYSQL_DATABASE: stackroute
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: cmatches
MYSQL_PASSWORD: cmatches
networks:
- my-net
user-app:
image: userservice
build: userservice/
container_name: userapp
ports:
- 9100:9100
depends_on:
- mysql
networks:
- my-net
fav-app:
image: favouriteservice
build: favouriteservice/
container_name: favapp
ports:
- 9200:9200
depends_on:
- mysql
- rabbitmq
networks:
- my-net
rec-app:
image: matchrecommendationservice
build: matchrecommendationservice/
container_name: recapp
ports:
- 9300:9300
depends_on:
- mysql
- rabbitmq
networks:
- my-net
cmatches-ui:
build: CMatchesUI/
container_name: cmatchesUi
ports:
- 4200:4200
networks:
- my-net
networks:
my-net:
Replace host name in all places to their respective container names like this;
server.port=9200
spring.datasource.url=jdbc:mysql://mysql:3306/stackroute?verifyServerCertificate=false&useSSL=false&requireSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=password
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = update
spring.rabbitmq.host=rabbitmq
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
spring.cloud.stream.bindings.recommendedMatchesChannel.destination=recommendedMatches
spring.cloud.stream.default.contentType=application/json
I think this is because you use network_mode = host
This means that you would like to "reuse" the namespace from the underlying host network.
Try to use the default "bridge" mode so that docker will create a "virtual network" between the containers.
This bridge mode is the default one, so just remove the line network_mode: "host" from the docker compose file.
Here is one nice tutorial that descibes docker network support at the high level.
I know it is already asked but I didn't find the solution to the problem yet. I have a Spring Boot application which uses spring-boot-starter-data. I'm trying to deploy the application in Tomcat server (v.8.5.38) using Docker but I am getting this error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultValidator' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.apache.bval.jsr303.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:157) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:137) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171) [spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5272) [catalina.jar:8.5.38]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.38]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754) [catalina.jar:8.5.38]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730) [catalina.jar:8.5.38]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:8.5.38]
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985) [catalina.jar:8.5.38]
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) [catalina.jar:8.5.38]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_201]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
Caused by: java.lang.AbstractMethodError: org.apache.bval.jsr303.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider;
As it was suggested in other post, I downgraded both javax validation and hibernate validator versions to 1.0.0.GA and 4.3.1.Final
When I did this I got this error:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.Validator]: Factory method 'mvcValidator' threw exception; nested exception is java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:607) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:157) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:137) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171) [spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5272) [catalina.jar:8.5.38]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.38]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754) [catalina.jar:8.5.38]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730) [catalina.jar:8.5.38]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:8.5.38]
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985) [catalina.jar:8.5.38]
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) [catalina.jar:8.5.38]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_201]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.Validator]: Factory method 'mvcValidator' threw exception; nested exception is java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
... 32 common frames omitted
As I could read in related posts, it is something related to hibernate-validation versions, but I dont know how to fix it.
Here are the dependencies I am using (before doing the downgrade):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Maven dependency tree:
+- org.springframework.boot:spring-boot-starter-web:jar:2.1.2.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter:jar:2.1.2.RELEASE:compile
[INFO] | | | +- org.springframework.boot:spring-boot:jar:2.1.2.RELEASE:compile
[INFO] | | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.2.RELEASE:compile
[INFO] | | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.2.RELEASE:compile
[INFO] | | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.1:compile
[INFO] | | | | | \- org.apache.logging.log4j:log4j-api:jar:2.11.1:compile
[INFO] | | | | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | | | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | | | \- org.yaml:snakeyaml:jar:1.23:runtime
[INFO] | | +- org.springframework.boot:spring-boot-starter-json:jar:2.1.2.RELEASE:compile
[INFO] | | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.8:compile
[INFO] | | | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] | | | | \- com.fasterxml.jackson.core:jackson-core:jar:2.9.8:compile
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.8:compile
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.8:compile
[INFO] | | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.8:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.2.RELEASE:compile
[INFO] | | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.14:compile
[INFO] | | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.14:compile
[INFO] | | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.14:compile
[INFO] | | +- org.hibernate.validator:hibernate-validator:jar:6.0.14.Final:compile
[INFO] | | | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | | | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | | | \- com.fasterxml:classmate:jar:1.4.0:compile
[INFO] | | +- org.springframework:spring-web:jar:5.1.4.RELEASE:compile
[INFO] | | | \- org.springframework:spring-beans:jar:5.1.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-webmvc:jar:5.1.4.RELEASE:compile
[INFO] | | +- org.springframework:spring-context:jar:5.1.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:5.1.4.RELEASE:compile
(...)
org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.2.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-aop:jar:2.1.2.RELEASE:compile
[INFO] | | | \- org.aspectj:aspectjweaver:jar:1.9.2:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.2.RELEASE:compile
[INFO] | | | +- com.zaxxer:HikariCP:jar:3.2.0:compile
[INFO] | | | \- org.springframework:spring-jdbc:jar:5.1.4.RELEASE:compile
[INFO] | | +- javax.transaction:javax.transaction-api:jar:1.3:compile
[INFO] | | +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | | +- org.hibernate:hibernate-core:jar:5.3.7.Final:compile
[INFO] | | | +- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] | | | +- org.javassist:javassist:jar:3.23.1-GA:compile
[INFO] | | | +- net.bytebuddy:byte-buddy:jar:1.9.7:compile
[INFO] | | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | | +- org.jboss:jandex:jar:2.0.5.Final:compile
[INFO] | | | +- org.dom4j:dom4j:jar:2.1.1:compile
[INFO] | | | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.4.Final:compile
[INFO] | | +- org.springframework.data:spring-data-jpa:jar:2.1.4.RELEASE:compile
[INFO] | | | +- org.springframework.data:spring-data-commons:jar:2.1.4.RELEASE:compile
[INFO] | | | +- org.springframework:spring-orm:jar:5.1.4.RELEASE:compile
[INFO] | | | \- org.springframework:spring-tx:jar:5.1.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-aspects:jar:5.1.4.RELEASE:compile
Thanks in advance
I tried to run Kafka without Docker a few days ago, again, I failed. It's very hard to setup. So, I decided to use Docker, then I failed again. What could be the problem?
I ran these commands:
git clone https://github.com/confluentinc/cp-docker-images
cd cp-docker-images/examples/kafka-single-node
docker-compose up
Btw, this is my:
Docker version: 17.03.1-ce
Docker compose version: 1.11.2, build dfed245
I downloaded the new Docker for OS X here.
SIDE NOTE: New Docker for OS X uses a different architecture than the previous ones and so, solves many previous problems in OS X with Docker. So, most of the issues talked in Confluent Docker documentation will be easier to address, I believe.
Error Log:
kafka_1 | [2017-05-08 21:00:37,382] WARN [Controller-1-to-broker-1-send-thread], Controller 1 epoch 1 fails to send request (type: UpdateMetadataRequest=, controllerId=1, controllerEpoch=1, partitionStates={}, liveBrokers=(id=1, endPoints=(host=localhost, port=29092, listenerName=ListenerName(PLAINTEXT), securityProtocol=PLAINTEXT), rack=null)) to broker localhost:29092 (id: 1 rack: null). Reconnecting to broker. (kafka.controller.RequestSendThread)
kafka_1 | java.io.IOException: Connection to 1 was disconnected before the response was read
kafka_1 | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1$$anonfun$apply$1.apply(NetworkClientBlockingOps.scala:114)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1$$anonfun$apply$1.apply(NetworkClientBlockingOps.scala:112)
kafka_1 | at scala.Option.foreach(Option.scala:257)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1.apply(NetworkClientBlockingOps.scala:112)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1.apply(NetworkClientBlockingOps.scala:108)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$.recursivePoll$1(NetworkClientBlockingOps.scala:136)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$.kafka$utils$NetworkClientBlockingOps$$pollContinuously$extension(NetworkClientBlockingOps.scala:142)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$.blockingSendAndReceive$extension(NetworkClientBlockingOps.scala:108)
kafka_1 | at kafka.controller.RequestSendThread.liftedTree1$1(ControllerChannelManager.scala:196)
kafka_1 | at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:188)
kafka_1 | at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63)
kafka_1 | [2017-05-08 21:00:37,484] INFO [Controller-1-to-broker-1-send-thread], Controller 1 connected to localhost:29092 (id: 1 rack: null) for sending state change requests (kafka.controller.RequestSendThread)
kafka_1 | [2017-05-08 21:00:37,486] ERROR Processor got uncaught exception. (kafka.network.Processor)
kafka_1 | java.lang.NoClassDefFoundError: Could not initialize class kafka.network.RequestChannel$
kafka_1 | at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:111)
kafka_1 | at kafka.network.Processor$$anonfun$processCompletedReceives$1.apply(SocketServer.scala:513)
kafka_1 | at kafka.network.Processor$$anonfun$processCompletedReceives$1.apply(SocketServer.scala:505)
kafka_1 | at scala.collection.Iterator$class.foreach(Iterator.scala:893)
kafka_1 | at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
kafka_1 | at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
kafka_1 | at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
kafka_1 | at kafka.network.Processor.processCompletedReceives(SocketServer.scala:505)
kafka_1 | at kafka.network.Processor.run(SocketServer.scala:433)
kafka_1 | at java.lang.Thread.run(Thread.java:745)
kafka_1 | [2017-05-08 21:01:07,516] WARN [Controller-1-to-broker-1-send-thread], Controller 1 epoch 1 fails to send request (type: UpdateMetadataRequest=, controllerId=1, controllerEpoch=1, partitionStates={}, liveBrokers=(id=1, endPoints=(host=localhost, port=29092, listenerName=ListenerName(PLAINTEXT), securityProtocol=PLAINTEXT), rack=null)) to broker localhost:29092 (id: 1 rack: null). Reconnecting to broker. (kafka.controller.RequestSendThread)
kafka_1 | java.io.IOException: Connection to 1 was disconnected before the response was read
kafka_1 | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1$$anonfun$apply$1.apply(NetworkClientBlockingOps.scala:114)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1$$anonfun$apply$1.apply(NetworkClientBlockingOps.scala:112)
kafka_1 | at scala.Option.foreach(Option.scala:257)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1.apply(NetworkClientBlockingOps.scala:112)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1.apply(NetworkClientBlockingOps.scala:108)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$.recursivePoll$1(NetworkClientBlockingOps.scala:136)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$.kafka$utils$NetworkClientBlockingOps$$pollContinuously$extension(NetworkClientBlockingOps.scala:142)
kafka_1 | at kafka.utils.NetworkClientBlockingOps$.blockingSendAndReceive$extension(NetworkClientBlockingOps.scala:108)
kafka_1 | at kafka.controller.RequestSendThread.liftedTree1$1(ControllerChannelManager.scala:196)
kafka_1 | at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:188)
kafka_1 | at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63)
kafka_1 | [2017-05-08 21:01:07,618] INFO [Controller-1-to-broker-1-send-thread], Controller 1 connected to localhost:29092 (id: 1 rack: null) for sending state change requests (kafka.controller.RequestSendThread)
kafka_1 | [2017-05-08 21:01:07,619] ERROR Processor got uncaught exception. (kafka.network.Processor)
kafka_1 | java.lang.NoClassDefFoundError: Could not initialize class kafka.network.RequestChannel$
kafka_1 | at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:111)
kafka_1 | at kafka.network.Processor$$anonfun$processCompletedReceives$1.apply(SocketServer.scala:513)
kafka_1 | at kafka.network.Processor$$anonfun$processCompletedReceives$1.apply(SocketServer.scala:505)
kafka_1 | at scala.collection.Iterator$class.foreach(Iterator.scala:893)
kafka_1 | at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
kafka_1 | at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
kafka_1 | at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
kafka_1 | at kafka.network.Processor.processCompletedReceives(SocketServer.scala:505)
kafka_1 | at kafka.network.Processor.run(SocketServer.scala:433)
kafka_1 | at java.lang.Thread.run(Thread.java:745)
Docker recently changed its name to Moby and that was causing my issues. I needed to add moby as a localhost in my docker-compose config.
By adding extra_hosts parameter that resolves moby as localhost will solve this problem:
extra_hosts:
- "moby:127.0.0.1"
The fixing pull-request about this error is here.
To get this fix, type: git pull origin pull/258/head.
If you also want to read about the root cause of this, click here.
I am working a project which is using
spring 3.2.5.RELEASE
hibernate 4.2.15.Final
karaf 3.0.x
when i install my custom bundle (contain all entity classes), throwing PersistentClass name cannot be converted into a Class exception
please find below my karaf bundle lists
ID | State | Lvl | Version | Name
-------------------------------------------------------------------------------------
84 | Active | 80 | 2.7.7.5 | Apache ServiceMix :: Bundles :: antlr
85 | Active | 80 | 1.8.2.2 | Apache ServiceMix :: Bundles :: ant
86 | Active | 80 | 1.6.1.5 | Apache ServiceMix :: Bundles :: dom4j
87 | Active | 80 | 1.14.1.1 | Apache ServiceMix :: Bundles :: serp
88 | Active | 80 | 1.1.0 | ClassMate
89 | Active | 80 | 3.18.1.GA | Javassist
90 | Active | 80 | 1.0.2.Final | JACC 1.4 API
91 | Active | 80 | 1.2.2.Final | Java Annotation Indexer
92 | Active | 80 | 3.1.4.GA | JBoss Logging 3
93 | Active | 80 | 4.0.4.Final | hibernate-commons-annotations
94 | Active | 100 | 4.2.15.Final | hibernate-core
95 | Active | 100 | 4.2.15.Final | hibernate-entitymanager
96 | Active | 100 | 4.2.15.Final | hibernate-osgi
294 | Active | 80 | 3.2.5.RELEASE | Spring Context
295 | Active | 80 | 3.2.5.RELEASE | Spring Core
296 | Active | 80 | 3.2.5.RELEASE | Spring Expression Language
297 | Active | 80 | 3.2.5.RELEASE | Spring Transaction
298 | Active | 80 | 1.2.17 | Apache Log4j
299 | Active | 80 | 1.7.5 | slf4j-api, Fragments: 300
300 | Resolved | 80 | 1.7.5 | slf4j-log4j12, Hosts: 299
302 | Active | 80 | 0 | wrap_mvn_org.springframework.amqp_spring-amqp_1.2.2.RELEASE
303 | Active | 80 | 0 | wrap_mvn_org.springframework.amqp_spring-rabbit_1.2.2.RELEASE
304 | Active | 80 | 3.2.5.RELEASE | Spring ORM
305 | Active | 80 | 1.0.0 | AOP Alliance API
306 | Active | 80 | 3.2.5.RELEASE | Spring JDBC
307 | Active | 80 | 8.3.603 | PostgreSQL JDBC3 Driver
308 | Active | 80 | 0.9.1.2 | c3p0 Connection Pool
309 | Active | 80 | 2.0.0 | Java Persistence API
310 | Active | 80 | 0 | wrap_mvn_antlr_antlr_2.7.7
311 | Active | 80 | 3.1.0.GA | JBoss Logging 3
312 | Active | 80 | 0 | wrap_mvn_dom4j_dom4j_1.6.1
313 | Active | 80 | 1.0.1.Final | Java Transaction API
314 | Active | 80 | 0 | wrap_mvn_org.hibernate.javax.persistence_hibernate-jpa-2.0-api_1.0.1.Final
315 | Active | 80 | 4.0.2.Final | Hibernate Commons Annotations
316 | Active | 80 | 3.0.0 | Expression Language 3.0 API
317 | Active | 80 | 1.2 | javax.interceptor API
318 | Active | 80 | 0 | wrap_mvn_javax.inject_javax.inject_1
319 | Active | 80 | 1.2.0 | CDI APIs
320 | Active | 80 | 1.5.3 | Apache Commons Pool
321 | Active | 80 | 1.7.2.RELEASE | AspectJ Runtime
322 | Active | 80 | 1.7.1.RELEASE | AspectJ Weaver
323 | Active | 80 | 1.1.0 | Java Transaction API
324 | Active | 80 | 2.6.0 | Apache Commons Lang
325 | Active | 80 | 1.3.1 | MaxMind GeoIP Legacy API
326 | Active | 80 | 3.2.1 | Apache Commons Collections
327 | Active | 80 | 3.4.0 | Apache Commons Lang
328 | Active | 80 | 2.3.2 | Jackson-annotations
329 | Active | 80 | 0 | wrap_mvn_commons-collections_commons-collections_3.2
330 | Active | 80 | 1.0.1 | soautil
331 | Active | 80 | 0 | wrap_mvn_logkit_logkit_1.0.1
332 | Active | 80 | 0 | wrap_mvn_javax.servlet_servlet-api_2.3
333 | Active | 80 | 0 | wrap_mvn_commons-logging_commons-logging_1.1
334 | Active | 80 | 3.2.5.RELEASE | Spring AOP
335 | Active | 80 | 3.2.5.RELEASE | Spring Beans
336 | Active | 80 | 3.2.5.RELEASE | Spring Web
337 | Active | 80 | 0 | wrap_mvn_org.springframework_spring-remoting_2.0.8
339 | Active | 80 | 1.2.16 | Apache Log4J
340 | Active | 80 | 2.3.18 | Freemarker Templating Engine
341 | Active | 80 | 1.0.1 | utils-spring
342 | Active | 80 | 5.0.0.201203141902 | osgi.core
343 | Active | 80 | 1.2.1 | spring-osgi-io
344 | Active | 80 | 1.2.1 | spring-osgi-core
345 | Active | 80 | 1.2.1 | spring-osgi-extender
346 | Active | 80 | 5.0.0.201305092017 | osgi.cmpn
347 | Active | 80 | 0.5.4 | FasterXML ClassMate
348 | Active | 80 | 1.0.1 | MyServiceBundle
Find below exceptions
2016-03-26 01:04:41,934 | DEBUG | ExtenderThread-2 | OsgiBundleXmlApplicationContext | 294 - org.springframework.context - 3.2.5.RELEASE | Post refresh error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'geoService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sample.repository.sampleRepository com.sample.impl.GeoServiceImpl.sampleRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sampleRepository': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.hibernate.SessionFactory com.sample.repository.sampleRepository.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundle://348.0:0/spring-data.xml]: Invocation of init method failed; nested exception is org.hibernate.AssertionFailure: PersistentClass name cannot be converted into a Class
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)[294:org.springframework.context:3.2.5.RELEASE]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[344:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[344:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[344:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[344:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[345:org.springframework.osgi.extender:1.2.1]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_71]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sample.repository.sampleRepository com.sample.impl.GeoServiceImpl.sampleRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sampleRepository': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.hibernate.SessionFactory com.sample.repository.sampleRepository.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundle://348.0:0/spring-data.xml]: Invocation of init method failed; nested exception is org.hibernate.AssertionFailure: PersistentClass name cannot be converted into a Class
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)[335:org.springframework.beans:3.2.5.RELEASE]
... 15 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sampleRepository': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.hibernate.SessionFactory com.sample.repository.sampleRepository.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundle://348.0:0/spring-data.xml]: Invocation of init method failed; nested exception is org.hibernate.AssertionFailure: PersistentClass name cannot be converted into a Class
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:912)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:855)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)[335:org.springframework.beans:3.2.5.RELEASE]
... 17 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.hibernate.SessionFactory com.sample.repository.sampleRepository.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundle://348.0:0/spring-data.xml]: Invocation of init method failed; nested exception is org.hibernate.AssertionFailure: PersistentClass name cannot be converted into a Class
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)[335:org.springframework.beans:3.2.5.RELEASE]
... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundle://348.0:0/spring-data.xml]: Invocation of init method failed; nested exception is org.hibernate.AssertionFailure: PersistentClass name cannot be converted into a Class
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:912)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:855)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)[335:org.springframework.beans:3.2.5.RELEASE]
... 30 more
Caused by: org.hibernate.AssertionFailure: PersistentClass name cannot be converted into a Class
at org.hibernate.cfg.BinderHelper.getPropertyOverriddenByMapperOrMapsId(BinderHelper.java:816)[94:org.hibernate.core:4.2.15.Final]
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2097)[94:org.hibernate.core:4.2.15.Final]
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:895)[94:org.hibernate.core:4.2.15.Final]
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:728)[94:org.hibernate.core:4.2.15.Final]
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3568)[94:org.hibernate.core:4.2.15.Final]
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3522)[94:org.hibernate.core:4.2.15.Final]
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1379)[94:org.hibernate.core:4.2.15.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1784)[94:org.hibernate.core:4.2.15.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1868)[94:org.hibernate.core:4.2.15.Final]
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:247)[304:org.springframework.orm:3.2.5.RELEASE]
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:373)[304:org.springframework.orm:3.2.5.RELEASE]
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:358)[304:org.springframework.orm:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)[335:org.springframework.beans:3.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)[335:org.springframework.beans:3.2.5.RELEASE]
... 40 more
Caused by: java.lang.ClassNotFoundException: com.sample.model.Country not found by org.hibernate.core [94]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_71]
at java.lang.Class.forName0(Native Method)[:1.7.0_71]
at java.lang.Class.forName(Class.java:274)[:1.7.0_71]
at org.hibernate.annotations.common.util.ReflectHelper.classForName(ReflectHelper.java:60)[93:org.hibernate.common.hibernate-commons-annotations:4.0.4.Final]
at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.classForName(JavaReflectionManager.java:138)[93:org.hibernate.common.hibernate-commons-annotations:4.0.4.Final]
at org.hibernate.cfg.BinderHelper.getPropertyOverriddenByMapperOrMapsId(BinderHelper.java:812)[94:org.hibernate.core:4.2.15.Final]
... 53 more
i guess, entity classes are not scanning properly. This is my configuration
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties" ref="hibernateProperties"/>
<property name="annotatedClasses">
<list>
<value>com.sample.model.Country</value>
<value>com.sample.model.Location</value>
</list>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
EDITED :
Please find below manifest header entries
Manifest-Version = 1.0
Bnd-LastModified = 1458957186000
Tool = Bnd-2.4.0.201411031534
Spring-Context = /spring.xml
Created-By = 1.7.0_71 (Oracle Corporation)
Bundle-Vendor = demo
Bundle-Name = MyServiceBundle
Bundle-Description = MyService Bundle to create Amqp services
Bundle-SymbolicName = com.sample.MyServiceBundle
Bundle-Version = 1.0.1
Bundle-ManifestVersion = 2
Require-Capability =
osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=1.7))
Import-Package =
com.maxmind.geoip;version="[1.3,2)",
javax.persistence;version="[2.0,3)",
org.hibernate;version="[4.2,5)",
org.hibernate.annotations;version="[4.2,5)",
org.hibernate.criterion;version="[4.2,5)",
org.slf4j;version="[1.7,2)",
org.springframework.beans.factory.annotation;version="[3.2,4)",
org.springframework.context.support;version="[3.2,4)",
org.springframework.stereotype;version="[3.2,4)",
org.springframework.transaction.annotation;version="[3.2,4)",
com.sample.api;version="[1.0,2)",
com.sample.utils.soa.exception;version="[1.0,2)",
org.springframework.amqp.rabbit.core,
org.springframework.orm.hibernate4;version="[3.2,4)",
com.mchange.v2.c3p0;version="[0.9,1)",
org.springframework.aop;version="[3.2,4)",
org.springframework.aop.framework;version="[3.2,4)",
org.springframework.cglib.proxy;version="[3.2,4)",
org.springframework.cglib.core;version="[3.2,4)",
org.aopalliance.aop;version="[1.0,2)",
org.springframework.amqp.rabbit.listener.adapter,
org.springframework.amqp.remoting.service,
com.sample.utils.spring;version="[1.0,2)",
org.springframework.remoting.support;version="[3.2,4)",
org.springframework.amqp.rabbit.transaction,
org.springframework.cglib.reflect;version="[3.2,4)",
org.springframework.jmx.export.annotation;version="[3.2,4)",
org.springframework.amqp.support.converter,
org.springframework.core.type;version="[3.2,4)",
org.springframework.context;version="[3.2,4)",
org.apache.felix.service.command,
org.apache.felix.gogo.commands,
org.apache.karaf.shell.console,
org.apache.karaf.shell.commands,
org.hibernate.cfg;version="[4.2,5)",
org.hibernate.service;version="[4.2,5)",
org.hibernate.proxy;version="[4.2,5)",
javassist.util.proxy;version="[3.18,4)",
com.sample.model;version="[1.0,2)"
Export-Package =
com.sample;uses:=com.sample.utils.soa.exception;version=1.0.1,
com.sample.repository;
uses:="org.hibernate,
org.springframework.beans.factory.annotation,
org.springframework.stereotype,
org.springframework.transaction.annotation,
com.sample.api,
com.sample.model,
com.sample.utils.soa.exception";
version=1.0.1,
com.sample.impl;uses:="org.springframework.stereotype,com.sample.api,com.sample.utils.soa.exception";version=1.0.1,
com.sample.model;uses:=javax.persistence;version=1.0.1
I cannot solve this problem. If anyone get idea please share with me
Thank you,
gopy
Edited : 4-april-2016
Still i am unable to solve .....
Now i upgraded spring to
Apache ServiceMix :: Bundles 4.2.5.RELEASE_1 and
hibernate-core 4.3.6.Final
But again same issue.
Caused by: org.hibernate.AssertionFailure: PersistentClass name cannot
be converted into a Class at
org.hibernate.cfg.BinderHelper.getPropertyOverriddenByMapperOrMapsId(BinderHelper.java:817)
at
org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2169)
at
org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:963)
at
org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:796)
at
org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3788)
at
org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3742)
at
org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
at
org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372)
at
org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454)
at
org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
Same bundle able to deploy in virgo osgi server. So i am sure hibernate configuration is not an issue. Some supporting libs are missing.
If anyone using karaf 3.x with hibernate please share your
bundle:list
i will compare with mine.
thank you in advance.
This seems to be the root cause:
Caused by: java.lang.ClassNotFoundException: com.sample.model.Country not found by org.hibernate.core [94]
Without seeing the manifest, or the output from
karaf> headers $bundleId
there isn't much else to go on.
Most likely, you are missing an Import-Package entry for com.sample.model