您现在的位置是:首页 > 正文

项目启动报java.lang.IllegalAccessError: tried to access method 热门推荐

2024-04-01 02:46:16阅读 2

最近在对接京东代扣相关的业务,拿到京东的Demo,可以很快地把整套的流程跑下来,但当把Demo集成到项目中时,只要启动项目就不停地报错,错误信息如下:

2017-10-13 19:34:18 ERROR _500_jsp _jspService - Handler processing failed; nested exception is java.lang.IllegalAccessError: tried to access method org.apache.commons.codec.digest.DigestUtils.getDigest(Ljava/lang/String;)Ljava/security/MessageDigest; from class com.wangyin.npp.util.SignUtils
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.IllegalAccessError: tried to access method org.apache.commons.codec.digest.DigestUtils.getDigest(Ljava/lang/String;)Ljava/security/MessageDigest; from class com.wangyin.npp.util.SignUtils
    at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1305)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:979)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
    at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
    at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalAccessError: tried to access method org.apache.commons.codec.digest.DigestUtils.getDigest(Ljava/lang/String;)Ljava/security/MessageDigest; from class com.wangyin.npp.util.SignUtils
    at com.wangyin.npp.util.SignUtils.digestHex(SignUtils.java:142)
    at com.wangyin.npp.util.SignUtils.sign(SignUtils.java:45)
    at com.thinkgem.jeesite.easyloan.api.jdpay.util.EnctyptUtil.sign(EnctyptUtil.java:96)
    at com.thinkgem.jeesite.easyloan.api.jdpay.agencypay.util.RequestUtil.enctyptData(RequestUtil.java:60)
    at com.thinkgem.jeesite.easyloan.api.jdpay.agencypay.util.RequestUtil.tradeRequestSSL(RequestUtil.java:40)
    at com.thinkgem.jeesite.easyloan.api.jdpay.agencypay.AgreementSign.agreementSignRequest(AgreementSign.java:146)
    at com.thinkgem.jeesite.easyloan.api.jdpay.service.AgencyPayService.agreementSignRequest(AgencyPayService.java:64)
    at com.thinkgem.jeesite.easyloan.api.jdpay.service.AgencyPayService$$FastClassBySpringCGLIB$$c2335cfa.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
    at com.thinkgem.jeesite.easyloan.api.jdpay.service.AgencyPayService$$EnhancerBySpringCGLIB$$10c648d3.agreementSignRequest(<generated>)
    at com.thinkgem.jeesite.easyloan.api.jdpay.service.AgencyPayService$$FastClassBySpringCGLIB$$c2335cfa.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
    at com.thinkgem.jeesite.easyloan.api.jdpay.service.AgencyPayService$$EnhancerBySpringCGLIB$$9a4e90ad.agreementSignRequest(<generated>)
    at com.thinkgem.jeesite.easyloan.api.jdpay.controller.AgencyPayController.agreementSignRequest(AgencyPayController.java:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:832)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:743)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)
    ... 40 more

其实通过错误提示就能直接看到问题的所在,是因为jar包冲突了.我们使用的是maven管理项目的,但通过maven分析jar却找不到冲突的包所在,只能一个包一个包的找那个codec的DigestUtils,终于在项目中找到了好几个,除了容联云SDK中的codec是1.5的,其他的都跟项目的版本一致.所以,就用maven依赖的exclusion方法,将jar中的类给排除掉
这里写图片描述
然后maven的依赖树,发现类的确被排除掉了,可再重启的时候,发现还是报错.这一下子就给搞懵掉了,于是就开始了一段漫长地排查过程,经过各种排查以及找京东的技术,都没法找到问题的所在.没办法,最后只好把功能单独地启一个项目,然后把我们框架的依赖全都加上,一个一个地去试,最后发现,竟然问题还是出在容联云的那个jar包上面.这就比较奇怪了,明明已经exclusion过了,为什么还是会报错呢?然后,又对容联云的jar进行了一层一层地排除,最后发现就算把所有的都exclusion掉还是会报错,可检查maven依赖,的确都已经没有了啊.这真的就奇怪了,难道是exclusion不对.后来,仔细地分析 jar才发现,原来容联云为了方便客户集成,并不是像我们一样使用的是maven依赖那些其他需要引入的jar的,而是直接放jar源码的,这也就导致了怎么exclusion,其实jar里面的方法其实都还是能访问到的,所以也就引起了版本的冲突

网站文章

  • Tor

    Tor

    先打开这个网站 https://bridges.torproject.org/ Step #1:下载Tor浏览器 Step #2:获取bridges Step #3:在Tor浏览器上添加网桥 Step #4:调出项目结构管理区域 把网桥全部复制进去 在点击连接 注:连接第一次的时候比较慢 -End- 暗网搜索引擎 http://www.onion.l

    2024-04-01 02:45:37
  • CPU缓存那些事儿

    CPU缓存那些事儿

    CPU高速缓存集成于CPU的内部,其是CPU可以高效运行的成分之一,本文围绕下面三个话题来讲解CPU缓存的作用:为什么需要高速缓存?高速缓存的内部结构是怎样的?如何利用好cache,优化代码执行效率?...

    2024-04-01 02:45:29
  • IDEA-推荐几款好用的插件

    IDEA-推荐几款好用的插件

    .ignore git提交时过滤掉不需要提交的文件,很方便,有些本地文件是不需要提交到Git上的。 TranslationPlugin 对于不经常使用英语的同学来说,对类,变量,方法想取一个合适的名字...

    2024-04-01 02:45:22
  • 防病毒服务器部署位置,SymantecAntiVirus防病毒服务器安装配置使用指南.pdf

    Symantec AntiVirus 病毒服务器安装配置使用指南放入Symantec AntiVirus 安装光盘自启动 (或点击应用程序setup )后,选择 “安装管理员工具”。如...

    2024-04-01 02:44:39
  • javascript数组常用api 方法

    本文总结了javascript常用的数组的方法包括 forEach filter map join concat sort splice indexOf reverse find every push unshift pop shift等

    2024-04-01 02:44:31
  • IDEA 设置类注释,方法注释 /**

    IDEA 设置类注释,方法注释 /**

    一、类注释 打开: File → Settings → Editor → File and Code Templates 在class上方设置下放格式: /** * @Description: * @...

    2024-04-01 02:44:24
  • Markdown学习(七)

    Markdown学习(七)

    强调Markdown 使用星号()和底线(_)作为标记强调字词的符号,被 或 _ 包围的字词会被转成用 <em> 标签包围,用两个 * 或 _ 包起来的话,则会被转成 <strong>,例如:Source:*single asterisks*_single underscores_**double asterisks**__double underscores__Result:single as

    2024-04-01 02:43:44
  • 红黑树详解(上)(红黑树的基本概念、查找操作、插入操作)

    红黑树详解(上)(红黑树的基本概念、查找操作、插入操作)

    红黑树详解 前言 师傅渣哥在最后一节课上提到,如果能在简历上写“手写过红黑树”,给对方的感觉一定是不一样的。 正值寒假,笔者学习大量前人文章,又投入数个夜晚思考,逐个情况推导方案,编写代码,调试分析,...

    2024-04-01 02:43:37
  • 2021-04-21

    2021-04-21

    第一章 ElasticSearch入门篇第一节 ElasticSearch概述1.1ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RES...

    2024-04-01 02:43:29
  • 大三下学期到大四上学期的IT学习规划

    大三小结: 正如大三上半学期计划的那样, 寒假进行了CCNA课程的预习。 大三下半学期3月1号开始进行了CCNA的培训, 4.28日CCNA以949分通过了考试。 5月中旬开始进行MCITP服务器管理员的培训, 将于8月份结束。 (基础狠差) 在学校中, 6月份开始自学网站的设计和管理。 计划在7月份学完dreamwave和firework软件。 在7月9日考完课程考试后,

    2024-04-01 02:43:24