Closed membersound closed 1 week ago
Please have a look here: https://github.com/spring-projects/spring-batch/issues/4519#issuecomment-1860530016
Does this answer your question?
No, when I exlude the jobRegistryBeanPostProcessor
then my batch application breaks entirely.
I need that class probably from spring internals for the batch processing.
Have you tried exposing a JobRegistrySmartInitializingSingleton
instead? It's the recommended replacement of the JobRegistryBeanPostProcessor
: https://docs.spring.io/spring-batch/reference/job/advanced-meta-data.html#jobregistrysmartinitializingsingleton
If that should not work out and you have additional questions, please provide more specific descriptions of the problems you are facing. For example by including logs and stacktraces of your application failures.
I did not know I have to, bc I though from "Convention over Configuration" point of view, this should not be necessary?
And still, even if I register the following bean, the errors are printed.
@Bean
public JobRegistrySmartInitializingSingleton jobRegistrySmartInitializingSingleton(JobRegistry jobRegistry) {
return new JobRegistrySmartInitializingSingleton(jobRegistry);
}
Logs attached in initial post.
According to the last line of the logs you posted, you did not add the code snippet from https://github.com/spring-projects/spring-batch/issues/4519#issuecomment-1860530016.
That's true, I added them how they were before adding the additional bean. Here, see still the errors when I add the bean:
:: Spring Boot :: (v3.3.2)
2024-08-13T16:37:53.250+02:00 INFO 149947 --- [ main] com.example.springboot.ExampleApp : Starting ExampleApp using Java 19.0.2 with PID 149947 (/home/dko/Desktop/spring-datasource-init/target/classes started by dko in /home/dko/Desktop/spring-datasource-init)
2024-08-13T16:37:53.251+02:00 INFO 149947 --- [ main] com.example.springboot.ExampleApp : No active profile set, falling back to 1 default profile: "default"
2024-08-13T16:37:53.474+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.488+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.488+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$PooledDataSourceConfiguration' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$PooledDataSourceConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.489+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'jdbcConnectionDetails' of type [org.springframework.boot.autoconfigure.jdbc.PropertiesJdbcConnectionDetails] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.496+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'dataSource' of type [com.zaxxer.hikari.HikariDataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.497+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration$JdbcTransactionManagerConfiguration' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration$JdbcTransactionManagerConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.499+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizationAutoConfiguration' of type [org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizationAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.501+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionExecutionListeners' of type [org.springframework.boot.autoconfigure.transaction.ExecutionListenersTransactionManagerCustomizer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.502+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.transaction-org.springframework.boot.autoconfigure.transaction.TransactionProperties' of type [org.springframework.boot.autoconfigure.transaction.TransactionProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.503+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'platformTransactionManagerCustomizers' of type [org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.505+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionManager' of type [org.springframework.jdbc.support.JdbcTransactionManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.505+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.batch-org.springframework.boot.autoconfigure.batch.BatchProperties' of type [org.springframework.boot.autoconfigure.batch.BatchProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-08-13T16:37:53.509+02:00 WARN 149947 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration$SpringBootBatchConfiguration' of type [org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration$SpringBootBatchConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [jobRegistryBeanPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead.
2024-08-13T16:37:53.527+02:00 INFO 149947 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2024-08-13T16:37:53.606+02:00 INFO 149947 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection conn0: url=jdbc:h2:mem:testdb user=SA
2024-08-13T16:37:53.607+02:00 INFO 149947 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2024-08-13T16:37:53.702+02:00 INFO 149947 --- [ main] com.example.springboot.ExampleApp : Started ExampleApp in 0.597 seconds (process running for 0.8)
2024-08-13T16:37:53.703+02:00 INFO 149947 --- [ main] o.s.b.a.b.JobLauncherApplicationRunner : Running default command line with: []
2024-08-13T16:37:53.706+02:00 INFO 149947 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2024-08-13T16:37:53.707+02:00 INFO 149947 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code 0
I can't reproduce this with your ExampleApp
. If I paste
@SpringBootApplication
public class ExampleApp {
public static void main(String[] args) {
SpringApplication.run(ExampleApp.class, args);
}
@Bean
public static BeanDefinitionRegistryPostProcessor jobRegistryBeanPostProcessorRemover() {
return registry -> registry.removeBeanDefinition("jobRegistryBeanPostProcessor");
}
}
into your ExampleApp.java
, I don't get any warning.
I can reproduce the warning when I do not add the BeanDefinitionRegistryPostProcessor
, which is consistent with the log line
Bean 'org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration$SpringBootBatchConfiguration' of type [org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration$SpringBootBatchConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [jobRegistryBeanPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead.
Just in case this isn't clear: If you want to get rid of the warnings but require your Job
beans to be registered with the JobRegistry
, you need to do both:
jobRegistryBeanPostProcessor
JobRegistrySmartInitializingSingleton
as a beanThis is strange, I double checked, cleared all cached. still the error remains.
But when I applie this:
* remove the bean definition of the `jobRegistryBeanPostProcessor` * add the `JobRegistrySmartInitializingSingleton` as a bean
then it works, the warnings are going. So is this the solution also in future? Or is this just a workaround until it gets fixed?
The answers to your questions can be found in the issue I already linked above: https://github.com/spring-projects/spring-batch/issues/4519#issuecomment-1931739682 Please have a look there.
@membersound
So is this the solution also in future? Or is this just a workaround until it gets fixed?
This is just a workaround. The issue has been addressed in #4547 and will be available in the upcoming 5.2 release. I am closing this issue as duplicate of #4519.
@hpoettker Thank you very much for the follow up on this. Really appreciated!
I migrated from spring2 to spring 3.3.2, and discovered that all my
spring-boot-stater-batch
projects throw endless warnings about aBeanPostProcessorChecker
.I could reproduce it even on an empty project that does not launch any job, see attached. As I'm sure warnings should in general not be discarded, this is probably to be fixed.
Is there a temporary fix to remove the logging?
The app is as simple as:
spring-datasource-init.zip
I know I could theoretically disable it with:
But is that best practice now?
Logs: