`
haofenglemon
  • 浏览: 240785 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

SpringAop 报错

阅读更多
AOP configuration seems to be invalid: tried calling method [public abstract com.spring.entity.User com.spring.biz.UserBiz.getUserByName(java.lang.String)] on target [userBizImpl]; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)14:40:17,109 DEBUG JDBCTransaction:152 - rollback
14:40:17,109 DEBUG JDBCTransaction:163 - rolled back JDBC Connection
14:40:17,109 DEBUG JDBCContext:215 - after transaction completion
14:40:17,109 DEBUG ConnectionManager:398 - aggressively releasing JDBC connection
14:40:17,109 DEBUG ConnectionManager:435 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
at com.spring.advice.AroundAdvice.invoke(AroundAdvice.java:17)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
at $Proxy0.getUserByName(Unknown Source)
at com.spring.entity.Test.main(Test.java:13)
14:40:17,109 DEBUG SessionImpl:422 - after transaction completion
14:40:17,109 DEBUG SessionImpl:353 - automatically closing session
14:40:17,109 DEBUG SessionImpl:273 - closing session
14:40:17,109 DEBUG ConnectionManager:369 - connection already null in cleanup : no action
Exception in thread "main" java.lang.NullPointerException
at com.spring.entity.Test.main(Test.java:14)

解决方案
  错误如下:object is not an instance of declaring class
  代码:method.invoke(object,new Object[]{subObject});原来不小心将object直接写为object.getClass(),并非得到我这个类的实例,修改为这个类的实例即可。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics