Spring Batch Multiple Processors


swassbac
26/4/2016 6:52 am
HOME ยป Web Development

Can we have multiple processors and single writer to write data in two different tables in spring batch


Related to : Spring Batch Multiple Processors
Spring Batch Multiple Processors
26/4/2016 6:52 am Web Development

Can we have multiple processors and single writer to write data in two different tables in spring batch


Spring, spring batch, hibernate, and JUnit and initialization for multiple integration tests
30/12/2014 7:30 pm Web Development

I have some test classes that are making use of spring-batch, and hibernate. My test contexts establish an h2 in memory database, initialized the hibernate session factory, which creates most of the db schema, and also executes some specific SQL scripts to set up the database schema objects required for spring batch (non-orm). Hibernate does a very nice job only doing what is necessary, however the spring-batch initialization scripts are not as smart.

My test configuration uses an h2 embedded database, so I can safely initialize everything once, however, I need to convey to spring to only initialize the rest integration infrastructure (e.g hbm session factory, and spring-batch schemas) once for the whole collection of tests being run.

My unit tests all run individually, but tests 2 through N fail when testing the whole package as they are performing the same db schema initialization repeatedly, and dying on (db) object already exists errors.

I am looking to initialize an application context for the whole collection of integration tests, and then delegate configuration of the details for a specific test to the MyTest-context, yet still initialize the main application context when running a single integration test.

I have a common set of spring configuration files which are imported into test context to initialize the infrastructure needed to tests application services. The problem comes from running all tests in a package, etc. The test system calls the same initialization multiple times.

I am hoping this is a pretty common problem and that I overlooked a detail in spring or JUnit's documentation.


Error Integrating Spring batch with spring-batch-admin-manager on Spring-boot
31/12/2014 6:00 pm Web Development

I am trying to integrate spring-batch-admin-manager with spring-boot-starter-batch together using spring-boot embedded tomcat configuration.

However I am have this error trace which I cant nail down:

org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'batchConfiguration': Injection of
autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire field: private
org.springframework.batch.core.configuration.annotation.StepBuilderFactory
com.mycompany.notification.processor.service.batch.configuration.BatchConfiguration.steps;
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'stepBuilders' defined in class path resource
[org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.springframework.batch.core.configuration.annotation.StepBuilderFactory]:
Factory method 'stepBuilders' threw exception; nested exception is
java.lang.ClassCastException:
org.springframework.batch.core.repository.support.JobRepositoryFactoryBean$$EnhancerBySpringCGLIB$$6da887a9
cannot be cast to
org.springframework.batch.core.repository.JobRepository
    at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
    at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
    at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
    at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
    at
org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
    at
org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
    at
org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
    at
com.mycompany.notification.processor.service.main.Application.main(Application.java:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: org.springframework.beans.factory.BeanCreationException:
Could not autowire field: private
org.springframework.batch.core.configuration.annotation.StepBuilderFactory
com.mycompany.notification.processor.service.batch.configuration.BatchConfiguration.steps;
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'stepBuilders' defined in class path resource
[org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.springframework.batch.core.configuration.annotation.StepBuilderFactory]:
Factory method 'stepBuilders' threw exception; nested exception is
java.lang.ClassCastException:
org.springframework.batch.core.repository.support.JobRepositoryFactoryBean$$EnhancerBySpringCGLIB$$6da887a9
cannot be cast to
org.springframework.batch.core.repository.JobRepository
    at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:558)
    at
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    ... 21 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'stepBuilders' defined in class path
resource
[org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.springframework.batch.core.configuration.annotation.StepBuilderFactory]:
Factory method 'stepBuilders' threw exception; nested exception is
java.lang.ClassCastException:
org.springframework.batch.core.repository.support.JobRepositoryFactoryBean$$EnhancerBySpringCGLIB$$6da887a9
cannot be cast to
org.springframework.batch.core.repository.JobRepository
    at
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:602)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1111)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1006)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1127)
    at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1051)
    at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:949)
    at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:530)
    ... 23 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException:
