Springboot connecting to unknown database - java

I created a Springboot application using https://start.spring.io/.
After adding some initial application properties for spring-data-jpa, the application starts fine however, I do not see any tables created in my local database.
To test this further, I provided incorrect credentials in application.properties and started the application expecting it to fail, however it started fine.
I see in logs it is connecting to a Mysql database but not sure how and where.
Has anyone faced this strange issue ?
application.properties
spring.datasource.url = jdbc:mysql://localhost:3306/db
spring.datasource.username = db
spring.datasource.password = pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager)
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I even provided an incorrect port in database url, it still started fine with following logs :
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.4)
2022-10-01 22:01:21.025 INFO 20928 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication using Java 16.0.2 on DESKTOP-S112VSS with PID 20928 (C:\Users\Paras\Downloads\demo\demo\target\classes started by Paras in C:\Users\Paras\Downloads\demo\demo)
2022-10-01 22:01:21.036 INFO 20928 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to 1 default profile: "default"
2022-10-01 22:01:22.278 INFO 20928 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-10-01 22:01:22.302 INFO 20928 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 9 ms. Found 0 JPA repository interfaces.
2022-10-01 22:01:23.557 INFO 20928 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-10-01 22:01:23.583 INFO 20928 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-10-01 22:01:23.584 INFO 20928 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-10-01 22:01:23.957 INFO 20928 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-10-01 22:01:23.957 INFO 20928 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2789 ms
2022-10-01 22:01:24.267 INFO 20928 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-10-01 22:01:24.524 INFO 20928 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2022-10-01 22:01:24.600 INFO 20928 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-10-01 22:01:24.697 INFO 20928 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.11.Final
2022-10-01 22:01:24.971 INFO 20928 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-10-01 22:01:25.150 INFO 20928 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2022-10-01 22:01:25.472 INFO 20928 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-10-01 22:01:25.489 INFO 20928 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-10-01 22:01:25.550 WARN 20928 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2022-10-01 22:01:26.069 INFO 20928 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-10-01 22:01:26.086 INFO 20928 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 5.957 seconds (JVM running for 6.799)

The issue has been resolved, somehow there were environment variables being set from a previous project, so Spring was taking that as a priority instead of the values defined in the properties file.

Look again at your "log" and your configuration file. In the first one it indicates a dialect of MySQL version 8, however in the configuration file, it shows version 5. That's for starters.

