Results 1 to 5 of 5

Thread: $Proxy10

  1. #1

    Default $Proxy10

    I've a casting problem:

    Configuring my bean I wrote:

    Code:
    <bean id="PasoMapeo_Tasklet" class="es.bde.arq.ias.batch.tasklet.impl.AutoMappingTasklet" scope="step">
           <property name="mappingList">
                  <list>
                         <bean class="es.bde.arq.ias.batch.utils.Mapeo">
                                <property name="sourceObj" value="" />
                         </bean>
                  </list>
           </property>
    </bean>
    At runtime I'm obtaining a List of $Proxy10, but I don't know how to solve it and obtain my "es.bde.arq.ias.batch.utils.Mapeo" object...

    Please, any help?

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    So what is the problem, exactly? The proxy will have all the interfaces that the Mapeo class has by default. If you want the raw instances then I assume they are stateless, so they don't need to be in step scope? If so then inner bean definitions inherit the scope from their enclosing bean, so you either need to use scope="singleton" in the inner bean, or make it into a top=level bean definition and use ref="..." to inject it.

  3. #3

    Default

    Here is my tasklet's code for the bean defined upper:

    Code:
    ArrayList<Mapeo> mappingList;
    
    public void setMappingList(ArrayList<Mapeo> mappingList)
    {
    	this.mappingList = mappingList;
    }
    I get an exception before the setter is executed...

    Code:
    Encountered an error executing the step: class org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lazyBindingProxy.PasoMapeo_Tasklet#sysinit' defined in class path resource [es/bde/aps/zzz/ias/batch/jobs/jobmapeodatos/bezzz_JobMapeoDatos.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [java.util.ArrayList] for property 'mappingList'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy10 implementing org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [es.bde.arq.ias.batch.utils.Mapeo] for property 'mappingList[0]': no matching editors or conversion strategy foundorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lazyBindingProxy.PasoMapeo_Tasklet#sysinit' defined in class path resource [es/bde/aps/zzz/ias/batch/jobs/jobmapeodatos/bezzz_JobMapeoDatos.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [java.util.ArrayList] for property 'mappingList'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy10 implementing org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [es.bde.arq.ias.batch.utils.Mapeo] for property 'mappingList[0]': no matching editors or conversion strategy found
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
    	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$2.getObject(AbstractBeanFactory.java:302)
    	at org.springframework.batch.core.scope.StepScope.get(StepScope.java:120)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    	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.batch.core.scope.util.PlaceholderTargetSource.getTarget(PlaceholderTargetSource.java:205)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:184)
    	at $Proxy3.execute(Unknown Source)
    	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264)
    	at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:67)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:352)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:239)
    	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197)
    	at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:348)
    	at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43)
    	at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:137)
    	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:105)
    	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:250)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:110)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:105)
    	at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:207)
    	at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:254)
    	at es.bde.arq.ias.batch.runner.IASCommandLineJobRunner.executeWithParamsName(IASCommandLineJobRunner.java:71)
    	at es.bde.aps.zzz.ias.batch.jobs.jobmapeodatos.JobMapeoDatosRunner.main(JobMapeoDatosRunner.java:17)
    Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [java.util.ArrayList] for property 'mappingList'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy10 implementing org.springframework.aop.scope.ScopedObject,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [es.bde.arq.ias.batch.utils.Mapeo] for property 'mappingList[0]': no matching editors or conversion strategy found
    	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
    	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1276)
    	... 35 more
    If I change Mapeo for Object in the ArrayList definition:

    Code:
    ArrayList<Object> mappingList;
    
    public void setMappingList(ArrayList<Object> mappingList)
    {
    	this.mappingList = mappingList;
    }
    It run's OK, but then I can't to call Mapeo's methods becauso I can't to cast it...

    I don't know what I'm doing wrong...

  4. #4
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    I'll repeat the questions I asked in my last reply: is the Mapeo stateless? Can you put it in singleton scope?

    If it is stateful does it have an interface? If not give it one, and use that in your injected list instead of the concrete class. As a last resort you can use proxy-target-class="true", but I don't want to confuse the issue by discussing that unless we have to.

    Also why are you using ArrayList? It's not a good idea to depend on concrete classes when they have an interface? Is there some part of the ArrayList API that you rely on in your code?

  5. #5

    Default

    OK I did'nt understand your reply very well... My problem was that Mapeo did not implements any interface. It is solved. Thak you very much.

    About ArrayList, it was a fool proof, I'm using generic classes like Map or List. Thanks another time!

    Code:
    List<IMapeo> mappingList;
    
    public void setMappingList(List<IMapeo> mappingList)
    {
    	this.mappingList = mappingList;
    }

Posting Permissions

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