spring data jpa 运用,在dao类中写自己新增的方法,使用@query写hql语句,出现以下异常:
Caused by: java.lang.NoSuchMethodError: org.springframework.dao.IncorrectResultSizeDataAccessException.<init>(Ljava/lang/String;ILjava/lang/Throwable;)V
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:307)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:107)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:403)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy197.findByArStatus(Unknown Source)
at com.hopebridge.bloodlibrary.dal.daoservice.dic.DictAuditRoleDaoService.findByArStatus(DictAuditRoleDaoService.java:95)
at com.hopebridge.bloodlibrary.dal.daoservice.dic.DictAuditRoleDaoService$$FastClassByCGLIB$$b1ba3913.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at com.hopebridge.bloodlibrary.dal.daoservice.dic.DictAuditRoleDaoService$$EnhancerByCGLIB$$3d713821.findByArStatus(<generated>)
at com.hopebridge.bloodlibrary.dal.service.dic.DictAuditRoleService.findByArStatus(DictAuditRoleService.java:185)
at com.hopebridge.bloodlibrary.bll.business.BdApplyCombineEntityLogic.ValidateAuthority(BdApplyCombineEntityLogic.java:199)
at com.hopebridge.bloodlibrary.bll.business.BdApplyCombineEntityLogic.AuditBdApplyEntity(BdApplyCombineEntityLogic.java:112)
at com.hopebridge.service.blood.business.BdApplyCombineEntityService.AuditBdApplyEntity(BdApplyCombineEntityService.java:31)
... 52 more
解决思路:像java.lang.NoSuchMethodError: org.springframework.dao.IncorrectResultSizeDataAccessException.<init>(Ljava/lang/String;ILjava/lang/Throwable;)V这类型的错误一般是未找到方法,或者是引入多个包造成版本冲突
找到org.springframework.dao.IncorrectResultSizeDataAccessException.<init>(Ljava/lang/String;ILjava/lang/Throwable;)V所在的包,发现有两个包有这个类,一个是spring-tx,一个是另外一个包有这个类但是没这个方法,删掉这个包便正常。
顺便说一下 JNI字段描述符(Ljava/lang/String;ILjava/lang/Throwable;)V
最后面的V表示void即无返回值
L表示对象类型,后面紧跟对象类型java/lang/String;分割
I表示基本类型int,不用;分割,后面是另外一个对象类型java/lang/Throwable
整个表示方法
void IncorrectResultSizeDataAccessException(String,int,Throwable)
java.lang.NoSuchMethodError:
org.springframework.dao.IncorrectResultSizeDataAccessException,布布扣,bubuko.com
java.lang.NoSuchMethodError:
org.springframework.dao.IncorrectResultSizeDataAccessException
原文:http://www.cnblogs.com/zhangcybb/p/3708075.html