Announcement Announcement Module
Collapse
No announcement yet.
Batch version compatible with Spring 2.0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Batch version compatible with Spring 2.0

    Hi all,

    I am looking to integrate some batch processing into a web app, and being as I already have experience with Spring Batch, I thought this would be the best way to go.

    However, our web app is running on version 2.0 of Spring, and upgrading it is a bigger job than we can justify at the moment.

    Would anyone be able to advise me as to the version of Spring Batch I should be using.
    I've tried 2.1.8 but am having numerous issues with namespaces and method not found errors.

    Many thanks for your time,

    Dave

  • #2
    Spring Batch was built on Spring 2.5 and has always required that as the minimum version for Spring (in fact, we'll be updating it to require Spring 3+ soon). When you say "upgrading it is a bigger job than we can justify at the moment", two things come to mind:
    1. Did you evaluate the upgrade based on going all the way to the current version or just to 2.5?
    2. Is the use of Spring Batch enough of a justification to do the upgrade to at least 2.5?

    Comment


    • #3
      Originally posted by mminella View Post
      Spring Batch was built on Spring 2.5 and has always required that as the minimum version for Spring (in fact, we'll be updating it to require Spring 3+ soon). When you say "upgrading it is a bigger job than we can justify at the moment", two things come to mind:
      1. Did you evaluate the upgrade based on going all the way to the current version or just to 2.5?
      2. Is the use of Spring Batch enough of a justification to do the upgrade to at least 2.5?
      Hi,

      Many thanks for the reply.

      1 - I've looked at upgrading to the current version, as I wasn't sure at what point Spring Batch 2.1.8 became available.
      2 - It probably is to be honest. Now I know that's the minimum version, I can at least try it and see what breaks in our code.

      Just to mention, my concern isn't around Spring, it's more to do with the current state of our code

      Comment


      • #4
        Hi mminella (or anyone else reading),

        I've upgraded Spring to 2.5, and nothing seems to have broken. Happy days indeed.

        However, when I've tried to implement a FlatFileItemReader (as below), I get the following error:

        Code:
        2012-10-04 08:58:03,242 ERROR core.step.AbstractStep:213  -> Encountered an error executing the step: class java.lang.NoSuchMethodError: org.springframework.core.io.Resource.isReadable()Z
        Code:
            <bean id="itemReader" class="org.springframework.batch.item.file.FlatFileItemReader" >
                <property name="resource" value="file:C:/DJames/Batch/test_input.csv" />
                <property name="lineMapper" ref="lineMapper"/>
            </bean>
        I've got the Spring.jar on my classpath (as provided with 2.5), and the Spring core jar on there too, both of which have a Resource class without the "isReadable" method.

        Is the "isReadable" method a new dependency in a version of Spring Batch that isn't backwardly compatible with Spring 2.5?

        Comment


        • #5
          What version of Spring Batch are you trying to use? While upgrading to 2.5 will get you onto Spring Batch in general, the latest code. I did some digging and it looks like that method call was introduced on the 2.1 branch so if you stick with a version of the 2.0 branch, you should be fine with Spring 2.5 (in theory).

          I have to ask though, if you did the bump to 2.5, have you tried spring 3?

          Comment


          • #6
            Thanks again for your help.

            I'll need to discuss what versions of both Spring and Spring Batch we will go to, as it's not purely my decision.
            I do need to do a bit more digging to find out what effect (if any), moving to Spring 3 would have. I have a horrible feeling that some of the stuff that's deprecated is still in use with our code (from memory, things like the specific MVC controller classes).

            At least I have a plan of action now, which is more than I had this morning, so thanks for that.

            Comment


            • #7
              Hi again everyone.

              I've got batch working within our webapp now, so thanks for all your help.

              The next step is to get Spring Batch Admin running to monitor job execution, and needless to say, I'm having some issues.
              I can include the three jars on the classpath, and I can build and run my app.

              From looking at the docs I've seen, I should be able to go to
              Code:
              <my webapp root>/batch
              and see the standard Spring Batch Admin screen. Is this correct?
              If it is correct, then I've done something wrong, as I just get a 404.

              I've then tried to explicitly override the servlet settings (as described variously all over the web) to map the root to
              Code:
              /batch
              and that throws me another unexpected error:
              Code:
              Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/integration/http]

              Really at my wit's end now, can anyone help?

              Currently using:
              Spring - 2.5.6
              Spring Batch - 2.0.4

              Comment


              • #8
                Hi again,

                Resolved that issue, to be faced with a new one.
                Previous issue was solved by adding the spring integration http and core jars.

                Getting further issues with beans undefined. I'll try and work through them.

                Using Spring Integration release 1.0.4 - anyone know any reasons why that wouldn't work well with the batch and batch admin versions I've mentioned above?

                Comment


                • #9
                  What version of admin are you trying to run and getting errors with?

                  Comment


                  • #10
                    Originally posted by mminella View Post
                    What version of admin are you trying to run and getting errors with?
                    Version 1.0.0 (I think - not at work at the moment).

                    From what I can remember of the stack trace, the main issue was an error when initialising the context, specifically around the TransformerBeanDefinition, and an error in finding a multipart-job-requests bean.

                    Will post more accurate stack trace details tomorrow.

                    Am I correct in my assumption that just by including the Spring batch Admin jars (and dependants) on the classpath, and by setting a servlet mapping, I should be able to see the default admin home screen in my own web app?

                    Comment


                    • #11
                      Hey, just some more stack trace info.

                      From adding the following to my web.xml

                      Code:
                      	<servlet>
                      	    <servlet-name>Batch Servlet</servlet-name>
                      	    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                      	    <init-param>
                      	        <param-name>contextConfigLocation</param-name>
                      	        <param-value>classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml</param-value>
                      	    </init-param>
                      	    <load-on-startup>1</load-on-startup>
                      	</servlet>
                      	
                      	<servlet-mapping>
                      	    <servlet-name>Batch Servlet</servlet-name>
                      	    <url-pattern>/batch/*</url-pattern>
                      	</servlet-mapping>
                      And this to my root application context:

                      Code:
                      <bean id="resourceService"
                      	class="org.springframework.batch.admin.web.resources.DefaultResourceService">
                      	    <property name="servletPath" value="/batch" />
                      	</bean>
                      I get the following error:


                      Code:
                      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.TransformerFactoryBean#0': Cannot resolve reference to bean 'job-configuration-requests' while setting bean property 'outputChannel'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'job-configuration-requests' is defined
                              at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
                              at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:12
                      45)
                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
                              at java.security.AccessController.doPrivileged(Native Method)
                              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
                              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
                              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
                              at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
                              ... 38 more
                      Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'job-configuration-requests' is defined
                              at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:387)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:968)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:238)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
                              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
                              at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
                              ... 51 more

                      Edit to list version numbers:

                      Spring 2.5.5
                      Spring Batch 2.0.4
                      Spring Batch Admin 1.0.0 Release (Including the spring integration contained within the Admin download)
                      Last edited by davefeeder; Oct 23rd, 2012, 04:59 AM.

                      Comment


                      • #12
                        Latest update is that the context loader fails because it can't find the namespace handler for the "task" schema. I've identified that this should live in the Spring Context jar, but it's not there in Spring 2.5.5

                        Any ideas?

                        Comment


                        • #13
                          Am I correct in assuming that Spring Batch Admin is not compatible with any version of Spring framework lower than 3.0?

                          I've got version 1.0.0 of SBA, and it uses the "task" namespace for which there appears to be no handler until Spring 3.

                          Comment


                          • #14
                            The POM does require Spring 3 for SBA. Sorry about the confusion.

                            Comment


                            • #15
                              Originally posted by mminella View Post
                              The POM does require Spring 3 for SBA. Sorry about the confusion.
                              Thanks again for the clarification.

                              I've decided to write my own SBA style monitoring front end. It doesn't need to do anything too complex, just query the job repository for statuses.
                              Had a bit of an arduous task so far with this. Every time I thought I was getting somewhere, another dependency would crawl out of the woodwork and bite me on the backside.

                              Comment

                              Working...
                              X