Git Product home page Git Product logo

spring-boot-starter-batch-web's Introduction

Enterprise-ready production-ready batch applications powered by Spring Boot

Build Status Coverage Status Maven Central License

The project batch-web-spring-boot-starter is a Spring Boot starter for Spring Batch taking care of everything except writing the jobs.

See the documentation for detailed infos, examples and operational details.

Features include:

  • Starting up a web application and automatically deploying batch jobs to it (JavaConfig, XML or JSR-352).
  • Log file separation, one log file for each job execution.
  • An operations http endpoint for starting and stopping jobs, for retrieving the BatchStatus and the log file.
  • A monitoring http endpoint for retrieving detailed information on a job execution, for knowing all deployed jobs and all running job executions.

Take a look at the Getting Started page.

There are the following samples available:

batch-boot-simple: a very simple JavaConfig sample with an embedded database.

batch-boot-file-to-db: a job configured in xml using job parameters that reads from a file and writes to a database. This sample demonstrates the usage of an external database.

batch-boot-simple-jsr352: job samples in JSR-352 style.

spring-boot-starter-batch-web's People

Contributors

britter avatar danielbryantuk avatar denschu avatar dependabot[bot] avatar dickerpulli avatar jeff-walker avatar joshiste avatar mahartma avatar springjunky avatar tobiasflohre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-boot-starter-batch-web's Issues

@Inject @BatchProperty into Batchlet doesn't work

@Inject @BatchProperty into Batchlet doesn't work: at runtime the property values are null.

import javax.batch.api.AbstractBatchlet;
import javax.batch.api.BatchProperty;
import javax.inject.Inject;

public class BatchletWithPropertyInjection extends AbstractBatchlet {
    private static final Logger LOG = LoggerFactory.getLogger(BatchletWithPropertyInjection.class);

    @Inject
    @BatchProperty(name = "datakey")
    private String datakey;

    @Inject
    @BatchProperty(name = "datakey2")
    private String datakey2;

    @Override
    public String process() {
        LOG.info("datakey: " + datakey);
        LOG.info("datakey2: " + datakey2);

        return "OK";
    }
}

See this test in action: BatchletWithPropertyInjectionJsr352Test.java

quartz?

Nice! The only thing I miss is an integration with quartz ;)

Thanks,
Nick*

Asynch job run

Hi,
is it possible to start a job and make the rest api return just after the start instead of waiting for the execution to finish?
Nicola

Need a method to set serializer for JobRepository and JobExplorer

There's a bug described here with databases like postgres and sql server that requires setting the serializer on the JobRepositoryFactoryBean and JobExplorerFactoryBean to Jackson2ExecutionContextStringSerializer. I don't see a way to do this via TaskExecutorBatchConfigurer other than overriding much of it.

TransactionAwareMetricWriter reorders increments and resets

Givent the following scenario (single threaded):

<tx begin>
increment a
increment a
reset a
increment a
increment a
<tx end>

I would expect counter a to have the value 2.
But since TransactionAwareMetricWriter.afterCompletion() first executes all increments and afterwards the resets, the counter a has the value 0.

Get this warn twice while running any job, reproducable running simple batch example, should it be ignored?

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
2014-11-24 00:31:44.152 WARN 3412 --- [ main] o.s.c.a.ConfigurationClassEnhancer : @bean method ScopeConfiguration.jobScope 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 's
tatic' modifier to this method to avoid these container lifecycle issues; see @bean Javadoc for complete details

Upgrade to Spring Boot 2.4

After upgrading Spring Boot from 2.2.6 to 2.4.13, the JobMonitoringController /jobs returns an empty Set.

It looks like some change related to Spring Batch 4.3.x as when I override the managed version of Spring Batch Core from 4.3.4 to 4.2.8.RELEASE, the job names are returned as expected.

This is for Java Configured jobs. I have not tried XML.

I can see from the logs that the jobs are registered:
... c.b.c.AutomaticJobRegistrarConfiguration : Register jobs from class ...

And I can walkthrough the JobLoader registering each of the batches, but when /jobs is called the jobRegistry map is empty.

Versions:
Batch Web Spring Boot Starter 2.1.0.RELEASE
Spring Boot Version 2.4.13

It doesn't work on Java 8 at 1.3.2.RELEASE

Question

My project is based on Java 8 and I followed the guide from "Getting started" page. But, I received below error message.
Is that impossible to run spring-boot-starter-batch-web 1.3.2.RELEASE on Java 8?

P.S
I found an article that was suspected as a cause. Is it relevant?

so.. should I use java 7?

Output error message

***************************
APPLICATION FAILED TO START
***************************

