Spring Package - No bean named "configuration job"

I am using a custom MVC application that has SPring Batch dependencies as described in their documentation, and with this SO request Integrate SPring Batch Admin into an existing application .

The problem is that when the web application begins to map different URLs to the appropriate controller, the job setup phase explodes.

2012-06-04 10:17:54,966 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - <Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'> 2012-06-04 10:17:55,512 INFO [org.springframework.ui.freemarker.SpringTemplateLoader] - <SpringTemplateLoader for FreeMarker: using resource loader [WebApplicationContext for namespace 'admin-servlet': startup date [Mon Jun 04 10:17:54 EDT 2012]; parent: Root WebApplicationContext] and template loader path [/WEB-INF/web/]> 2012-06-04 10:17:55,512 INFO [org.springframework.ui.freemarker.SpringTemplateLoader] - <SpringTemplateLoader for FreeMarker: using resource loader [WebApplicationContext for namespace 'admin-servlet': startup date [Mon Jun 04 10:17:54 EDT 2012]; parent: Root WebApplicationContext] and template loader path [classpath:/org/springframework/batch/admin/web/]> 2012-06-04 10:17:55,512 INFO [org.springframework.batch.admin.web.freemarker.HippyFreeMarkerConfigurer] - <ClassTemplateLoader for Spring macros added to FreeMarker configuration> 2012-06-04 10:17:55,528 INFO [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping] - <Mapped URL path [/configuration] onto handler 'configurationHandler'> 2012-06-04 10:17:56,230 INFO [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping] - <Mapped URL path [/job-configuration] onto handler '/job-configuration'> ... 2012-06-04 10:17:56,230 ERROR [org.springframework.web.servlet.DispatcherServlet] - <Context initialization failed> org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/job-configuration.json': Cannot resolve reference to bean 'job-configurations' while setting bean property 'requestChannel'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'job-configurations' is defined 

Does anyone come across this? The application has dependencies on a simple spring-batch container that works completely isolated, and I expect it to pull any required beans job out of this artifact.

+4
source share
1 answer

I raised this question to some of my colleagues, and it seems that I consider a flaw in the spring batch admin design, which contradicts many typical spring design patterns.

The dependent spring batch admin bank “knows too much” about the context of the solution, including the data source. The problem is that in a decent web application, the data source can be dynamically determined at runtime based on a number or environment variables (environment, data center, application server) and is not as simple as Dave Sieer's approach (Mysql or HSQL). I read the posts in the spring forum , where it stands on this, however, it borders on insults on the questionnaire.

Everything is more complicated if your batch job uses several data sources (i.e. source and target databases). And it was not so simple as simply loading the data source into webapp, because all the beans associated with it were already associated with the Dave HSQL DS driver and the associated .sql files and initialization scripts.

And this led to the fact that I replaced almost every datasource bean associated with the party administration bank, including jobrepository (expected), jobExplorer, jobService and several others with a separate file in META-INF / spring / batch / override. Each file uses the spring 3.1 profile namespace to load the corresponding data source and introduces all the necessary beans.

+1
source

Source: https://habr.com/ru/post/1415974/


All Articles