I think you should see this log
[0;39m [2m:[0;39m Registered driver with driverClassName=com.mysql.jdbc.Driver
was not found, trying direct instantiation.
it,s the driver settings incorrect?
setting this configure properties correct
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

Please check the following line, driver class
Set it to like.
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
also, check your system's MySQL version
if it's 5.7 then make your hibernate dialect version 57,
if it's 5.8 then make your hibernate dialect to version 8.
Example, My SQL version is
mysql Ver 8.0.30 for macos12.4 on x86_64 (Homebrew)
so, I have set my hibernate dialect
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
I hope, it helps!

Add this to the configuration
logging.level.com.zaxxer.hikari.HikariConfig=DEBUG
You will see the database URL in the logs.
The problem can be, IDE doesn't sync your changes to the build folder. Check application.properties in the build folder.
Also It is not necessary that application will connect to the database during startup. You can try to save() a simple entity.
https://stackoverflow.com/a/74019458/3405171
You can add spring-boot-starter-actuator library to check the connection during startup for sure.

Related

Spring Boot service can't connect to Spring Cloud Config Server when start as a Docker container

I'm using Spring Cloud Config Server with a simple Spring Boot project. So I have a service for Spring Cloud Config Service and another simple service that connect to Spring Cloud Config Service to get some properties like database credentials and other properties. If I test it on local everything works good, but if I try to start these 2 services as docker containers it isn't working. The Spring Cloud Config Service starts fine, and then I try to start the other service and it's not working. It cannot connect to the config server and I don't understand why.
spring cloud config server application.yml:
server:
port: 8888
spring:
application:
name: spring-cloud-config-server
cloud:
config:
label: master
server:
git:
uri: https://github.com/...
security:
user:
name: gigi
password: $2a$10$QpA9JjOQiciPKokmwlxEYOPtZLIHfTFECvDeL8in.ZGWVUY24Cx/a
spring cloud config server pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.gab.microservices</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-cloud-config-server</name>
<description>Centralized Configuration Server</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>eveningstar33/mmv2-${project.artifactId}:${project.version}</name>
<pullPolicy>IF_NOT_PRESENT</pullPolicy>
</image>
</configuration>
</plugin>
</plugins>
</build>
</project>
I start the spring cloud config server as a docker container on local:
$ docker run -p 8888:8888 eveningstar33/mmv2-spring-cloud-config-server:0.0.1-SNAPSHOT
Setting Active Processor Count to 4
Calculating JVM memory based on 4828376K available memory
`For more information on this calculation, see https://paketo.io/docs/reference/java-reference/#memory-calculator
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx4211948K -XX:MaxMetaspaceSize=104427K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 4828376K, Thread Count: 250, Loaded Class Count: 16023, Headroom: 0%)
Enabling Java Native Memory Tracking
Adding 127 container CA certificates to JVM truststore
Spring Cloud Bindings Enabled
Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -XX:+ExitOnOutOfMemoryError -XX:ActiveProcessorCount=4 -XX:MaxDirectMemorySize=10M -Xmx4211948K -XX:MaxMetaspaceSize=104427K -XX:ReservedCodeCacheSize=240M -Xss1M -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics -Dorg.springframework.cloud.bindings.boot.enable=true
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.0)
2022-06-26 15:40:12.369 INFO 1 --- [ main] g.m.s.SpringCloudConfigServerApplication : Starting SpringCloudConfigServerApplication v0.0.1-SNAPSHOT using Java 11.0.15.1 on 058d17df827b with PID 1 (/workspace/BOOT-INF/classes started by cnb in /workspace)
2022-06-26 15:40:12.376 INFO 1 --- [ main] g.m.s.SpringCloudConfigServerApplication : No active profile set, falling back to 1 default profile: "default"
2022-06-26 15:40:14.409 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=e8bf239d-fb47-310c-99e0-8c15e49dfb55
2022-06-26 15:40:15.015 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8888 (http)
2022-06-26 15:40:15.034 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-06-26 15:40:15.035 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.63]
2022-06-26 15:40:15.158 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-06-26 15:40:15.158 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2630 ms
2022-06-26 15:40:16.137 INFO 1 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter#5dbbb292, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#613f7eb7, org.springframework.security.web.context.SecurityContextPersistenceFilter#1ac730cd, org.springframework.security.web.header.HeaderWriterFilter#b5b9333, org.springframework.security.web.csrf.CsrfFilter#30bbcf91, org.springframework.security.web.authentication.logout.LogoutFilter#487cd177, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#3375ebd3, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#6467ddc7, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#565aa4ac, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#40717ed, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#5aa62ee7, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#1f7cec93, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#587c5c1, org.springframework.security.web.session.SessionManagementFilter#38588dea, org.springframework.security.web.access.ExceptionTranslationFilter#79627d27, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#2199e845]
2022-06-26 15:40:17.116 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8888 (http) with context path ''
2022-06-26 15:40:17.148 INFO 1 --- [ main] g.m.s.SpringCloudConfigServerApplication : Started SpringCloudConfigServerApplication in 5.731 seconds (JVM running for 6.46)
And I can do a request at the url http://localhost:8888/currency-exchange/master and these are the informations:
{
"name": "currency-exchange",
"profiles": [
"master"
],
"label": null,
"version": "7b6626f321d73191ca6cfc55f518f7158e1a2313",
"state": null,
"propertySources": [
{
"name": "https://github.com/...
"source": {
"spring.cloud.config.label": "master",
"spring.cloud.config.uri": "http://localhost:8888",
"spring.cloud.config.username": "gigi",
"spring.cloud.config.password": "test1234",
"spring.datasource.url": "jdbc:mysql://docker-mysql:3306/testdb",
"spring.datasource.username": "root",
"spring.datasource.password": "test1234",
"spring.security.user.name": "admin",
"spring.security.user.password": "$2a$10$QpA9JjOQiciPKokmwlxEYOPtZLIHfTFECvDeL8in.ZGWVUY24Cx/a"
}
}
]
}
After that I try to start the other service and I get connection refused:
$ docker run -p 8000:8000 eveningstar33/mmv2-currency-exchange-service:0.0.1-SNAPSHOT
Setting Active Processor Count to 4
Calculating JVM memory based on 4502728K available memory
`For more information on this calculation, see https://paketo.io/docs/reference/java-reference/#memory-calculator
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx3840722K -XX:MaxMetaspaceSize=150005K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 4502728K, Thread Count: 250, Loaded Class Count: 24070, Headroom: 0%)
Enabling Java Native Memory Tracking
Adding 127 container CA certificates to JVM truststore
Spring Cloud Bindings Enabled
Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -XX:+ExitOnOutOfMemoryError -XX:ActiveProcessorCount=4 -XX:MaxDirectMemorySize=10M -Xmx3840722K -XX:MaxMetaspaceSize=150005K -XX:ReservedCodeCacheSize=240M -Xss1M -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics -Dorg.springframework.cloud.bindings.boot.enable=true
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.0)
2022-06-26 15:47:01.483 INFO [currency-exchange,,] 1 --- [ main] g.m.c.CurrencyExchangeServiceApplication : Starting CurrencyExchangeServiceApplication v0.0.1-SNAPSHOT using Java 11.0.15.1 on 08358a26aa24 with PID 1 (/workspace/BOOT-INF/classes started by cnb in /workspace)
2022-06-26 15:47:01.490 INFO [currency-exchange,,] 1 --- [ main] g.m.c.CurrencyExchangeServiceApplication : No active profile set, falling back to 1 default profile: "default"
2022-06-26 15:47:01.591 INFO [currency-exchange,,] 1 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://localhost:8888
2022-06-26 15:47:01.592 INFO [currency-exchange,,] 1 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2022-06-26 15:47:01.592 WARN [currency-exchange,,] 1 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource#4aeaadc1 uris = array<String>['http://localhost:8888'], optional = true, profiles = list['default']]): I/O error on GET request for "http://localhost:8888/currency-exchange/default/master": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2022-06-26 15:47:04.088 INFO [currency-exchange,,] 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-06-26 15:47:04.511 INFO [currency-exchange,,] 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 403 ms. Found 1 JPA repository interfaces.
2022-06-26 15:47:05.655 INFO [currency-exchange,,] 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=14f08c66-f514-36a3-965b-ebd56a472fd5
2022-06-26 15:47:07.788 INFO [currency-exchange,,] 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8000 (http)
2022-06-26 15:47:07.814 INFO [currency-exchange,,] 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-06-26 15:47:07.816 INFO [currency-exchange,,] 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.63]
2022-06-26 15:47:08.034 INFO [currency-exchange,,] 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-06-26 15:47:08.034 INFO [currency-exchange,,] 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 6437 ms
2022-06-26 15:47:08.484 ERROR [currency-exchange,,] 1 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourcePoolMetadataMeterBinder' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration$DataSourcePoolMetadataMetricsConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourcePoolMetadataMeterBinder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2022-06-26 15:47:08.521 INFO [currency-exchange,,] 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-06-26 15:47:08.547 WARN [currency-exchange,,] 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2022-06-26 15:47:08.618 INFO [currency-exchange,,] 1 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-06-26 15:47:08.663 ERROR [currency-exchange,,] 1 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Native Memory Tracking:
Total: reserved=4647673752, committed=360292248
- Java Heap (reserved=3934257152, committed=181403648)
(mmap: reserved=3934257152, committed=181403648)
- Class (reserved=192943772, committed=52971164)
(classes #9559)
( instance classes #8950, array classes #609)
(malloc=1590940 #24005)
(mmap: reserved=191352832, committed=51380224)
( Metadata: )
( reserved=46137344, committed=44564480)
( used=43492240)
( free=1072240)
( waste=0 =0.00%)
( Class space:)
( reserved=145215488, committed=6815744)
( used=6117872)
( free=697872)
( waste=0 =0.00%)
- Thread (reserved=20055984, committed=1083312)
(thread #19)
(stack: reserved=19968000, committed=995328)
(malloc=68136 #116)
(arena=19848 #35)
- Code (reserved=254867960, committed=18545144)
(malloc=1235448 #5350)
(mmap: reserved=253632512, committed=17309696)
- GC (reserved=190061883, committed=50801979)
(malloc=9997627 #7092)
(mmap: reserved=180064256, committed=40804352)
- Compiler (reserved=11178686, committed=11178686)
(malloc=35638 #532)
(arena=11143048 #15)
- Internal (reserved=389891, committed=389891)
(malloc=357123 #1153)
(mmap: reserved=32768, committed=32768)
- Symbol (reserved=13126528, committed=13126528)
(malloc=11383312 #133295)
(arena=1743216 #1)
- Native Memory Tracking (reserved=2835432, committed=2835432)
(malloc=8120 #101)
(tracking overhead=2827312)
- Arena Chunk (reserved=27594984, committed=27594984)
(malloc=27594984)
- Tracing (reserved=97, committed=97)
(malloc=97 #5)
- Logging (reserved=4572, committed=4572)
(malloc=4572 #192)
- Arguments (reserved=19067, committed=19067)
(malloc=19067 #495)
- Module (reserved=172456, committed=172456)
(malloc=172456 #1850)
- Synchronizer (reserved=157096, committed=157096)
(malloc=157096 #1302)
- Safepoint (reserved=8192, committed=8192)
(mmap: reserved=8192, committed=8192)
So it cannot connect to the config server, and because of that it cannot connect to the database and it cracks.
currency-exchange service application.yml:
spring:
application:
name: currency-exchange
config:
import: optional:configserver:http://localhost:8888
cloud:
config:
label: master
uri: http://localhost:8888
username: gigi
password: test1234
jpa:
show-sql: true
server:
port: 8000
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.gab.microservices</groupId>
<artifactId>currency-exchange-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>currency-exchange-service</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.h2database</groupId>-->
<!-- <artifactId>h2</artifactId>-->
<!-- <scope>runtime</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>eveningstar33/mmv2-${project.artifactId}:${project.version}</name>
<pullPolicy>IF_NOT_PRESENT</pullPolicy>
</image>
</configuration>
</plugin>
</plugins>
</build>
</project>
Any feedback will be apreciated! Thank you!
Every container is another host. You can't use loopback address for inter-container communication. The easiest way is to use docker-compose. It will configure dns names, and you will be able to use them for inter-container communication. Like http://config-server:8888 , http://currency-exchange:8000 , jdbc:mysql://docker-mysql:3306/testdb
maybe that answer will be usefull
Docker how to send request(curl - get, post) one container to another container
and you should check runtime classpath for db driver, like #jeekiii said.
i have not enought reputation for commenting, but i can edit my answer, if you comment it with any question.
If you generate the docker images and start all of them individually, they can't communicate with each as each docker container will have it's own network. So that's why we need to use docker compose, when we want our containers to communicate with each other.
try adding the jdbc driver as a dependency on your pom.xml, I don't see it in your dependencies.
It seems like the error is that it's not finding a driver class in your dependencies, so I'd start looking there.

Feign Client being ignored during component scan

I am creating a feign client to hit an external service. I added the following dependencies to my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>in.njari</groupId>
<artifactId>util</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>util</name>
<description>Utilities for API Dev</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>2.6.6</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
The two additions here are spring-cloud-starter-openfeign and spring-cloud-dependencies
Here is my feign client class :
#FeignClient(name = "chat-service", url = "${server.chatservice.url}")
public interface ChatServiceClient {
#PostMapping("/email/send")
void sendEmail(#RequestBody Map<String, String> sendEmailMap);
}
Next I'm autowiring this in one of my existing services. However, this leads to an error. What am I missing?
I tried adding #Service to my chatServiceClient, however that simply gives me this warning :
2022-04-11 17:02:07.358 DEBUG 87001 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Ignored because not a concrete top-level class: file [/Users/rajdeep/X/util/target/classes/in/njari/util/src/client/ChatServiceClient.class]
I think #FeignClient should be enough to register this as a bean, however it's not. What else do I need?
2022-04-11 16:50:41.917 INFO 86938 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$247290de] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.5.RELEASE)
2022-04-11 16:50:42.110 INFO 86938 --- [ main] in.njari.util.UtilApplication : No active profile set, falling back to default profiles: default
2022-04-11 16:50:42.236 DEBUG 86938 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Identified candidate component class: file [/Users/rajdeep/X/util/target/classes/in/njari/util/src/ExceptionReportingAdvice.class]
2022-04-11 16:50:42.268 DEBUG 86938 --- [ main] o.s.c.a.ClassPathBeanDefinitionScanner : Identified candidate component class: file [/Users/rajdeep/X/util/target/classes/in/njari/util/src/controller/UtilController.class]
2022-04-11 16:50:42.978 INFO 86938 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=9ddeaaa5-b9f2-314c-82de-bbd43b8d74ad
2022-04-11 16:50:43.129 INFO 86938 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$247290de] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-11 16:50:43.732 INFO 86938 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-04-11 16:50:43.753 INFO 86938 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-04-11 16:50:43.753 INFO 86938 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.31]
2022-04-11 16:50:43.887 INFO 86938 --- [ main] o.a.c.c.C.[.[localhost].[/util-service] : Initializing Spring embedded WebApplicationContext
2022-04-11 16:50:43.888 INFO 86938 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1722 ms
2022-04-11 16:50:43.930 WARN 86938 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'exceptionReportingAdvice': Unsatisfied dependency expressed through field 'chatServiceClient'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'in.njari.util.src.client.ChatServiceClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
2022-04-11 16:50:43.932 INFO 86938 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-04-11 16:50:43.948 INFO 86938 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-04-11 16:50:43.948 DEBUG 86938 --- [ main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#28cda624, started on Mon Apr 11 16:50:41 IST 2022
2022-04-11 16:50:44.091 ERROR 86938 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field chatServiceClient in in.njari.util.src.ExceptionReportingAdvice required a bean of type 'in.njari.util.src.client.ChatServiceClient' that could not be found.
The injection point has the following annotations:
- #org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'in.njari.util.src.client.ChatServiceClient' in your configuration.
Process finished with exit code 1
try to add #EnableFeignClients in your main class:
#SpringBootApplication
#EnableFeignClients
public class ExampleApplication {
public static void main(String[] args) {
SpringApplication.run(ExampleApplication.class, args);
}
}
see more: https://www.baeldung.com/spring-cloud-openfeign

Elasticsearch stops working after I run the springboot Java program and elasticsearch transport node is not loading in my Java Program

Elasticsearch version 8.1.3
Java version 1.8
Im trying to connect elasticsearch with Java springboot program. My Elasticsearch works fine until I run the Java program, also my java program works fine but with ".d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{LsJSQJtCS56wr7IM_S0h4Q}{localhost}{127.0.0.1:9300}]" on springboot error.
Also, as soon as I run my program as java application elasticsearch stops working with "[WARN ][o.e.x.c.s.t.n.SecurityNetty4Transport] [DESKTOP-ADQ0I0S] received plaintext traffic on an encrypted channel, closing connection Netty4TcpChannel{localAddress=/127.0.0.1:9300, remoteAddress=/127.0.0.1:59255, profile=default}"
My pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>
4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.elasticsearch</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-elasticsearch-example</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
Application.properties file
spring.data.elasticsearch.cluster-name=mycluster
spring.data.elasticsearch.cluster-nodes=localhost:9300
Output of my java program
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.1.RELEASE)
2022-04-22 20:53:48.890 INFO 18300 --- [ restartedMain] pringBootElasticsearchExampleApplication : Starting SpringBootElasticsearchExampleApplication on DESKTOP-ADQ0I0S with PID 18300 (started by Hp in D:\STS Project\demo)
2022-04-22 20:53:48.895 INFO 18300 --- [ restartedMain] pringBootElasticsearchExampleApplication : No active profile set, falling back to default profiles: default
2022-04-22 20:53:49.012 INFO 18300 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-04-22 20:53:49.012 INFO 18300 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-04-22 20:53:50.085 INFO 18300 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2022-04-22 20:53:50.169 INFO 18300 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 77ms. Found 1 repository interfaces.
2022-04-22 20:53:51.242 INFO 18300 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-04-22 20:53:51.280 INFO 18300 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-04-22 20:53:51.281 INFO 18300 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13
2022-04-22 20:53:51.302 INFO 18300 --- [ restartedMain] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\STS\sts-4.13.0.RELEASE\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.1.v20211116-1657\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:/STS/sts-4.13.0.RELEASE//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.1.v20211116-1657/jre/bin/server;D:/STS/sts-4.13.0.RELEASE//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.1.v20211116-1657/jre/bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Program Files\Java\jdk1.8.0_202\bin;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Azure Data Studio\bin;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\Hp\AppData\Local\Microsoft\WindowsApps;;C:\Users\Hp\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Hp\AppData\Roaming\npm;C:\Program Files\Azure Data Studio\bin;C:\Program Files\Azure Data Studio\bin;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.1\bin;;D:\STS\sts-4.13.0.RELEASE;;.]
2022-04-22 20:53:51.464 INFO 18300 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-04-22 20:53:51.464 INFO 18300 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2452 ms
2022-04-22 20:53:51.996 INFO 18300 --- [ restartedMain] o.elasticsearch.plugins.PluginsService : no modules loaded
2022-04-22 20:53:51.997 INFO 18300 --- [ restartedMain] o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.index.reindex.ReindexPlugin]
2022-04-22 20:53:51.997 INFO 18300 --- [ restartedMain] o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.join.ParentJoinPlugin]
2022-04-22 20:53:51.998 INFO 18300 --- [ restartedMain] o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.percolator.PercolatorPlugin]
2022-04-22 20:53:51.998 INFO 18300 --- [ restartedMain] o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.script.mustache.MustachePlugin]
2022-04-22 20:53:51.998 INFO 18300 --- [ restartedMain] o.elasticsearch.plugins.PluginsService : loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2022-04-22 20:53:53.600 INFO 18300 --- [ restartedMain] o.s.d.e.c.TransportClientFactoryBean : Adding transport node : 127.0.0.1:9300
2022-04-22 20:53:53.962 INFO 18300 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2022-04-22 20:53:53.985 ERROR 18300 --- [ restartedMain] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{LsJSQJtCS56wr7IM_S0h4Q}{localhost}{127.0.0.1:9300}]
2022-04-22 20:53:54.354 INFO 18300 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2022-04-22 20:53:54.920 INFO 18300 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-04-22 20:53:54.924 INFO 18300 --- [ restartedMain] pringBootElasticsearchExampleApplication : Started SpringBootElasticsearchExampleApplication in 6.707 seconds (JVM running for 8.106)
Error I get on elasticsearch terminal as soon as I run the Java program
[2022-04-22T20:46:04,821][INFO ][o.e.i.g.DatabaseNodeService] [DESKTOP-ADQ0I0S] successfully loaded geoip database file [GeoLite2-City.mmdb]
[2022-04-22T20:53:53,786][WARN ][o.e.x.c.s.t.n.SecurityNetty4Transport] [DESKTOP-ADQ0I0S] received plaintext traffic on an encrypted channel, closing connection Netty4TcpChannel{localAddress=/127.0.0.1:9300, remoteAddress=/127.0.0.1:59255, profile=default}
To access Elasticsearch with Java I have followed this YouTube video tutorial
[1]: https://www.youtube.com/watch?v=dlChXjE7IHw&t=541s
Also, im not able to add the type and shards parameter in the #Document annotation in my model. it is only accepting
#Document(indexName= "myindex")
According to the video it should be
#Document(indexName= "myindex" type="customer", shards=2)
elasticsearch.yml file
cluster.name: mycluster
path.data: D:\STS Project\demo
action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: true
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["DESKTOP-ADQ0I0S"]
http.host: [_local_, _site_]
I was using transport client 9300 which is deprecated in Elasticsearch 7 and not supported in version 8 and I was using version 8.1.3.
Here we can use the supported Elastic version 7.x or use Elasticsearch Java API client. [Elasticsearch Java API Client 8.1.3] Elasticsearch Java API Client 8.1.3

Spring Boot Security causes application to shutdown when deployed to GAE when locally everything works fine

I'm having a problem with Spring Security and OAuth 2.0 on Google App Engine.
I set up OAuth using this tutorial and everything works fine locally. When accessing any endpoint other than "/" you're being redirected to Google login page.
Problem starts when I deploy application to Google App Engine.
Application keeps restarting and the logs aren't very clear. I tried setting up everything from scratch and I found that even when changing only pom.xml file and adding either spring-boot-starter-security or spring-boot-starter-oauth2-client dependency without adding any security related code causes application to restart.
I think it may be something related to security autoconfiguration, but I'm mostly .NET developer and I really have no clue how to even find this error.
What I expect is application to work as fine on GAE as it works locally.
My pom.xml file looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>time-off-backend</artifactId>
<packaging>jar</packaging>
<name>time-off-backend</name>
<description>Time-off project</description>
<groupId>pl.devapo</groupId>
<version>1.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
</properties>
<profiles>
<profile>
<id>cloud-gcp</id>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter</artifactId>
<version>1.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.2</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.5.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>
pl.devapo.timeoff.TimeOffApplication
</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- todo delete-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
app-test.yaml file:
runtime: java11
service: backend-test
entrypoint: java -Xmx64m -jar target/time-off-backend-1.0.0.jar --debug
env_variables:
SPRING_PROFILES_ACTIVE: "test"
DATABASE_USERNAME: ...
DATABASE_PASSWORD: ...
handlers:
- url: /.*
script: this field is required, but ignored
manual_scaling:
instances: 1
in my application.properties file I added these two lines:
spring.security.oauth2.client.registration.google.client-id=...
spring.security.oauth2.client.registration.google.client-secret=...
and finally my SecurityConfig.java file:
package pl.devapo.timeoff.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
#Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Override
public void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/**").authorizeRequests()
.antMatchers(new String[]{"/", "/not-restricted"}).permitAll()
.anyRequest().authenticated()
.and()
.oauth2Login();
}
}
Logs look like this:
2021-07-20 17:07:56 backend-test[20210720t190541] . ____ _ __ _ _
2021-07-20 17:07:56 backend-test[20210720t190541] /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2021-07-20 17:07:56 backend-test[20210720t190541] ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2021-07-20 17:07:56 backend-test[20210720t190541] \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2021-07-20 17:07:56 backend-test[20210720t190541] ' |____| .__|_| |_|_| |_\__, | / / / /
2021-07-20 17:07:56 backend-test[20210720t190541] =========|_|==============|___/=/_/_/_/
2021-07-20 17:07:56 backend-test[20210720t190541] :: Spring Boot :: (v2.4.4)
2021-07-20 17:07:56 backend-test[20210720t190541]
2021-07-20 17:07:57 backend-test[20210720t190541] 2021-07-20 17:07:57.024 INFO 10 --- [ main] pl.devapo.timeoff.TimeOffApplication : Starting TimeOffApplication using Java 11.0.11 on localhost with PID 10 (/workspace/target/time-off-backend-1.0.0.jar started by www-data in /workspace)
2021-07-20 17:07:57 backend-test[20210720t190541] 2021-07-20 17:07:57.028 INFO 10 --- [ main] pl.devapo.timeoff.TimeOffApplication : The following profiles are active: test
2021-07-20 17:07:58 backend-test[20210720t190541] 2021-07-20 17:07:58.759 INFO 10 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-07-20 17:07:58 backend-test[20210720t190541] 2021-07-20 17:07:58.919 INFO 10 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 148 ms. Found 6 JPA repository interfaces.
2021-07-20 17:08:00 backend-test[20210720t190541] 2021-07-20 17:08:00.006 INFO 10 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-07-20 17:08:00 backend-test[20210720t190541] 2021-07-20 17:08:00.024 INFO 10 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-07-20 17:08:00 backend-test[20210720t190541] 2021-07-20 17:08:00.024 INFO 10 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.44]
2021-07-20 17:08:00 backend-test[20210720t190541] 2021-07-20 17:08:00.108 INFO 10 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-07-20 17:08:00 backend-test[20210720t190541] 2021-07-20 17:08:00.108 INFO 10 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2967 ms
2021-07-20 17:08:00 backend-test[20210720t190541] 2021-07-20 17:08:00.836 INFO 10 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-07-20 17:08:00 backend-test[20210720t190541] 2021-07-20 17:08:00.929 INFO 10 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.29.Final
2021-07-20 17:08:01 backend-test[20210720t190541] 2021-07-20 17:08:01.162 INFO 10 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-07-20 17:08:01 backend-test[20210720t190541] 2021-07-20 17:08:01.320 INFO 10 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-07-20 17:08:01 backend-test[20210720t190541] 2021-07-20 17:08:01.649 INFO 10 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-07-20 17:08:01 backend-test[20210720t190541] 2021-07-20 17:08:01.705 INFO 10 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-07-20 17:08:03 backend-test[20210720t190541] 2021-07-20 17:08:03.478 INFO 10 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-07-20 17:08:03 backend-test[20210720t190541] 2021-07-20 17:08:03.501 INFO 10 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-07-20 17:08:04 backend-test[20210720t190541] 2021-07-20 17:08:04.444 WARN 10 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-07-20 17:08:05 backend-test[20210720t190541] 2021-07-20 17:08:05.096 INFO 10 --- [ main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
2021-07-20 17:08:05 backend-test[20210720t190541] 2021-07-20 17:08:05.407 INFO 10 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.071 INFO 10 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will secure Ant [pattern='/**'] with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#2ac519dc, org.springframework.security.web.context.SecurityContextPersistenceFilter#2b73bd6b, org.springframework.security.web.header.HeaderWriterFilter#5f0bab7e, org.springframework.security.web.csrf.CsrfFilter#1eb9a3ef, org.springframework.security.web.authentication.logout.LogoutFilter#2da81754, org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter#5e593b08, org.springframework.security.oauth2.client.web.OAuth2LoginAuthenticationFilter#3946075, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#4998e74b, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#3d53e6f7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#750ed637, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#18d11527, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#1de4bee0, org.springframework.security.web.session.SessionManagementFilter#337a6d30, org.springframework.security.web.access.ExceptionTranslationFilter#58fd1214, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#3fe512d2]
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.163 INFO 10 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.166 INFO 10 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.244 INFO 10 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.311 INFO 10 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.312 INFO 10 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.343 INFO 10 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 31 ms
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.346 INFO 10 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.617 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: findUsingGET_1
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.620 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: getUsingGET_1
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.655 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: findUsingGET_2
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.657 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: getUsingGET_2
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.669 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: findUsingGET_3
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.671 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: getUsingGET_3
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.687 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: cancelUsingPOST_1
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.695 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: findUsingGET_4
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.697 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: getUsingGET_4
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.705 INFO 10 --- [ main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: saveUsingPOST_1
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.769 INFO 10 --- [ main] pl.devapo.timeoff.TimeOffApplication : Started TimeOffApplication in 10.578 seconds (JVM running for 11.602)
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.796 INFO 10 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.801 INFO 10 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.804 INFO 10 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-07-20 17:08:06 backend-test[20210720t190541] 2021-07-20 17:08:06.808 INFO 10 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2021-07-20 17:08:07 backend-test[20210720t190541] {"severity": "WARNING", "message": "App is listening on port 8080. We recommend your app listen on the port defined by the PORT environment variable to take advantage of an NGINX layer on port 8080."}\n
After reviewing logs in debug level we found out that GAE needs endpoint /_ah/start to start the application and since spring security autoconfiguration secures all endpoints by default you need to unsecure /_ah/start endpoint in order to make it work well on GAE.
So after adding these to our SecurityConfig configure method everything started working well:
#Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/_ah/start").permitAll()
.and()
.antMatcher("/**").authorizeRequests()
.anyRequest().authenticated()
.and()
.oauth2Login();
}
}

Spring boot 2.2.1- Unable to start embed tomcat(no errors in log)

Am working on a Spring Boot application having version 2.2.1RELEASE.Application structure ,i have moved configuration into config folder as external configuration.Project structure should be like this
When i run my application its showing following log
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.1.RELEASE)
2019-12-12 20:34:41.631 INFO 375592 --- [ main] c.g.h.x.app.services.api.erviceMain : Starting ServiceMain v1.0 on host-4 with PID 375592 (D:\Service\target\Service-10.jar started by Administrator in D:\Service\target)
2019-12-12 20:34:41.636 INFO 375592 --- [ main] c.g.h.x.app.services.api.ServiceMain : The following profiles are active: Service
2019-12-12 20:34:45.086 INFO 375592 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-12-12 20:34:45.477 INFO 375592 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 154ms. Found 0 repository interfaces.
408 SybaseUnit INFO [main] openjpa.Enhance - You have enabled runtime enhancement, but have not specified the set of persistent classes. OpenJPA must look for metadata for every loaded class, whi
ch might increase class load times significantly.
296 SybaseUnit WARN [main] openjpa.Runtime - An error occurred while registering a ClassTransformer with PersistenceUnitInfo: name 'SybaseUnit', root URL [file:/D:/Service/targetService-1.0.jar]. The error has been consumed. To see it, set your openjpa.Runtime log level to TRACE. Load-time class transformation will not
be available.
312 SybaseUnit WARN [main] openjpa.Runtime - Could not create the optional validation provider. Reason returned: "A default ValidatorFactory could not be created."
2019-12-12 20:34:50.108 INFO 375592 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'SybaseUnit'
0 MssqlUnit INFO [main] openjpa.Enhance - You have enabled runtime enhancement, but have not specified the set of persistent classes. OpenJPA must look for metadata for every loaded class, which
might increase class load times significantly.
0 MssqlUnit WARN [main] openjpa.Runtime - An error occurred while registering a ClassTransformer with PersistenceUnitInfo: name 'MssqlUnit', root URL [file:/D:/Service/target/Service-1.0.jar]. The error has been consumed. To see it, set your openjpa.Runtime log level to TRACE. Load-time class transformation will not be
available.
0 MssqlUnit WARN [main] openjpa.Runtime - Could not create the optional validation provider. Reason returned: "A default ValidatorFactory could not be created."
2019-12-12 20:34:50.140 INFO 375592 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'MssqlUnit'
log4j:WARN No appenders could be found for logger (com..manager.data).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2019-12-12 20:34:53.284 INFO 375592 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'TaskExecutor'
2019-12-12 20:34:53.328 INFO 375592 --- [ main] ca.uhn.fhir.util.VersionUtil : HAPI FHIR version is: 1.4
2019-12-12 20:34:53.335 INFO 375592 --- [ main] ca.uhn.fhir.context.FhirContext : Creating new FHIR context for FHIR version [DSTU3]
2019-12-12 20:34:54.946 INFO 375592 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService
2019-12-12 20:34:55.343 INFO 375592 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'asyncExecutor'
2019-12-12 20:34:57.647 INFO 375592 --- [ main] c.g.h.x.app.services.api.ServiceMain : Started ServiceMain in 19.208 seconds (JVM running for 21.409)
Pom.xml file having added following dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
<!-- <exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion> -->
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
I have tried following possible solutions.
update and clean my projects.
delete .m2 repository
and also refer following stack links.
1.Spring boot application not starting embedded tomcat
2.Spring boot deployed on tomcat won't start
Didn't get any solution yet.
Note:-
have noticed two line in my log
2019-12-12 20:34:45.086 INFO 375592 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-12-12 20:34:45.477 INFO 375592 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 154ms. Found 0 repository interfaces.
This can be caused by the interfaces not being on the same level as the main class with the #SpringBootApplication annotation.
Here is an example.
Notice that all sub-packages are on the same level as the #SpringBootApplication.

Categories