Description:

Field metricRepository in de.codecentric.batch.configuration.BaseConfiguration required a bean of type 'org.springframework.boot.actuate.metrics.repository.MetricRepository' that could not be found.
	- Bean method 'actuatorMetricRepository' not loaded because @ConditionalOnJava (older than 1.8) found 1.8


Action:

Consider revisiting the conditions above or defining a bean of type 'org.springframework.boot.actuate.metrics.repository.MetricRepository' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:60183', transport: 'socket'

Process finished with exit code 1

Metrics when using partitioning

I expected themetric-counters to be in the slaves' stepExecutionContexts when using partitioning, but they are in the masters. Is that expected behaviour?

Did somebody explore if they behave correctly when doing restarts while using partitioning?

Batch table prefix not being passed to the JobExplorer during configuration

While using this great boot starter I discovered that during the configuration using the TaskExecutorBatchConfigurer when it creates the JobExplorer, the batch table prefix is not passed in to the factory, whereas it is when creating the JobRepository. This results in the JobRepository and JobExplorer looking in different places for the batch metadata tables.

To work round the problem I have cloned this configuration class and modified the initialise method to set the prefix just as it is done for the JobRepository.

 @PostConstruct
    public void initialize() throws Exception {
        if (dataSource == null) {
            log.warn("No datasource was provided...using a Map based JobRepository");

            if (this.transactionManager == null) {
                this.transactionManager = new ResourcelessTransactionManager();
            }

            MapJobRepositoryFactoryBean jobRepositoryFactory = new MapJobRepositoryFactoryBean(this.transactionManager);
            jobRepositoryFactory.afterPropertiesSet();
            this.jobRepository = jobRepositoryFactory.getObject();

            MapJobExplorerFactoryBean jobExplorerFactory = new MapJobExplorerFactoryBean(jobRepositoryFactory);
            jobExplorerFactory.afterPropertiesSet();
            this.jobExplorer = jobExplorerFactory.getObject();
        } else {
            this.jobRepository = createJobRepository();

            JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
            jobExplorerFactoryBean.setDataSource(this.dataSource);
            String tablePrefix = env.getProperty("batch.repository.tableprefix");
            if (tablePrefix != null) {
                jobExplorerFactoryBean.setTablePrefix(tablePrefix);
            }
            jobExplorerFactoryBean.afterPropertiesSet();
            this.jobExplorer = jobExplorerFactoryBean.getObject();
        }

        this.jobLauncher = createJobLauncher();
    }

springboot 2.2.1

hi,
i upgrade from springboot 2.1.13 to 2.2.1 and startup failed with :

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XXXX': Unsatisfied dependency expressed through field 'yyyy'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'XXXX' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

i remove batch-web-spring-boot-starter dependency and try again, server start and works.

will you maintain this library?

thanks.

Not compatible with Boot 1.3.0

Running with Spring Boot 1.3.0 throws the following:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration.setConfigurers(java.util.List); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'de.codecentric.batch.configuration.WebConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private de.codecentric.batch.configuration.BaseConfiguration de.codecentric.batch.configuration.WebConfig.baseConfig; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'de.codecentric.batch.configuration.BaseConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.actuate.metrics.repository.MetricRepository de.codecentric.batch.configuration.BaseConfiguration.metricRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.actuate.metrics.repository.MetricRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at blah.Application.main(Application.java:13) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration.setConfigurers(java.util.List); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'de.codecentric.batch.configuration.WebConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private de.codecentric.batch.configuration.BaseConfiguration de.codecentric.batch.configuration.WebConfig.baseConfig; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'de.codecentric.batch.configuration.BaseConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.actuate.metrics.repository.MetricRepository de.codecentric.batch.configuration.BaseConfiguration.metricRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.actuate.metrics.repository.MetricRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:661) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    ... 22 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'de.codecentric.batch.configuration.WebConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private de.codecentric.batch.configuration.BaseConfiguration de.codecentric.batch.configuration.WebConfig.baseConfig; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'de.codecentric.batch.configuration.BaseConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.actuate.metrics.repository.MetricRepository de.codecentric.batch.configuration.BaseConfiguration.metricRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.actuate.metrics.repository.MetricRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1068) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:618) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    ... 24 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private de.codecentric.batch.configuration.BaseConfiguration de.codecentric.batch.configuration.WebConfig.baseConfig; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'de.codecentric.batch.configuration.BaseConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.actuate.metrics.repository.MetricRepository de.codecentric.batch.configuration.BaseConfiguration.metricRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.actuate.metrics.repository.MetricRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    ... 35 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'de.codecentric.batch.configuration.BaseConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.actuate.metrics.repository.MetricRepository de.codecentric.batch.configuration.BaseConfiguration.metricRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.actuate.metrics.repository.MetricRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    ... 37 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.actuate.metrics.repository.MetricRepository de.codecentric.batch.configuration.BaseConfiguration.metricRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.actuate.metrics.repository.MetricRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    ... 48 common frames omitted
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.actuate.metrics.repository.MetricRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    ... 50 common frames omitted

