I am trying spring cloud config server. My client's configuration has a context.initializer.classes property. But when the client load configuration from the config server, the server will load class according context.initializer.classes
and then report classnotfound error. The context.initializer.classes
property is for client side, so the config server should not run the context initializer.
The reason maybe is that the config server load client's configuration with a new SpringApplication. When SpringApplication bootstrap, Spring load context.initializer.classes
.
Comment From: ryanjbaxter
I don't think the config server is loading the clients configuration properties its just serving them via http requests to the clients. Maybe you can provide a sample that reproduces the issue?
Comment From: spencergibb
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: etyberick
Hi @spencergibb can we reopen this issue? I'm actually facing the same problem and I'm trying to find a solution.
Comment From: spencergibb
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
Comment From: etyberick
Hi, thanks for answering so swiftly and... sure! My client is using Spring Boot v2.1.10.RELEASE. Due to NDA I can't reveal the real data but I'll do my best trying to explain the bug:
I got these configuration files sitting on a github repo, that part is actually working because when I fetch certain configuration files I get the information as expected, the funny part begins when the "application.properties" file we're fetching contains a field named "context.initializer.classes" because when I call the endpoint for fetching the configuration I'm getting a faulty loading stacktrace in console.
org.springframework.context.ApplicationContextException: Failed to load context initializer class [foo.bar.foo.bar.foo.bar.foo]; nested exception is java.lang.ClassNotFoundException: foo.bar.foo.bar.foo.bar.foo
at org.springframework.boot.context.config.DelegatingApplicationContextInitializer.getInitializerClass(DelegatingApplicationContextInitializer.java:78) ~[spring-boot-2.1.10.RELEASE.jar!/:2.1.10.RELEASE]
.
.
.
Caused by: java.lang.ClassNotFoundException: foo.bar.foo.bar.foo.bar.foo
Comment From: spencergibb
Unfortunately, spring boot 2.1.x is end of life as is Spring Cloud Greenwich.
We don't need your full application, just a sample that reproduces the issue. If you can do that with boot 2.2..12 and cloud Hoxton.SR9 I can take the time to investigate.
Comment From: etyberick
I think they chose this particular version for some java version compatibility reasons, I'll need to research and understand their reasons but in the meanwhile I'll try with 2.2.12 and come back to you, thanks for clarifying.
Comment From: etyberick
@spencergibb I'm using v2.3.2.RELEASE and I'm still facing the same issue.
Comment From: spencergibb
Ok. We'll wait for a complete, minimal, verifiable sample that reproduces the problem.
Comment From: etyberick
Herre's my application.yml contents
info:
component: Config Server
spring:
application:
name: configserver
jmx:
default_domain: cloud.config.server
cloud:
config:
server:
git:
uri: https://github.com/Foo/bar
username: foo
password: bar
cloneOnStart: true
searchPaths: '{application}/{profile}'
repos:
special:
pattern:
- '*/stage*'
- '*/prod*'
uri: https://github.com/Foo/bar2
username: foo
password: bar
cloneOnStart: true
searchPaths: '{application}/{profile}'
management:
context_path: /admin
and when I fetch an address, one of the file that fails hosted on github contains a field like this: `
Initializer
context.initializer.classes=foo.bar.foo.bar.foo.bar `
and then when I call the configuration fetch I get the error of the class not found because it's trying to initialize that class.
Consider I'm just using spring config as a configuration fetching server, nothing else, as simple as that and I'm getting that error, I tried adding to the url arguments the variable resolvePlaceholders=false
but it happens anyway.
Comment From: spencergibb
That's not a complete, minimal, verifiable sample that reproduces the problem.