Announcement Announcement Module
Collapse
No announcement yet.
SpringBatch 2.1.9 with Spring 3.1.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SpringBatch 2.1.9 with Spring 3.1.2

    Hello,

    Can I use SpringBatch 2.1.9 with Spring 3.2.2?

    Upgrade Guide(Covers upgrading from Spring 2.5 to 3.0)
    shows that Spring Batch 2.1 has a Spring 3.0 Compatibility.
    http://static.springsource.org/sprin...l/ch02s03.html

    but I could not find Spring 3.2 Compatibility.

    Thanks for any help.
    Last edited by mrst; Apr 17th, 2013, 01:06 AM.

  • #2
    I too am trying to upgrade Spring to 3.2.2 with Spring Batch 2.1.9; but I am unsuccessful so far. There seems to be an issue with using StaxEventItemWriter/Jibx/Woodstox. I am getting a NullPointerException when Woodstox is trying to:

    char[] buf = mOutputBuffer;
    buf[ptr++] = '<';

    The mOutputBuffer must not be getting created. Trying to dig through and find out where this is breaking.



    java.lang.NullPointerException
    at com.ctc.wstx.sw.BufferingXmlWriter.writeStartTagSt art(BufferingXmlWriter.java:725)
    at com.ctc.wstx.sw.BaseNsStreamWriter.doWriteStartTag (BaseNsStreamWriter.java:618)
    at com.ctc.wstx.sw.SimpleNsStreamWriter.writeStartOrE mpty(SimpleNsStreamWriter.java:265)
    at com.ctc.wstx.sw.BaseNsStreamWriter.writeStartEleme nt(BaseNsStreamWriter.java:317)
    at org.codehaus.stax2.ri.Stax2EventWriterImpl.add(Sta x2EventWriterImpl.java:97)
    at org.springframework.batch.item.xml.stax.NoStartEnd DocumentStreamWriter.add(NoStartEndDocumentStreamW riter.java:38)
    at org.springframework.util.xml.XMLEventStreamWriter. writeStartElement(XMLEventStreamWriter.java:195)
    at org.springframework.util.xml.XMLEventStreamWriter. writeStartElement(XMLEventStreamWriter.java:92)
    at org.jibx.runtime.impl.StAXWriter.startTagOpen(StAX Writer.java:151)
    at org.jibx.runtime.impl.MarshallingContext.startTagA ttributes(MarshallingContext.java:541)
    at .....JiBX_OrgNodeExportOrgNode_access.marshal()
    at .....ExportOrgNode.marshal(ExportOrgNode.java)
    at org.jibx.runtime.impl.MarshallingContext.marshalRo ot(MarshallingContext.java:1021)
    at org.jibx.runtime.impl.MarshallingContext.marshalDo cument(MarshallingContext.java:1041)
    at org.springframework.oxm.jibx.JibxMarshaller.marsha lXmlStreamWriter(JibxMarshaller.java:289)
    at org.springframework.oxm.jibx.JibxMarshaller.marsha lXmlEventWriter(JibxMarshaller.java:342)
    at org.springframework.oxm.support.AbstractMarshaller .marshalStaxResult(AbstractMarshaller.java:229)
    at org.springframework.oxm.support.AbstractMarshaller .marshal(AbstractMarshaller.java:96)
    at org.springframework.batch.item.xml.StaxEventItemWr iter.write(StaxEventItemWriter.java:641)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:183)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :150)
    at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:132)
    at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:120)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at com.sun.proxy.$Proxy50.write(Unknown Source)
    at org.springframework.batch.core.step.item.SimpleChu nkProcessor.writeItems(SimpleChunkProcessor.java:1 74)
    at org.springframework.batch.core.step.item.SimpleChu nkProcessor.doWrite(SimpleChunkProcessor.java:150)
    at org.springframework.batch.core.step.item.SimpleChu nkProcessor.write(SimpleChunkProcessor.java:272)
    at org.springframework.batch.core.step.item.SimpleChu nkProcessor.process(SimpleChunkProcessor.java:197)
    at org.springframework.batch.core.step.item.ChunkOrie ntedTasklet.execute(ChunkOrientedTasklet.java:74)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$ChunkTransactionCallback.doInTransaction(Tas kletStep.java:386)
    at org.springframework.transaction.support.Transactio nTemplate.execute(TransactionTemplate.java:131)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$2.doInChunkContext(TaskletStep.java:264)
    at org.springframework.batch.core.scope.context.StepC ontextRepeatCallback.doInIteration(StepContextRepe atCallback.java:76)
    at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:367)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:214)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
    at org.springframework.batch.core.step.tasklet.Taskle tStep.doExecute(TaskletStep.java:250)
    at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:195)
    at org.springframework.batch.core.job.SimpleStepHandl er.handleStep(SimpleStepHandler.java:135)
    at org.springframework.batch.core.job.flow.JobFlowExe cutor.executeStep(JobFlowExecutor.java:61)
    at org.springframework.batch.core.job.flow.support.st ate.StepState.handle(StepState.java:60)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.resume(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.start(SimpleFlow.java:124)
    at org.springframework.batch.core.job.flow.FlowJob.do Execute(FlowJob.java:135)
    at org.springframework.batch.core.job.AbstractJob.exe cute(AbstractJob.java:293)
    at .....ClassPathXmlApplicationContextJobFactory$Cont extClosingJob.execute(ClassPathXmlApplicationConte xtJobFactory.java:76)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:120)
    at org.springframework.core.task.SyncTaskExecutor.exe cute(SyncTaskExecutor.java:49)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:114)
    at .....JobLauncherDetails.executeInternal(JobLaunche rDetails.java:93)
    at org.springframework.scheduling.quartz.QuartzJobBea n.execute(QuartzJobBean.java:113)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:2 02)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run (SimpleThreadPool.java:525)

    Comment


    • #3
      Forgot to mention, this works fine with Spring 3.1.1

      Comment


      • #4
        Hi, one question

        I'm using

        Spring 3.1
        Spring Batch 2.1.8
        Hibernate 3.6.9 Final



        I have one project with 2 database but I need help for configuration with 2 database because I don't find documentation of this.'

        How transactionality Spring Batch handles when you have two database?
        Because I'm having trouble with the transaction and rollback when rollback of the two database.
        Any help please?


        DataSource.xml

        .
        .
        .

        <bean id="dataSourceA" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName">
        <value>${ipdatabase.connection.driver}</value>
        </property>
        <property name="url">
        <value>${ipdatabase.connection.url}</value>
        </property>
        <property name="username">
        <value>${ipdatabase.connection.username}</value>
        </property>
        <property name="password">
        <value>${ipdatabase.connection.password}</value>
        </property>
        </bean>

        <bean id="dataSourceB" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName">
        <value>${extdatabase.connection.driver}</value>
        </property>
        <property name="url">
        <value>${extdatabase.connection.url}</value>
        </property>
        <property name="username">
        <value>${extdatabase.connection.username}</value>
        </property>
        <property name="password">
        <value>${extdatabase.connection.password}</value>
        </property>
        </bean>


        Hibernate3.xml

        .
        .
        .

        <!-- SessionFactory Configuration -->
        <bean id="abstractSessionFactoryA" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean" abstract="true">
        <property name="dataSource" ref="dataSourceA" />
        <property name="hibernateProperties">
        <props>
        <prop key="hibernate.dialect">
        ${iphibernate.dialect}
        </prop>
        <prop key="hibernate.show_sql">
        ${iphibernate.show_sql}
        </prop>
        <prop key="hibernate.generate_statistics">
        ${iphibernate.generate_statistics}
        </prop>

        <!-- ehCache configuration -->
        <prop key="hibernate.cache.use_second_level_cache">
        ${iphibernate.cache.use_second_level_cache}
        </prop>
        <prop key="hibernate.cache.use_query_cache">
        ${iphibernate.cache.use_query_cache}
        </prop>
        <prop key="hibernate.cache.region.factory_class">
        ${iphibernate.cache.region.factory_class}
        </prop>
        <prop key="net.sf.ehcache.configurationResourceName">
        ${iphibernate.configurationResourceName}
        </prop>
        </props>
        </property>
        </bean>

        <bean id="sessionFactoryA" parent="abstractSessionFactoryA">
        <property name="configLocations">
        <list>
        <value>classpath:com/production/module/massive/configuration/hbm/massive-core-hbm.cfg.xml</value>
        <value>classpath:com/production/module/massive/configuration/hbm/massive-ecommerceint-hbm.cfg.xml</value>
        </list>
        </property>
        </bean>


        <bean id="abstractSessionFactoryB" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean" abstract="true">
        <property name="dataSource" ref="dataSourceB" />
        <property name="hibernateProperties">
        <props>
        <prop key="hibernate.dialect">
        ${iphibernate.dialect}
        </prop>
        <prop key="hibernate.show_sql">
        ${iphibernate.show_sql}
        </prop>
        <prop key="hibernate.generate_statistics">
        ${iphibernate.generate_statistics}
        </prop>

        <!-- ehCache configuration -->
        <prop key="hibernate.cache.use_second_level_cache">
        ${exthibernate.cache.use_second_level_cache}
        </prop>
        <prop key="hibernate.cache.use_query_cache">
        ${exthibernate.cache.use_query_cache}
        </prop>
        <prop key="hibernate.cache.region.factory_class">
        ${exthibernate.cache.region.factory_class}
        </prop>
        <prop key="net.sf.ehcache.configurationResourceName">
        ${exthibernate.configurationResourceName}
        </prop>
        </props>
        </property>
        </bean>

        <bean id="sessionFactoryB" parent="abstractSessionFactoryB">
        <property name="configLocations">
        <list>
        <value>classpath:com/production/module/massive/configuration/hbm/massive-hbm.cfg.xml</value>
        </list>
        </property>
        </bean>


        Service.xml
        (I have 2 transaction Manager. Is ok??)

        .
        .
        .

        <bean id="transactionManagerA" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
        <property name="sessionFactory" ref="sessionFactoryA" />
        </bean>

        <bean id="transactionManagerB" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
        <property name="sessionFactory" ref="sessionFactoryB" />
        </bean>

        <tx:advice id="txAdviceA" transaction-manager="transactionManagerA">
        <tx:attributes>
        <tx:method name="save*" propagation="REQUIRED" rollback-for="Exception" />
        <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception" />
        <tx:method name="delete*" propagation="REQUIRED" />
        <tx:method name="get*" propagation="REQUIRED" read-only="true" />
        <tx:method name="find*" propagation="REQUIRED" read-only="true" />
        <tx:method name="process*" propagation="REQUIRED" rollback-for="Exception" />
        </tx:attributes>
        </tx:advice>

        <tx:advice id="txAdviceB" transaction-manager="transactionManagerB">

        <tx:attributes>
        <tx:method name="save*" propagation="REQUIRED" rollback-for="Exception" />
        <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception" />
        <tx:method name="process*" propagation="REQUIRED" rollback-for="Exception" />
        <tx:method name="delete*" propagation="REQUIRED" />
        <tx:method name="get*" propagation="REQUIRED" read-only="true" />
        <tx:method name="find*" propagation="REQUIRED" read-only="true" />
        </tx:attributes>
        </tx:advice>

        <aop:config>
        <aopointcut id="serviceTxConfiguration" expression="execution(* com.production.module.batch.facade..*.*(..))" />
        <aop:advisor advice-ref="txAdviceA" pointcut-ref="serviceTxConfiguration" />
        <aop:advisor advice-ref="txAdviceB" pointcut-ref="serviceTxConfiguration" />
        </aop:config>


        Spring-batch.xml
        (This well set up job-repository with just a transaction-manager, how it behaves with two transactions? . How it should be ?)


        <?xml version="1.0" encoding="UTF-8"?>
        <beans:beans xmlns="http://www.springframework.org/schema/batch"
        xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schem...-beans-3.0.xsd
        http://www.springframework.org/schema/batch
        http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">

        <job-repository id="jobRepository" data-source="dataSourceB" transaction-manager="transactionManagerB" isolation-level-for-create="REPEATABLE_READ" />

        <beans:bean id="jobLauncher" class="org.springframework.batch.core.launch.suppo rt.SimpleJobLauncher">
        <beansroperty name="jobRepository" ref="jobRepository" />
        </beans:bean>
        </beans:beans>


        Because I'm having trouble with the transaction and rollback when rollback of the two database.

        Comment


        • #5
          Can we break this out into new threads please? Three people have posted in this thread, all with three different unrelated issues.

          To answer the first issue (@mrst), Spring Batch 2.1.9 should work fine with 3.2.2.RELEASE. The only issue I'm aware of is that the tests won't compile (due to an API change in Spring Core). I would double check your dependencies. Was something else upgraded that you didn't expect (since the actual issue is buried in another library's code)?

          Also, I'd encourage you to take a look at Spring Batch 2.2.0.RC1 if you are interested in going through the upgrade process...might as well hit two birds with one stone

          Comment


          • #6
            I answer in place of "mrst".
            I work on the same team with "mrst".

            Thank you very much for answer(@mminella).

            As a result of actually running with the Spring Batch 2.1.9 and Spring 3.2.2,
            it worked as expected.


            >Also, I'd encourage you to take a look at Spring Batch 2.2.0.RC1 if you are interested in going through the upgrade process...might as well hit two birds with one stone.

            Thank you for your valuable information.
            I'll take a look at the Spring Batch 2.2.0.RC1.

            Again, thank you very much.

            Comment

            Working...
            X