RepositoryItemWriter not inserting on execution

Hi, when using this library every time I execute a job using a RepositoryItemWriter it does not generate the inserts in database.
I'm using jpa, hibernate with oracle. On enabling "spring.jpa.show-sql=true" property I can see the are no insert being executed by hibernate.
After just removing the spring-boot-starter-batch-web 1.4.0.RELEASE dependency from my pom, and re-executing the Job, the inserts are there.
Is this any configuration issue? How can I fix it?

Spring boot 3

hi,

do you plan to upgrade to version 3 of springboot?

Thanks for support.

Jackson 1.0 is required but Jackson2.0 is maintainted in dependecies

Caused by: java.lang.NoClassDefFoundError: org/codehaus/jackson/map/MappingJsonFactory
at org.springframework.batch.item.file.mapping.JsonLineMapper.(JsonLineMapper.java:44)

import org.codehaus.jackson.map.MappingJsonFactory;
public class JsonLineMapper implements LineMapper<Map<String, Object>> {
private MappingJsonFactory factory = new MappingJsonFactory();

MappingJsonFactory in Jackson 2.x live in com.fasterxml.jackson package; but as per exception, ones in org.codehaus.jackson are needed.

Springfox Swagger UI doesn't see operations controller

I'm trying to get Springfox going to show the different controller endpoints. The endpoints show up properly in the swagger2 docs at /v2/api-docs. The /swagger-ui.html web frontend only shows the monitoring controller. I've turned on debugging output from springfox and don't see any errors or any indicating an issue. Do you have any idea why this wouldn't be working?

Basic setup and operation for springfox can be found here http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

Make the JobParametersConverter used in the JobExecutionController configurable

Hello,

we have some special requirenments regarding the JobParameters in our project. It would help us immensively if it would be possible to configure the JobParametersConverter that is used in the JobParametersController JobOperationsController. This way we would be able to replace the currently used DefaultJobParametersConverter with a special JobParametersConverter implementation.

Is there any chance that you make this possible? :)

-- Edit: To be more precise in explaining our problem and about what we are asking.

We are currently using your library to be able to execute different jobs through REST. This is working quite nice. The only drawback that currently exists is, that the JobOperationsController declares, creates and uses a JobParametersConverter instance on its own.

private JobParametersConverter jobParametersConverter = new DefaultJobParametersConverter();

The member is declared as private, it is not annotated as @Autowired, and the ctor does not allow to assign another instance. Therefore we are not able to explain the JobOperationsController to use another instance of JobParametersConverter as the one that is created while initialising the member (at least we don't see a possibility). An instance of JobParametersConverter that is part of the application-context would not help because it would not be injected into the instance of JobOperationsController.

We have some special cases we would like to do with the job-parameters that are send with the request. Therefore it would be really helpful if it would be possible to explain the JobOperationsController which instance of JobParametersConverter to use. :)

@Inject JobContext fails: a JobExecution is required

Execution of following Batchlet fails:

import javax.batch.api.AbstractBatchlet;
import javax.batch.runtime.context.JobContext;
import javax.inject.Inject;

public class BatchletWithJobContextInjection extends AbstractBatchlet {
    @Inject
    private JobContext jobContext;

    @Override
    public String process() {
        return "OK";
    }
}

Stacktrace:

