Spring Batch
  1. Spring Batch
  2. BATCH-1231

"Superclass has no null constructors but no arguments were given" when using lateBinding FileSystemResource with scope step

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Invalid
    • Affects Version/s: 2.0.1
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      This is a bug i found after the changes in BATCH-1228 were made. Described here:
      http://jira.springframework.org/browse/BATCH-1228?focusedCommentId=43927&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_43927

      When proxyTargetClass in StepScope is true, this bean creates an Exception:
      <bean id="ItemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
      <property name="resource">
      <bean class="org.springframework.core.io.FileSystemResource">
      <constructor-arg index="0" value="#

      {stepExecutionContext[foo]}

      " />
      </bean>
      </property>
      </bean>

      Exceptionmessage is:
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.core.io.FileSystemResource#25deba0e' defined in BeanDefinition defined in class path resource [StepScopeProxyTargetClassIntegrationTests-context.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class org.springframework.core.io.FileSystemResource]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given

      The changed test-context for Test "StepScopeProxyTargetClassIntegrationTests" is attached.

        Activity

        Hide
        Dave Syer added a comment -

        I think this is just telling you that you need to provide a no-args constructor for your class. Since FileSystemResource doesn't have one you need to create your own factory, or switch off proxyTargetClass.

        Show
        Dave Syer added a comment - I think this is just telling you that you need to provide a no-args constructor for your class. Since FileSystemResource doesn't have one you need to create your own factory, or switch off proxyTargetClass.
        Hide
        Dave Syer added a comment -

        Actually, using scope="step" for a FileSystemResource is pretty strange. This should work:

        <bean id="ItemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
         		<property name="resource" value="#{stepExecutionContext[foo]}" />
        </bean>	
        
        Show
        Dave Syer added a comment - Actually, using scope="step" for a FileSystemResource is pretty strange. This should work: <bean id= "ItemReader" class= "org.springframework.batch.item.file.FlatFileItemReader" scope= "step" > <property name= "resource" value= "#{stepExecutionContext[foo]}" /> </bean>
        Hide
        Markus Thielen added a comment -

        Oh! My bad! It works the way you described.

        THANKS!

        Show
        Markus Thielen added a comment - Oh! My bad! It works the way you described. THANKS!

          People

          • Assignee:
            Unassigned
            Reporter:
            Markus Thielen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: