Announcement Announcement Module
Collapse
No announcement yet.
expression language issue between Spring 2.5 and 3 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • expression language issue between Spring 2.5 and 3

    We’re working off the trunk. I have this reader:


    Code:
    <bean id="databaseReader" class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step">
    
            <property name="dataSource" ref="dataSource"/>
    
            <property name="sql" value="SELECT OBJECTID from ACCOUNT WHERE ACCOUNTID LIKE ?"/>
    
            <property name="rowMapper">
    
                <bean class="com.bsb.sf.batch.reader.PersistentIdRowMapper"/>
    
            </property>
    
            <property name="preparedStatementSetter">
    
                <bean class="org.springframework.batch.core.resource.ListPreparedStatementSetter">
    
                    <property name="parameters">
    
                        <list>
    
                            <value>#{jobParameters[accountPrefix]}%</value>
    
                        </list>
    
                    </property>
    
                </bean>
    
            </property>
    
        </bean>

    I specify an accountPrefix as parameters and everything runs fine (Spring 2.5, Spring batch 2.1.0.CI-SNAPSHOT).



    Then, I deploy the same job in the admin service (Spring 3.0.0, Spring Batch Admin SNAPSHOT, Spring Batch SNAPSHOT).


    Code:
    [INFO] [talledLocalContainer] 2010-01-15 17:32:29 [ThreadPoolTaskExecutor-1] SimpleJobLauncher [INFO] Job: [FlowJob: [name=partitionSimpleJob]] launched with the following parameters: [{accountPrefix=123}]
    
    [INFO] [talledLocalContainer] 2010-01-15 17:32:29 [ThreadPoolTaskExecutor-1] SimpleStepHandler [INFO] Executing step: [TaskletStep: [name=staging]]
    
    [INFO] [talledLocalContainer] 2010-01-15 17:32:29 [ThreadPoolTaskExecutor-1] AbstractStep [ERROR]
    
    Encountered an error executing the step
    
    [INFO] [talledLocalContainer] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.databaseReader' defined in URL [jar:file:/C:/temp/sni/cargo/conf/webapps/batch-admin/WEB-INF/lib/sbpoc-simple-batch-1.0-SNAPSHOT.jar!/jobs/PartitionSimpleJob.xml]: Cannot create inner bean 'org.springframework.batch.core.resource.ListPreparedStatementSetter#1174ec5' of type [org.springframework.batch.core.resource.ListPreparedStatementSetter] while setting
    
    bean property 'preparedStatementSetter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.batch.core.resource.ListPreparedStatementSetter#1174ec5' defined in URL [jar:file:/C:/temp/sni/cargo/conf/webapps/batch-admin/WEB-INF/lib/sbpoc-simple-batch-1.0-SNAPSHOT.jar!/jobs/PartitionSimpleJob.xml]: Initialization of
    
    bean failed; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'account' of bean class [org.springframework.batch.core.scope.context.StepContext]: Bean property 'account' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    
    [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
    
    [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
    
    [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1305)
    
    [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
    
    [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    
    [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    
    [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:328)
    
    [INFO] [talledLocalContainer]   at org.springframework.batch.core.scope.StepScope.get(StepScope.java:150)
    
    [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
    
    [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    
    [INFO] [talledLocalContainer]   at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33)
    
    [INFO] [talledLocalContainer]   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
    
    [INFO] [talledLocalContainer]   at $Proxy35.open(Unknown Source)
    
    [INFO] [talledLocalContainer]   at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:98)
    
    [INFO] [talledLocalContainer]   at org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:288)

    So the question is. Is there a known conflict between the Spring batch “EL” and the Spring 3 EL?



    Thanks,

    Stéphane

  • #2
    It's not really a conflict: just an incompatibility. From the user guide (just added):

    "If you are using Spring 3.0 (or above) the expressions in step-scoped beans are in the Spring Expression Language, a powerful general purpose language with many interesting features. To provide backward compatibility, if Spring Batch detects the presence of older versions of Spring it uses a native expression language that is less powerful, and has slightly different parsing rules. The main difference is that the map keys in the example above do not need to be quoted with Spring 2.5, but the quotes are mandatory in Spring 3.0."

    Comment


    • #3
      Thank you dave; changing

      Code:
      <value>#{jobParameters[accountPrefix]}%</value>
      to

      Code:
      <value>#{jobParameters['accountPrefix']}%</value>
      did the trick.

      Comment

      Working...
      X