javax.batch.operations.JobStartException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchletWithJobContextInjection': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.batch.runtime.context.JobContext de.codecentric.batch.simplejsr.item.BatchletWithJobContextInjection.jobContext; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'jsr_jobContext': org.springframework.beans.factory.FactoryBeanNotInitializedException: A JobExecution is required

	at org.springframework.batch.core.jsr.launch.JsrJobOperator.start(JsrJobOperator.java:635)
	at org.springframework.batch.test.JsrTestUtils.runJob(JsrTestUtils.java:58)
	at de.codecentric.batch.simplejsr.BatchletWithJobContextInjectionJsr352Test.testTraditionalJsr352(BatchletWithJobContextInjectionJsr352Test.java:12)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchletWithJobContextInjection': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.batch.runtime.context.JobContext de.codecentric.batch.simplejsr.item.BatchletWithJobContextInjection.jobContext; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'jsr_jobContext': org.springframework.beans.factory.FactoryBeanNotInitializedException: A JobExecution is required
	at org.springframework.batch.core.jsr.configuration.support.SpringAutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(SpringAutowiredAnnotationBeanPostProcessor.java:272)
	at org.springframework.batch.core.jsr.configuration.support.JsrAutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(JsrAutowiredAnnotationBeanPostProcessor.java:30)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
	at org.springframework.batch.core.jsr.launch.JsrJobOperator.start(JsrJobOperator.java:633)
	... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.batch.runtime.context.JobContext de.codecentric.batch.simplejsr.item.BatchletWithJobContextInjection.jobContext; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'jsr_jobContext': org.springframework.beans.factory.FactoryBeanNotInitializedException: A JobExecution is required
	at org.springframework.batch.core.jsr.configuration.support.SpringAutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(SpringAutowiredAnnotationBeanPostProcessor.java:501)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)
	at org.springframework.batch.core.jsr.configuration.support.SpringAutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(SpringAutowiredAnnotationBeanPostProcessor.java:269)
	... 36 more
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'jsr_jobContext': org.springframework.beans.factory.FactoryBeanNotInitializedException: A JobExecution is required
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:135)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1645)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1175)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:327)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)
	at org.springframework.batch.core.jsr.configuration.support.SpringAutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(SpringAutowiredAnnotationBeanPostProcessor.java:473)
	... 38 more

See error in action: BatchletWithJobContextInjectionJsr352Test.java

The following combinations fail with the same error:

  • @Inject org.springframework.batch.core.scope.context.JobContext
  • @Autowired org.springframework.batch.core.scope.context.JobContext
  • @Inject javax.batch.runtime.context.JobContext
  • @Autowired javax.batch.runtime.context.JobContext

Also injection into javax.batch.api.partition.PartitionMapper fails with the same error.

App fails to start when Dropwizard Metrics in pom

Hi,
I am trying to add metrics using Dropwizard metrics library to my application. However, the application fails with errors below:

Field metricReader in de.codecentric.batch.configuration.MetricsConfiguration required a bean of type 'org.springframework.boot.actuate.metrics.reader.MetricReader' that could not be found.
	- Bean method 'actuatorMetricReader' not loaded because @ConditionalOnMissingBean (types: org.springframework.boot.actuate.metrics.GaugeService; SearchStrategy: all) found bean 'dropwizardMetricServices'
	- Bean method 'actuatorMetricRepository' not loaded because @ConditionalOnJava (older than 1.8) found 1.8

Are there any workarounds?

JOB_LOG_PATH is not being honoured by the logback-batch-base.xml

Hi have a logback-spring.xml in my application with contents

<?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="logback-batch-base.xml" /> <logger name="org.springframework" level="INFO"/> <jmxConfigurator/> </configuration>

In my application.yml file I am defining

batch: joblog: path: /var/log/batch

When I debug and breakpoint in JobLoggingApplicationListener I can see it getting the value from the Spring environment and setting the system property. However when a job runs, logback ignores it and goes with the default of /tmp. It also appears to ignore the standard Spring Boot LOG_PATH setting as well.

This split logging functionality is great but at the moment, I can't hand it over to the operations team as they will want to specify where the log files are created.

optional/omitted jobParameters are reloaded from previous jobs

When you are using optional job parameters or in the case a mandatory job parameter is simply not provided the missing/omitted parameter gets loaded from the job repository from a former successful job.

In case of restarting a failed job this should be ok, but when dealing with optional parameters or if some mandatory parameters are not provided this can cause some wired results.

Right now I get a list of every parameter used for this job since the 1st run plus the ones I provided for the actual run.

Is this behaviour intended? Is there a way I can assure that only the provided jobParameters are used, like some flag to supress the reload from repository?

Best regards
Peter

BatchMetricsImpl uses MappedDiagnosticContext to determine StepName

The BatchMetricsImpl fetches the StepExecutionIdentifier from the MappedDiagnosticContext.
This seems a bit awkward since MDC is only for logging purposes.

Better use StepSynchronizationManager.getContext() to obtain step-identifier?

It also causes problems when using partiotioning since LoggingListener.beforeStep isn't called for the slave-step and the counternames are prefixed whit the master-step-id

batch.repository.isolationlevelforcreate=ISOLATION_READ_COMMITTED not setup in jobRepository using Junit

