`

java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy7 implem

阅读更多

java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy7 implementing com.rs.common.core.service.SearchCriteria,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [pack.java.jsf.service.RequisitionBillCriteria] for property 'requisitionBillCriteria': no matching editors or conversion strategy found
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
java.security.AccessController.doPrivileged(Native Method)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
org.springframework.web.context.request.SessionScope.get(SessionScope.java:90)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
org.springframework.web.jsf.DelegatingVariableResolver.resolveSpringBean(DelegatingVariableResolver.java:138)
org.springframework.web.jsf.DelegatingVariableResolver.resolveVariable(DelegatingVariableResolver.java:111)
com.sun.faces.el.VariableResolverChainWrapper.getValue(VariableResolverChainWrapper.java:107)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)

 

如果在Spring配置文件中配置的事务是通过AOP标签实现的,那就在中增加proxy-target-class=”true”属性。就异常显示的信息可以看到,Spring在转换时,主要是将代理类转换成接口,反而不能转换成实际类。

 

如果是通过bean方式增加事务控制,则在配置文件中增加如下代码:(注意红色部分)

解决方案:

 

 

<bean id="transaction" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  		<property name="sessionFactory" ref="sessionFactory" />
	 </bean>
	 
	 <tx:advice id="advice" transaction-manager="transaction">
		  <tx:attributes>
			   <tx:method name="add*" propagation="REQUIRED" />
			   <tx:method name="del*" propagation="REQUIRED" />
			   <tx:method name="update*" propagation="REQUIRED" />
			   <tx:method name="save*" propagation="REQUIRED" />
			   <tx:method name="*" propagation="SUPPORTS" read-only="true"/>
		  </tx:attributes>
	 </tx:advice>
	 <!--加入proxy-target-class="true" 即可,默认是false;-->
	 <aop:config proxy-target-class="true">
	  <aop:pointcut id="cut" expression="execution(* pack.java.jsf.service.*.*(..))" />
	  <aop:advisor advice-ref="advice" pointcut-ref="cut" />
 	</aop:config>

  

即可.重启服务器..错误即可解决..

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics