Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After disabling Spring Auto Reconfiguration, application is not able to connect to config server(this leads to placeholder resolve problem) #1053

Open
dev-praveen opened this issue Feb 9, 2024 · 4 comments

Comments

@dev-praveen
Copy link

We have a spring boot application that is deployed in PCF and works fine until we tried to migrate it to java-cfenv-boot library by following the migration guide and removing the dependencies it suggests. However, we encounter a problem with the centralized configuration. The application fails to get the placeholder values from the Spring Cloud Config Server (bound to PCF).
This is the error we get: [OUT] Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder ‘some.value’ in value “${some.value}”

removed
org.springframework.boot:spring-boot-starter-cloud-connectors
or
org.springframework.cloud:spring-cloud-core
org.springframework.cloud:spring-cloud-connectors-core
org.springframework.cloud:spring-cloud-cloudfoundry-connector
org.springframework.cloud:spring-cloud-spring-service-connector dependencies from pom file

added

io.pivotal.cfenv java-cfenv-boot 2.4.0 dependency
spring.profiles.active: dev,cloud
JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}'

Application couldn't able to locate the real config server and it is fall back to localhost
024-02-08T17:22:22.762+05:30 [APP/PROC/WEB/0] [OUT] 2024-02-08 11:52:22.761 INFO 8 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888/
2024-02-08T17:22:22.892+05:30 [APP/PROC/WEB/0] [OUT] 2024-02-08 11:52:22.892 WARN 8 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/dev,cloud": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2024-02-08T17:22:22.895+05:30 [APP/PROC/WEB/0] [OUT] 2024-02-08 11:52:22.895 INFO 8 --- [ main] c.t.a.s.migration.Application : The following profiles are active: dev,cloud

without removing the above dependencies below are the logs

2024-01-25T12:52:52.305+05:30 [APP/PROC/WEB/0] [OUT] 2024-01-25 07:22:52.305 INFO 7 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: https://config-server-11121121a-fdec-4ba5-c654-5ccff667744.apps.np.app.com/

2024-01-25T12:52:54.122+05:30 [APP/PROC/WEB/0] [OUT] 2024-01-25 07:22:54.122 INFO 7 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource {name='credhub-app-dev-master'}, MapPropertySource {name='credhub-app-dev-master'}, MapPropertySource {name='ssh://[email protected]:22/var/vcap/store/mirror/8475euhfjy348573857rjhgdfjh745647/davinci-config/davinci-app-dev.properties'}, MapPropertySource {name='ssh://[email protected]:22/var/vcap/store/mirror/8475euhfjy348573857rjhgdfjh745647/davinci-config/application.properties'}]]

please help us why after removing recommended dependencies from the documentation application is not able to locate the real config server.

@pivotal-david-osullivan
Copy link
Contributor

Can you please share the following?

  • pom.xml with SCS etc. versions
  • VCAP_SERVICES with the Config Server binding
  • Example of a property placeholder that cannot be resolved (are you using a prefix?)

@dev-praveen
Copy link
Author

thanks for the reply @pivotal-david-osullivan

pom.xml with SCS etc. versions
we have removed the connector libraries from the project as suggested in migration guide

VCAP_SERVICES with the Config Server binding
[
{
"label": "p.config-server",
"provider": null,
"plan": "standard",
"name": "dev-app-config-server",
"tags": [
"configuration",
"spring-cloud"
],
"instance_guid": "1212343a-fdec-4ba5-b318-87fdhjdyt6",
"instance_name": "dev-app-config-server",
"binding_guid": "e535435-5221-4b8e-97ea-7hjhjgj",
"binding_name": null,
"credentials": {
"credhub-ref": "/c/p.spring-cloud-services-scs-service-broker/e9ca123d-c312-4f57-88a4-djf454545/ecb4186d-65444-4b8e-97ea-djfbj677d5fdfd6c4d/credentials-json"
},
"syslog_drain_url": null,
"volume_mounts": []
}
]
Example of a property placeholder that cannot be resolved (are you using a prefix?)
java.lang.IllegalArgumentException: Could not resolve placeholder 'threadpool.corepool.size' in value
"${threadpool.corepool.size}"

  actually threadpool.corepool.size is configured in external properties file hosted in gitlab and this placeholder should be 
  available via config server.

my analysis(why it is not working) is it's because of removal of connector libraries. From the logs it's clear that my application is not able to locate the real SCS bounded in PCF. (it should not be localhost)
ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888/

do i need to add manual connection configuration via bootstrap.yml file something like below. or any extra libraries along with java-cfenv i need to add it in pom file

spring:
application:
name: app-one
cloud:
config:
profile: dev
config:
import: configserver:http://localhost:8888

if it is our SCS is protected with oauth2.0. any reference for the same.

@pivotal-david-osullivan
Copy link
Contributor

pom.xml with SCS etc. versions
we have removed the connector libraries from the project as suggested in migration guide

By SCS I am referring to Spring Cloud Services - do you still have client libraries for use with SCS as well as Spring Cloud versions in your pom?

@dev-praveen
Copy link
Author

sorry for the confusion yes we have some, below are the ones.

            <dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-config-client</artifactId>
		<version>1.4.3.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-context</artifactId>
		<version>1.2.3.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>com.marcosbarbero.cloud</groupId>
		<artifactId>spring-cloud-config-client-oauth2</artifactId>
		<version>1.0.1.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter</artifactId>
		<version>1.2.3.RELEASE</version>
		<exclusions>
			<exclusion>
				<groupId>org.bouncycastle</groupId>
				<artifactId>bcpkix-jdk15on</artifactId>
			</exclusion>
			<exclusion>
				<groupId>org.bouncycastle</groupId>
				<artifactId>bcprov-jdk15on</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants