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

Cannot enhance @Configuration bean definition 'beanNamePlaceholderRegistryPostProcessor' #29

Closed
chenrui333 opened this issue Jun 27, 2016 · 19 comments

Comments

@chenrui333
Copy link

chenrui333 commented Jun 27, 2016

I have tried to apply the similar setup for the other app, but I have encountered this issue.

Jun 27, 2016 12:33:50 PM org.apache.catalina.startup.VersionLoggerListener log WARNING: Cannot enhance @Configuration bean definition 'beanNamePlaceholderRegistryPostProcessor' 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'.
Jun 27, 2016 12:34:25 PM org.apache.catalina.startup.TldConfig execute SEVERE: Context [] startup failed due to previous errors
Jun 27, 2016 12:34:32 PM org.springframework.web.context.support.XmlWebApplicationContext doClose

Can anyone takes a look at this?

@chenrui333
Copy link
Author

As far as I can see in the code, it has been already declared as static return, why does it still complain?
code ref

@chenrui333
Copy link
Author

chenrui333 commented Jun 27, 2016

FYI:
I have fixed this error

WARNING: @Bean method ServiceConfig.propertyPlaceholderConfigurer is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @Resource and @PostConstruct within the method's declaring @Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @Bean javadoc for complete details.

By adding the static modifier to PropertySourcesPlaceholderConfigurer to

    @Bean
    public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
        return new PropertySourcesPlaceholderConfigurer();
    }

which I did not do before.

@ulisesbocchio
Copy link
Owner

do you need further help?

@chenrui333
Copy link
Author

For the tomcat one, yes.

@chenrui333
Copy link
Author

I still have the tomcat issue, but the FYI message is just for another issue.

@chenrui333
Copy link
Author

no way to reopen this?

@ulisesbocchio
Copy link
Owner

Yeah, please reopen and explain what's the situation. If you have sample code where the issue manifests even better so I can test and make sure I got you covered.

@chenrui333
Copy link
Author

I found there is no way to re-open the issue.

The jar actually works pretty well with my sample codebase, but the real integration does the opposite.

@ulisesbocchio
Copy link
Owner

As far as warnings go,beanNamePlaceholderRegistryPostProcessor has been static for a while and there's no warning being raised. Check out the demo apps, there's a bunch of them

@ulisesbocchio ulisesbocchio reopened this Jul 1, 2016
@ulisesbocchio
Copy link
Owner

what's the "real" integration? Can you create a repo with a "real" example in your github accound and share it with me?

@chenrui333
Copy link
Author

chenrui333 commented Jul 1, 2016

Yes, I was trying to confirm with you whether you have seen that issue first.

Now, I guess I need to try to reproduce the issue now. I still do not know the root cause yet.

@chenrui333
Copy link
Author

Will get back to this by the end of this week.

@gorky
Copy link

gorky commented Oct 16, 2016

Seeing this issue with "com.github.ulisesbocchio:jasypt-spring-boot-starter:1.8"

@ulisesbocchio
Copy link
Owner

@gorky, Can you explain what you see? Is it just the warning? On tomcat? Do you have a code sample?

@ulisesbocchio ulisesbocchio reopened this Oct 16, 2016
@gorky
Copy link

gorky commented Oct 17, 2016

Thanks for your quick reply!

It's the Tomcat that is embedded in Spring Boot, although it hasn't started when these methods are logged. I don't currently have a code sample I can post in a public forum (my apologies).
[2016-10-17 17:37:14.278 -0500] - 17939 WARN [main] --- o.s.c.a.ConfigurationClassPostProcessor: Cannot enhance @Configuration bean definition 'beanNamePlaceholderRegistryPostProcessor' 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'. [2016-10-17 17:37:15.112 -0500] - 17939 INFO [main] --- c.u.j.EnableEncryptablePropertySourcesPostProcessor: Post-processing PropertySource instances [2016-10-17 17:37:15.178 -0500] - 17939 INFO [main] --- c.u.j.c.StringEncryptorConfiguration: String Encryptor custom Bean not found with name 'jasyptStringEncryptor'. Initializing String Encryptor based on properties with name 'jasyptStringEncryptor'
Annoyingly, I have a Jar in the classpath with a Config that is defining a bean with the name jasyptStringEncryptor and that config is definitely not getting loaded by Spring Boot. And this is causing decryption to fail as the seeding password doesn't get read/loading. When I drop the dependency on the jasypt-spring-boot-starter, the jar and included config are read but then fail on loading due to missing required jasypt classes.

We are using org.springframework.boot.loader.PropertiesLauncher with -Dloader.path set to include the jars that have our jasypt beans defined. Feel free to PM me.

Regards,
Steve

@gorky
Copy link

gorky commented Oct 18, 2016

Found the issue with the jar not being picked up -- a directory name had be changed w/o an update in the -Dloader.path. When I corrected the directory name I started getting quite a few interesting failures -- trying to work my way through them. I will keep this thread updated.

@ulisesbocchio
Copy link
Owner

Alright, thanks, let me know if you need further assistance. I was checking the sample apps I have and I don't see the warning in any of them

@gorky
Copy link

gorky commented Oct 18, 2016

Ok, this is issue is resolved. I've walked into some others, but I can open a ticket and supply a test case. Feel free to close this one as "End User Configuration Error -- corrected".

And thanks!

@lakshmandev
Copy link

The issue is fixed now in version 4.2.6, 4.3 RC2. Please refer this ticket https://jira.spring.io/browse/SPR-14234

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

4 participants