THe following issue with oracle is handlled by setting isolationforcreate=ISOLATION_READ_COMMITTED. It works fine when I run Normal batch through webservice call.Somehow when I run batch through Junit, this property is not getting set.
P.S. I have made sure application.properties is getting loaded when this Junit starts as I am reading other parameters from this files too.
StacckTrace :
org.springframework.dao.CannotSerializeTransactionException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; ORA-08177: can't serialize access for this transaction
; nested exception is java.sql.SQLException: ORA-08177: can't serialize access for this transaction

Can't make runIdIncrementor work

When I execute jobs with the API the the JobOperationsController does not seem to pick up the previous job execution correctly. It uses the following code:

            JobExecution lastJobExecution = jobRepository.getLastJobExecution(job.getName(), jobParameters);

It always seems to return null.

Looking at the CommandLineJobRunner code, I can see that it uses the JobExplorer to find the last instance that was executed. Perhaps it needs to be done that way? Do you have another way to make this work or is it a bug?

Rerunning jobs with identical parameters via REST API results in reuse of existing run.id

I'm the same implementation of RunIdIncrementer mentioned here.

When starting the batch application the first time and POSTing a request to /batch/jobs/my-job everything works fine. When resending the same exact request a second time I see that the parameterspassed to the RunIdIncrementer are empty causing run.id to be set to 1. This results in the following error:

Step already complete or not restartable, so no action to execute

Am I doing something wrong?

WebMvcConfigurer.addResourceHandlers(registry) StackOverFlowException

I want to add a function that can access static file by URL.

And I know in spring boot 2 you can do this with 2 way .

extends WebMvcConfigurationSupport or implements implements WebMvcConfigurer
override the addResourceHandlers() method.

But when I implements WebMvcConfigurer,I meet a stackoverflowException.
It is confused to me.

Here's my code. Both of them are very simple. But the extend's code is running good.Another is not.

@configuration
public class WebFileConfiguration implements WebMvcConfigurer {

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {

    //addResourceHandler = url请求的路径
    registry.addResourceHandler("/txt/**")
    //addResourceLocations=图片存放在服务器的真实路径
            .addResourceLocations("file:D://");
    addResourceHandlers(registry);
}

}

@configuration
public class WebFileConfiguration extends WebMvcConfigurationSupport {

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {

    //addResourceHandler = url请求的路径
    registry.addResourceHandler("/txt/**")
    //addResourceLocations=图片存放在服务器的真实路径
            .addResourceLocations("file:D://");
    super.addResourceHandlers(registry);
}

}

There is my error log.
I thought maybe my D disk is too many file that too long for ArrayList's size.But I change the resouceLocation it's same error.

My D: disk only used less than 8 gb , about 15000 files ,and less than 3500 folders.

2018-10-29 14:38:26.517 INFO 31056 --- [ restartedMain] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-10-29 14:38:26.524 ERROR 31056 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resourceHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.StackOverflowError
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at com.freego.report.crm.ReportCrmApplication.main(ReportCrmApplication.java:36) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.4.RELEASE.jar:2.0.4.RELEASE]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.StackOverflowError
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
... 23 common frames omitted
Caused by: java.lang.StackOverflowError: null
at java.util.ArrayList.addAll(ArrayList.java:581) ~[na:1.8.0_181]
at org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration.addResourceLocations(ResourceHandlerRegistration.java:83) ~[spring-webmvc-5.0.8.RELEASE.jar:5.0.8.RELEASE]

Create new method to return executions by job name

@RequestMapping(value = "/jobs/executions/{jobName}", method = RequestMethod.GET)
public Set<Long> findLastExecutions(@PathVariable String jobName) throws NoSuchJobExecutionException {
	List<JobInstance> jobInstances = jobExplorer.getJobInstances(jobName, 0, 10);
	
	Set<JobExecution> jobExecutions = new HashSet<JobExecution>();
	for(JobInstance jobInstance : jobInstances){
		jobExecutions.addAll(jobExplorer.getJobExecutions(jobInstance));
	}
	
	if (jobExecutions.isEmpty()) {
		throw new NoSuchJobExecutionException("There is not any JobExecution for the job '" + jobName + "'.");
	}
	
	return runningExecutionTracker.getAllRunningExecutionIds();
}

TransactionAwareMetricWriter doesn't play along with AsyncItemProcessor

When the TransactionAwareMetricWriter.increment() is called from an asynchronous execution (via AsyncItemProcessor) TransactionSynchronizationManager.isSynchronizationActive() returns false and the increment is passed directly to the delegate instead of being buffered in the MetricContainer. So the increments aren't transactional.

The TransactionSynchronizationManager uses an ThreadLocal to store the synchronizations therefore the threads started for the asynchronous execution aren't aware of the transaction.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.