Announcement Announcement Module
Collapse
No announcement yet.
Invalid property 'jobParameters' of bean class [org.springframework.batch.core.scope Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Invalid property 'jobParameters' of bean class [org.springframework.batch.core.scope

    When running my code from RAD, as a java application, i am getting the following error. (RAD using a JRE lib of WebSphere AS 7 jdk--> jre i.e jre1.6). Seems like its a problem with jre provided by WAS
    when i am porting the same application in eclipse, my job is running fine.(using jre7 & also working with jre 1.6).
    Problem with IBM provided java, working fine in Oracle provided java.
    can anybody pls throw focus & let me know what exactly is happening & help me.

    Code:
    Throwable occurred: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.scopedTarget.myReader' defined in class path resource [jobs/job2.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 'jobParameters' of bean class [org.springframework.batch.core.scope.context.StepContext]: Bean property 'jobParameters' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:332)
    	at org.springframework.batch.core.scope.StepScope.get(StepScope.java:150)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    	at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
    	at $Proxy3.close(Unknown Source)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    	at java.lang.reflect.Method.invoke(Method.java:599)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy3.close(Unknown Source)
    	at org.springframework.batch.item.support.CompositeItemStream.close(CompositeItemStream.java:83)
    	at org.springframework.batch.core.step.item.ChunkMonitor.close(ChunkMonitor.java:99)
    	at org.springframework.batch.item.support.CompositeItemStream.close(CompositeItemStream.java:83)
    	at org.springframework.batch.core.step.tasklet.TaskletStep.close(TaskletStep.java:297)
    	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:255)
    	at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)
    	at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)
    	at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
    	at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
    	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114)
    	at com.t.o.b.b.n.GetFilesInfoTasklet.execute(GetFilesInfoTasklet.java:63)
    	at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:386)
    	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
    	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264)
    	at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:250)
    	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195)
    	at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)
    	at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)
    	at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
    	at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
    	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114)
    	at com.t.o.b.b.n.JobTest.jobShouldRunSuccessfully(JobTest.java:40)
    	
    Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'jobParameters' of bean class [org.springframework.batch.core.scope.context.StepContext]: Bean property 'jobParameters' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    	at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:142)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1299)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:210)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:182)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    	... 79 more
    Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'jobParameters' of bean class [org.springframework.batch.core.scope.context.StepContext]: Bean property 'jobParameters' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    	at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:729)
    	at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:721)
    	at org.springframework.batch.core.scope.StepScope.resolveContextualObject(StepScope.java:131)
    Last edited by krish_mohan; Aug 31st, 2012, 07:45 AM.

  • #2
    My Code Looks Somewhat like this

    Job1-->GetFilesInfoTasklet-->gets all files from un processed directory-->launches job2 for each file.

    I am getting error while parsing a part of job2.xml which is in Red.




    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:batch="http://www.springframework.org/schema/batch"
    	xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    	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/schem...-batch-2.1.xsd
    	http://www.springframework.org/schema/jdbc
    	http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">	
    	<job id="Job1"  xmlns="http://www.springframework.org/schema/batch" job-repository="jobRepository">
    		
    		<step id="getFiles">
    			<tasklet ref="getFilesInfo">
    			 	<batch:transaction-attributes propagation="NOT_SUPPORTED" />
    			 </tasklet>
    		</step>
    	</job>
    	<bean id="taskExecutor" class="org.springframework.core.task.SyncTaskExecutor" />
    	<bean id="getFilesInfo" class="com.t.o.b.b.n.GetFilesInfoTasklet" />
    	<bean id="transactionManager"
    		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    		<property name="dataSource" ref="dataSource" />
    	</bean>
    	
    	<batch:job-repository  id="jobRepository"
    		data-source="dataSource"
    		transaction-manager="transactionManager"
    		isolation-level-for-create="SERIALIZABLE"
    	/>	
    		
    	<bean id="jobLauncher"
    		class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
    		<property name="jobRepository" ref="jobRepository" />
    	</bean>
    	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
    		<property name="url" value="jdbc:mysql://localhost:3306/mohan" />
    		<property name="username" value="root" />
    		<property name="password" value="root" />
    		<property name="initialSize" value="10" />
    		<property name="maxActive" value="30" />
    		<property name="defaultAutoCommit" value="false"/>		
    	</bean>
    	
      	<!--<jdbc:initialize-database data-source="dataSource">
     		 <jdbc:script location="classpath:/org/springframework/batch/core/schema-mysql.sql"/>
      		<jdbc:script location="classpath:/create-tables.sql" />
    	 </jdbc:initialize-database>
      	--></beans>
    Code:
    package com.t.o.b.b.n;
    
    import java.io.File;
    import java.io.FilenameFilter;
    
    import org.springframework.batch.core.Job;
    import org.springframework.batch.core.JobExecution;
    import org.springframework.batch.core.JobParameters;
    import org.springframework.batch.core.JobParametersBuilder;
    import org.springframework.batch.core.JobParametersInvalidException;
    import org.springframework.batch.core.StepContribution;
    import org.springframework.batch.core.launch.JobLauncher;
    import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
    import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
    import org.springframework.batch.core.repository.JobRestartException;
    import org.springframework.batch.core.scope.context.ChunkContext;
    import org.springframework.batch.core.step.tasklet.Tasklet;
    import org.springframework.batch.repeat.RepeatStatus;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class GetFilesInfoTasklet implements Tasklet{
    	JobLauncher jobLauncher;
    	Job job;
    	JobParameters jobParameters;
    	public RepeatStatus execute(StepContribution arg0, ChunkContext arg1)
    			throws Exception {
    		
    		String ackFileDir=new String("C:/ackFiles/");
    		String unProcessedDir=new String("C:/UnProcNegFiles");
    		String processedDir=new String("C:/ProcNegFiles");
    		File directory = new File(unProcessedDir); 
    		String fileName;
    		
    		String[] filenames = directory.list();  
    		if(filenames==null){
    			System.out.println("no files in the directory");			
    		}
    		System.out.println("files in the directory");
    		JobExecution jobExecution;
    		
    		ApplicationContext context =new ClassPathXmlApplicationContext("jobs/Job2.xml");
    		jobLauncher = (JobLauncher) context.getBean("jobLauncher");
    		job = (Job) context.getBean("Job2");
    		for (int i = 0; i < filenames.length; i++) {
    			System.out.println(i);
    			fileName = filenames[i];
    			if(fileName.contains(".ext.")){
    				String sourceFilePath=(new StringBuffer(unProcessedDir).append("/").append(fileName)).toString();
    				
    				System.out.println(sourceFilePath);
    				
    				jobParameters=new JobParametersBuilder().addString("ackFileDir", ackFileDir)
    														.addString("unProcessedDir", unProcessedDir)
    														.addString("processedDir", processedDir)
    														.addString("fileName", fileName)
    														.toJobParameters();								
    				jobExecution=jobLauncher.run(job, jobParameters);
    			}
    		
    		}  
    		
    		return RepeatStatus.FINISHED;
    	}
    
    }
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:batch="http://www.springframework.org/schema/batch"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    	http://www.springframework.org/schema/batch 
    	http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
    	<import resource="../batch-infrastructure-context.xml" />
    	<import resource="../connect-database-context.xml" />
    	<job id="Job2"  xmlns="http://www.springframework.org/schema/batch" job-repository="jobRepository">
    		
    		
    		<step id="processCard" next="clean">
    			<tasklet > 
    				<chunk reader="MyReader" 
    						writer="MyWriter" 
    						commit-interval="200"
    						skip-limit="20">
    					<skippable-exception-classes>
    						<include class="org.springframework.batch.item.file.FlatFileParseException" />
    					</skippable-exception-classes>
    				 	<streams>
    						<stream ref="MyReader"/>
    						<!--<stream ref="MyWriter"/>
    						<stream ref="writer"/>						
    					--></streams> 
    				</chunk>		
    				<listeners>
    					<listener ref="MyTokenizer"/>
    					<listener ref="footerCallback"/>
    					<listener ref="headerCopier"/>				
    				</listeners>		
    		    </tasklet>
    		</step>
    		<step id="clean">
    			<tasklet ref="cleanTasklet" />
    		</step>
    	</job>
    	<bean class="org.springframework.batch.core.scope.StepScope" /> 
    	<bean id="cleanTasklet" class="com.t.o.b.b.n.CleanTasklet" scope="step" >
    		<property name="processedDir" value="#{jobParameters['processedDir']}" />
    		<property name="unProcessedDir" value="#{jobParameters['unProcessedDir']}" />
    		<property name="fileName" value="#{jobParameters['fileName']}" />
    	</bean>
    			
    	<bean id="MyWriter" class="com.t.o.b.b.n.MyWriter" >
    		<property name="myDao" ref="myDao" />
    		 <property name="delegate" ref="writer"/>
    	</bean>
    
    	<bean id="writer" class="org.springframework.batch.item.file.FlatFileItemWriter" >		 
    		<property name="resource"  ref="outputResource" />
    		<property name="lineAggregator">
    			<bean class="org.springframework.batch.item.file.transform.PassThroughLineAggregator" />
    		</property>		
    		<property name="footerCallback" ref="footerCallback" />
    	</bean>
    	
    	<bean name="MyReader"  scope="step" class="org.springframework.batch.item.file.FlatFileItemReader" >
    		<property name="resource" value="file:/#{jobParameters['unProcessedDir']}/#{jobParameters['fileName']}" />
    		<property name="lineMapper">
    		 	<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper" >
    		 		<property name="lineTokenizer" ref="MyTokenizer" />
    		 		<property name="fieldSetMapper" ref="myMapper" />
    		 	</bean>
    		</property>
    		<property name="skippedLinesCallback" ref="headerCopier" />
    		<property name="linesToSkip" value="1" />
    	</bean>	
    	<bean id="footerCallback" class="com.t.o.b.b.n.support.SummaryFooterCallback" />
    	<bean id="headerCopier"
    		class="com.t.o.b.b.n.support.HeaderCopyCallback" />
    		
    	<bean name="myMapper" class="com.t.o.b.b.n.MyMapper" />
    	
    	<bean name="MyTokenizer" class="com.t.o.b.b.n.MyLineTokenizer" >
    		<property name="MyTokenizer">
    			<bean class="org.springframework.batch.item.file.transform.FixedLengthTokenizer" >
    				<property name="columns" value="1-10,11,12" />
    			</bean>
    		</property>
    		<property name="footerTokenizer" >
    			<bean class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">				
    				<property name="columns" value="1,2" />
    			</bean>
    		</property>
    		<property name="headerTokenizer" >
    			<bean class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">				
    				<property name="columns" value="1,2-12" />
    			</bean>
    		</property>
    	</bean>
    		
    	<bean name="myDao" class="com.t.o.b.b.n.MyDaoImpl" >
    		<constructor-arg  ref="dataSource" />
    	</bean>	
    	
    	<bean id="outputResource" class="org.springframework.core.io.FileSystemResource" scope="step">
    		<constructor-arg type="java.lang.String"
    			value="#{jobParameters['ackFileDir']}#{jobParameters['fileName']}.ext" />
    	</bean>
    	
    </beans>
    Last edited by krish_mohan; Aug 30th, 2012, 01:43 PM.

    Comment

    Working...
    X