【Caused by: java.lang.IllegalArgumentException: Original must not be null 】
下面是我开发项目中遇到的问题,Caused by: java.lang.IllegalArgumentException: Original must not be null,提示这个错误,百思不得其解。最后面不断的google,spring配置Aop配置相关的文章,最后硬着头皮去看看错误,想调试一番,因为spring的代理无非就是两种,一种是jdk代理;另外一种就是cglib代理。
在这个项目中我用了spring的cglib代理,但是项目是SSH(spring+struts2+ibatis),struts2 默认注入的方式是jdk模式,问题是否是出在这个地方呢?
错误:Failed to convert property value of type [com.taobao.www.fanjf.servicei.TaobaokeItemsService$$EnhancerByCGLIB$$20783c4d] to required type
TaobaokeItemsService(实现类)注入到一个spring受管Bean中, 但是spring容器提示你注入的Bean类型不对,它说你注入的是 [$Proxy13] 类型,这就说明你可能在无意中将authorDaoImp实现了代理, 此时你再在spring容器中引用 TaobaokeItemsService(实现类)时得到的将是代理类型。
这个似乎提示了我,在struts2当中,我必须通过接口注入方式。
在com.taobao.www.fanjf.action.DisplayPayedAction这个action当中我必须通过接口注入,最后面确定了,lazy-init="false" 也必须使用
[html]
taobaokeItemsManager
下面是配置:
[html]
<!-- 声明一个服务 -->
<bean id="taobaokeItemsServiceTarget" class="com.taobao.www.fanjf.servicei.TaobaokeItemsService" lazy-init="false" autowire="byType"/>
<!-- 相关的服务 -->
<bean id = "taobaokeItemsManager" class="org.springframework.aop.framework.ProxyFactoryBean" >
<!--这里代理的是接口-->
<property name="proxyInterfaces" value="com.taobao.www.fanjf.servicei.ITaobaokeItemsService">
</property>
<!--是ProxyFactoryBean要代理的目标类-->
<property name="target">
<ref bean="taobaokeItemsServiceTarget"/>
</property>
<property name="interceptorNames">
<list>
<value>methodCachePointCut</value>
</list>
</property>
<property name="proxyTargetClass" value="true"/>
</bean>
<bean id="DisplayPayedAction" class="com.taobao.www.fanjf.action.DisplayPayedAction">
<property name="taobaokeItemsManager" ref="taobaokeItemsManager" />
</bean>
[java]
[DEBUG] 2012-12-20 13:28:40 :Unable to apply any optimisations to advised method: protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract int org.springframework.aop.framework.Advised.indexOf(org.aopalliance.aop.Advice)
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract int org.springframework.aop.framework.Advised.indexOf(org.springframework.aop.Advisor)
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isFrozen()
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract org.springframework.aop.TargetSource org.springframework.aop.framework.Advised.getTargetSource()
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvisor(org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvisor(int,org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setTargetSource(org.springframework.aop.TargetSource)
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setPreFiltered(boolean)
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isProxyTargetClass()
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setExposeProxy(boolean)
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isExposeProxy()
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract java.lang.Class[] org.springframework.aop.framework.Advised.getProxiedInterfaces()
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract org.springframework.aop.Advisor[] org.springframework.aop.framework.Advised.getAdvisors()
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isPreFiltered()
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isInterfaceProxied(java.lang.Class)
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.removeAdvisor(int) throws org.springframework.aop.framework.AopConfigException
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.removeAdvisor(org.springframework.aop.Advisor)
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.replaceAdvisor(org.springframework.aop.Advisor,org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvice(int,org.aopalliance.aop.Advice) throws org.springframework.aop.framework.AopConfigException
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvice(org.aopalliance.aop.Advice) throws org.springframework.aop.framework.AopConfigException
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.removeAdvice(org.aopalliance.aop.Advice)
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract java.lang.String org.springframework.aop.framework.Advised.toProxyConfigString()
[DEBUG] 2012-12-20 13:28:40 :Method is declared on Advised interface: public abstract java.lang.Class org.springframework.aop.TargetClassAware.getTargetClass()
[DEBUG] 2012-12-20 13:28:40 :Finished creating instance of bean 'fanjfReportMemeberDAO'
[DEBUG] 2012-12-20 13:28:40 :Creating shared instance of singleton bean 'userInviteDAO'
[DEBUG] 2012-12-20 13:28:40 :Creating instance of bean 'userInviteDAO'
[DEBUG] 2012-12-20 13:28:40 :Returning cached instance of singleton bean 'methodCachePointCut'
[DEBUG] 2012-12-20 13:28:40 :Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0'
[DEBUG] 2012-12-20 13:28:40 :Eagerly caching bean 'userInviteDAO' to allow for resolving potential circular references
[DEBUG] 2012-12-20 13:28:40 :Getting BeanInfo for class [com.taobao.www.fanjf.daoi.UserInviteDAO]
[DEBUG] 2012-12-20 13:28:40 :Caching PropertyDescriptors for class [com.taobao.www.fanjf.daoi.UserInviteDAO]
[DEBUG] 2012-12-20 13:28:40 :Found bean property 'class' of type [java.lang.Class]
[DEBUG] 2012-12-20 13:28:40 :Found bean property 'dataSource' of type [javax.sql.DataSource]
[DEBUG] 2012-12-20 13:28:40 :Found bean property 'sqlMapClient' of type [com.ibatis.sqlmap.client.SqlMapClient]
[DEBUG] 2012-12-20 13:28:40 :Found bean property 'sqlMapClientTemplate' of type [org.springframework.orm.ibatis.SqlMapClientTemplate]
[DEBUG] 2012-12-20 13:28:40 :Returning cached instance of singleton bean 'sqlMapClient'
[DEBUG] 2012-12-20 13:28:40 :Invoking afterPropertiesSet() on bean with name 'userInviteDAO'
[DEBUG] 2012-12-20 13:28:40 :Returning cached instance of singleton bean 'methodCachePointCut'
[DEBUG] 2012-12-20 13:28:40 :Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0'
[DEBUG] 2012-12-20 13:28:40 :Returning cached instance of singleton bean 'methodCachePointCut'
[DEBUG] 2012-12-20 13:28:40 :Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0'
[DEBUG] 2012-12-20 13:28:40 :Creating [java.util.concurrent.ConcurrentHashMap]
[DEBUG] 2012-12-20 13:28:40 :Creating implicit proxy for bean 'userInviteDAO' with 0 common interceptors and 2 specific interceptors
[DEBUG] 2012-12-20 13:28:40 :Creating CGLIB2 proxy: target source is SingletonTargetSource for target object [com.taobao.www.fanjf.daoi.UserInviteDAO@17e9b52]
[WARN ] 2012-12-20 13:28:40 :Unable to proxy method [public final void org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.setDataSource(javax.sql.DataSource)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
[WARN ] 2012-12-20 13:28:40 :Unable to proxy method [public final org.springframework.orm.ibatis.SqlMapClientTemplate org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.getSqlMapClientTemplate()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
[WARN ] 2012-12-20 13:28:40 :Unable to proxy method [public final javax.sql.DataSource org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.getDataSource()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
[WARN ] 2012-12-20 13:28:40 :Unable to proxy method [public final void org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
[WARN ] 2012-12-20 13:28:40 :Unable to proxy method [public final com.ibatis.sqlmap.client.SqlMapClient org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.getSqlMapClient()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
[WARN ] 2012-12-20 13:28:40 :Unable to proxy method [public final void org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.setSqlMapClientTemplate(org.springframework.orm.ibatis.SqlMapClientTemplate)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
[WARN ] 2012-12-20 13:28:40 :Unable to proxy method [public final void org.springframework.dao.support.DaoSupport.afterPropertiesSet() throws java.lang.IllegalArgumentException,org.springframework.beans.factory.BeanInitializationException] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
[DEBUG] 2012-12-20 13:28:40 :Creating [java.util.concurrent.ConcurrentHashMap]
[DEBUG] 2012-12-20 13:28:40 :Unable to apply any optimisations to advised method: public java.util.List com.taobao.www.fanjf.daoi.UserInviteDAO.query(java.lang.Long,java.lang.Long,java.lang.String,java.lang.String,java.util.Date,java.util.Date) throws java.lang.RuntimeException
[DEBUG] 2012-12-20 13:28:40 :Unable to apply any optimisations to advised method: public com.taobao.www.fanjf.pojo.UserInvite com.taobao.www.fanjf.daoi.UserInviteDAO.findUserInviteById(int) throws java.lang.RuntimeException
[DEBUG] 2012-12-20 13:28:40 :Unable to apply any optimisations to advised method: public void com.taobao.www.fanjf.daoi.UserInviteDAO.saveUserInvite(com.taobao.www.fanjf.pojo.UserInvite) throws java.lang.RuntimeException
[DEBUG] 2012-12-20 13:28:40 :Unable to apply any optimisations to advised method: public void com.taobao.www.fanjf.daoi.UserInviteDAO.deleteUserInvite(int) throws java.lang.RuntimeException
[DEBUG] 2012-12-20 13:28:40 :Unable to apply any optimisations to advised method: public void com.taobao.www.fanjf.daoi.UserInviteDAO.updateUserInvite(com.taobao.www.fanjf.pojo.UserInvite) throws java.lang.RuntimeException
更多精彩教程请关注:windows xp系统下载