Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Usage example for BatchResourceFactoryBean

  1. #11
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    I was able to reproduce the error as well, thanks for the detail. I'll try and figure out what's going wrong.

  2. #12
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    I made the change to the fixedlengthimportjob to use a BatchResourceFactoryBean, and I did get the same exception. The problem is that the unit test has the locator and input source wired in via autowiring. I pulled all of this out by creating them by hand in the test and everything worked, with the exception of a bug in milestone 4 that was introduced last week, that shouldn't be an issue in milestone 3.

    So, if you just modified the fixedLengthImportJob to add in your classes, and the unit test is still the same, you should be able to fix it the same way I did.

  3. #13
    Join Date
    Jan 2008
    Posts
    9

    Default

    Hi Lucas,

    I was off a few days.

    I tried to follow your instructions, but with no success.
    Can you please post sample code and configuration.

    Thanks in advance

  4. #14
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    I did have an example in the Samples, but it got rolled back for other reasons. Just to make sure it's the actual problem, how exactly are you launching your job? Did you just modify the FixedLengthImportJob with your own classes and reuse the same unit test that launches it?

  5. #15
    Join Date
    Jan 2008
    Posts
    9

    Default

    I am working with m3 version of spring-batch (zip download).
    I have modified fileLocator to :

    Code:
    <bean id="fileLocator"
    	class="org.springframework.batch.execution.resource.BatchResourceFactoryBean"
    	scope="step">
    	<property name="rootDirectory" value="file://c/gsm2/data/inct" />
    	<property name="filePattern" value="%BATCH_ROOT%/%JOB_NAME%" />
    	<aop:scoped-proxy />
    </bean>
    and than run job with BatchCommandLineLauncher.

  6. #16
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Right, I understand. However, the error you're getting usually happens when someone tries to access a step scoped bean before a step has been started. I was able to reproduce this in the fixedLengthImportJob by changing our filelcoator to a resource factory bean. Because the unit test had the Resource autowired in, the bean (which is step scoped) was being accessed before the step was created, and the same error you received was thrown.

    Are you accessing any step scoped beans outside a step itself anywhere?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •