Describe the bug In Spring config, values are supposed to fetch from DB. And, when starting the application embedded tomcat failing to start The same application is running in other systems.
'@SpringBootApplication' & '@EnableConfigServer' these 2 annotations are given in main class
In "debug=true", it is saying to add git url, but I have no where mentioned to provide git url & I need to get proeprties from db.
`
05-11-2020 19:44:45.201 [/] [main] DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter.report - Application failed to start due to an exception
java.lang.IllegalStateException: You need to configure a uri for the git repository.
at org.springframework.util.Assert.state(Assert.java:73)
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.afterPropertiesSet(JGitEnvironmentRepository.java:247)
at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.afterPropertiesSet(MultipleJGitEnvironmentRepository.java:68)
`
`
05-11-2020 19:14:42.278 [/] [main] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].log - Initializing Spring embedded WebApplicationContext
05-11-2020 19:14:42.279 [/] [main] INFO org.springframework.web.context.ContextLoader.prepareWebApplicationContext - Root WebApplicationContext: initialization completed in 1686 ms
05-11-2020 19:14:42.726 [/] [main] ERROR org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup - Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configServerHealthIndicator' defined in class path resource [org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.class]: Unsatisfied dependency expressed through method 'configServerHealthIndicator' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.config.server.config.CompositeConfiguration': Unsatisfied dependency expressed through method 'setEnvironmentRepos' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultEnvironmentRepository' defined in class path resource [org/springframework/cloud/config/server/config/DefaultRepositoryConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: You need to configure a uri for the git repository.
05-11-2020 19:14:42.743 [/] [main] INFO org.apache.catalina.core.StandardService.log - Stopping service [Tomcat]
05-11-2020 19:14:42.768 [/] [main] WARN org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext.refresh - 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
05-11-2020 19:14:42.794 [/] [main] INFO org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener.logMessage -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
05-11-2020 19:14:42.798 [/] [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter.report -
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
`
Gradle file ` plugins { id 'org.springframework.boot' version '2.1.4.RELEASE' }
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "Greenwich.RELEASE")
}
dependencies {
runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
implementation ('org.springframework.boot:spring-boot-starter-data-jpa')
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security'
implementation ('org.projectlombok:lombok:1.18.8')
annotationProcessor('org.projectlombok:lombok:1.18.8')
implementation 'org.springframework.cloud:spring-cloud-config-server'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
`
application.properties `
server.port=7777
spring.application.name=config-server
spring.mvc.servlet.path=/config
spring.cloud.config.server.jdbc.sql=select NAME, VALUE from PROPERTIES where APPLICATION=? and PROFILE=? and LABEL=?
spring.cloud.config.server.jdbc.order=1
#spring.profiles.active=jdbc
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:sqlserver://ec2-A-B-C-D.ap-south-1.compute.amazonaws.com:6380;databaseName=app_config
spring.datasource.username=dbuser
spring.datasource.password=dbpassword
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.security.user.name=user
spring.security.user.password=password
`
I am not able to understand the error mentioned in console. Let me know what may be the cause of this issue.
Comment From: spencergibb
Please upgrade to Hoxton.SR8 and the latest spring boot 2.3.x and try again
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: satishpatro44
It worked. Only thing I was providing profile "spring.profile.active" in system argument, after removing that one it worked. What is the reason, is in config server spring profile means git profile?