Failed to instantiate
[org.springframework.batch.core.configuration.annotation.StepBuilderFactory]:
Factory method 'stepBuilders' threw exception; nested exception is
java.lang.ClassCastException:
org.springframework.batch.core.repository.support.JobRepositoryFactoryBean$$EnhancerBySpringCGLIB$$6da887a9
cannot be cast to
org.springframework.batch.core.repository.JobRepository
    at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:591)
    ... 35 common frames omitted
Caused by: java.lang.ClassCastException:
org.springframework.batch.core.repository.support.JobRepositoryFactoryBean$$EnhancerBySpringCGLIB$$6da887a9
cannot be cast to
org.springframework.batch.core.repository.JobRepository
    at
org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$$EnhancerBySpringCGLIB$$607a70b7.jobRepository(<generated>)
    at
org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.stepBuilders(AbstractBatchConfiguration.java:63)
    at
org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$$EnhancerBySpringCGLIB$$607a70b7.CGLIB$stepBuilders$7(<generated>)
    at
org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$$EnhancerBySpringCGLIB$$607a70b7$$FastClassBySpringCGLIB$$ac8c0a6a.invoke(<generated>)
    at
org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at
org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
    at
org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$$EnhancerBySpringCGLIB$$607a70b7.stepBuilders(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 36 common frames omitted

This is my gradle build file:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://repo.spring.io/milestone/' }
    }
    dependencies {
       
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.0.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'

war {
    baseName = 'notification-processor-service'
    version = '1.0.0-SNAPSHOT'
}
jar {
    baseName = 'notification-processor-service'
    version = '1.0.0-SNAPSHOT'
}

ext {
    springIntegrationVersion = '4.1.1.RELEASE'
    springIntegrationKafkaVersion = '1.0.0.M2'
}

repositories {
    mavenCentral()
    maven {
        url 'https://repository.apache.org/content/groups/public'
    }
    maven { url 'http://repo.spring.io/milestone/' }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
   
compile("org.springframework.boot:spring-boot-starter-batch:1.2.0.RELEASE")
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("javax.inject:javax.inject:1")
   
compile('org.springframework.batch:spring-batch-admin-manager:1.3.0.RELEASE')
{
        exclude module: 'slf4j-log4j12'
    }
    //SI
    //
compile("org.springframework.integration:spring-integration-core:$springIntegrationVersion")

    /* //kafka
    
compile("org.springframework.integration:spring-integration-kafka:$springIntegrationKafkaVersion")
{
         exclude module: 'log4j'
         exclude module: 'jms'
         exclude module: 'jmxtools'
         exclude module: 'jmxri'
     }*/
    testCompile("org.springframework.boot:spring-boot-starter-test")

}

task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}

I added those configurations as shown in this github example:

https://github.com/codecentric/spring-batch-admin-spring-boot

@Configuration
@ImportResource("classpath:/org/springframework/batch/admin/web/resources/servlet-config.xml")
public class ServletConfiguration {
}

 */
@Configuration
@ImportResource("classpath:/org/springframework/batch/admin/web/resources/webapp-config.xml")
public class WebappConfiguration {

}

this is my batchConfiguration class:

@EnableBatchProcessing
@Configuration
public class BatchConfiguration {

    private static final Logger logger =
LoggerFactory.getLogger(BatchConfiguration.class);

    @Inject
    WriteToKafkaTasklet writeToKafkaTasklet;

    @Autowired
    private StepBuilderFactory steps;


    @Autowired
    private JobBuilderFactory jobs;

    @Autowired
    private StepBuilderFactory stepBuilderFactory;


}

What am I missing?


Dynamically processing multiple batch files and generating corresponding output files with Spring Batch
Web Development

I've recently started learning Spring Batch in order to make use of some of its more advanced features like asynchronous batch processing, job stopping, and scheduling to replace some existing batch processing functionality, and implement new batch processing functionality. Right now, I'm trying to figure out how to dynamically process multiple batch files and generate a "receipt" file for each input file, and I'm confused by some of the design decisions of the Spring Batch architects. It seems like in order to process a simple flat CSV file and generate the output, I'm going to have to manually hack the beans in my ApplicationContext and manually set their "resource" properties at runt



HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .