Spring-cloud-config: ConfigurationClassPostProcessor cannot enhance bean "refreshScope"

Created on 14 May 2016  路  15Comments  路  Source: spring-cloud/spring-cloud-config

WARN [org.springframework.context.annotation.ConfigurationClassPostProcessor] - 
<Cannot enhance @Configuration bean definition 'refreshScope' since its singleton instance has been
created too early. The typical cause is a non-static @Bean method with a 
BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.>

Seeing this with Spring 2.4.6. Recently upgraded from 1.0.4.RELEASE where this warning was non-apparent. Is this something to be concerned about?

question

Most helpful comment

In our App which i would subsume under "sufficiently complex", this is the ONLY warning that is logged during startup. Besides that you are right, the original question was a little bit different. Nevertheless i think it is a bad practice having WARN's logged out that ought to be ignored.
And finally there might be a reason why the Spring people introduced it and it might indicate improper usage.

All 15 comments

/cc @dima767

Are you using @RefreshScope on a @Configuration class? There is a corresponding note in the documentation regarding that. See the RefreshScope section. Generally speaking, configuration classes themselves are not what you want to make refresh scope.

Thanks. It appears that there a quite a few Configuration classes that do carry that annotation. I'll get them removed.

Turns out this isnt quite solved: I removed all traces of @RefreshScope from all @Configuration classes, and ran a global search to ensure. I still see the log warning message.

If it helps, I am using Boot 1.3.5.RELEASE

I think it's fine. It's just telling you about a bean that is configured in the framework now.

Thanks for the confirmation.

Of course, would have been more reassuring if it wasnt logged as WARN, but I understand that is core to Spring and not the cloud config.

Hallo @dsyer ,

i don't think it's fine having a WARN logged on every application startup. Won't you agree?

I don't think this is the only WARN log when an app starts up, once it gets to something sufficiently complex. Besides I don't think there is a way to stop this one, since it comes from Spring (not from Spring Cloud). If you see a way to stop it please open a new issue, since it is not really relevant to the original question here.

In our App which i would subsume under "sufficiently complex", this is the ONLY warning that is logged during startup. Besides that you are right, the original question was a little bit different. Nevertheless i think it is a bad practice having WARN's logged out that ought to be ignored.
And finally there might be a reason why the Spring people introduced it and it might indicate improper usage.

I suggest you take it up with the Spring team then (https://jira.spring.io/browse/SPR) and/or open a new issue here.

Getting an App completely WARN-free is common practice in our organisation because we have a WARNINGS histogram chart on our DevOps monitor. We want this chart to be free of "noise" so that we can see when anything really goes wrong. Therefore regular warnings or errors that get logged every so often are very annoying for us. I think this bug should be reopened.

Maybe you didn't read the comment above? In my opinion this warning is completely benign, and we don't control it in Spring Cloud anyway, so calling it a "bug" is a tad incendiary, and unlikely to win you any friends. Please open an issue in the Spring JIRA if you want to dig into the technical reasons for the log.

Also, RefreshScope is in Spring Cloud Commons, so this is the wrong place to discuss changes.

@BastianVoigt, you can configure the log level for that specific class to turn off logging.

Was this page helpful?
0 / 5 - 0 ratings