这篇文章主要介绍“怎么解决java.lang.VerifyError问题”,在日常操作中,相信很多人在怎么解决java.lang.VerifyError问题问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么解决java.lang.VerifyError问题”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
测试环境,没有任何改动,启动突然出现这个问题:java.lang.VerifyError
网上搜了大部分的问题,基本判断是jar包重复,或者更本质是class重复导致触发了JVM的安全机制,要求一个jar包的引用必须要在jar包内。
项目有这样的两个jar包,castor-1.2.jar ,castor-xml-1.3.2.jar. 里面的 util文件夹里的类大部分一样,虽然更底层的原理暂不知,但删掉castor-1.2.jar后,
项目运行正常。
为什么删这个?如下面日志:org.castor.xml.AbstractInternalContext类是castor-xml里面的,它引用的org/castor/xml/XMLConfiguration在两个jar包都有
而castor-1.2.jar根本没有引用。
[http-nio-8062-exec-2] [ERROR] [2020-09-28 18:19:34,613] [logid:5d889f01b611462381e9f789b8e84d89] [sessionId:e52cd793-ed3e-457c-8add-9e4cf8b75a78] cn.com.sinosoft.iecs.web.filter.Log4jFilter.doFilter(Log4jFilter.java:52) -执行Log4j过滤器拦截到Controller执行失败,logid: 5d889f01b611462381e9f789b8e84d89 org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.VerifyError: (class: org/castor/xml/XMLConfiguration, method: newInstance signature: ()Lorg/castor/core/util/Configuration;) Incompatible argument to function at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1275) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:951) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at cn.com.sinosoft.iecs.online.core.security.XssCheckFilter.doFilter(XssCheckFilter.java:87) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at cn.com.sinosoft.iecs.web.filter.Log4jFilter.doFilter(Log4jFilter.java:50) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:164) at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at cn.com.sinosoft.iecs.sso.client.util.AssertionThreadLocalFilter.doFilter(AssertionThreadLocalFilter.java:54) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at cn.com.sinosoft.iecs.sso.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at cn.com.sinosoft.iecs.sso.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at cn.com.sinosoft.iecs.sso.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at cn.com.sinosoft.iecs.online.core.security.CookieFilter.doFilter(CookieFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:230) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:745) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.VerifyError: (class: org/castor/xml/XMLConfiguration, method: newInstance signature: ()Lorg/castor/core/util/Configuration;) Incompatible argument to function at org.castor.xml.AbstractInternalContext.<init>(AbstractInternalContext.java:121) at org.castor.xml.BackwardCompatibilityContext.<init>(BackwardCompatibilityContext.java:45) at org.exolab.castor.xml.MarshalFramework.<init>(MarshalFramework.java:185) at org.exolab.castor.xml.Marshaller.<init>(Marshaller.java:322) at cn.com.sinosoft.iecs.online.core.util.CastorUtil.MarshallerXML(CastorUtil.java:50) at cn.com.sinosoft.iecs.online.sale.service.impl.SalesManCheckServiceImpl.getSalesManCheck(SalesManCheckServiceImpl.java:45) at cn.com.sinosoft.iecs.online.sale.service.impl.SalesManCheckServiceImpl$$FastClassBySpringCGLIB$$d9da3df.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) 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.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633) at cn.com.sinosoft.iecs.online.sale.service.impl.SalesManCheckServiceImpl$$EnhancerBySpringCGLIB$$8d051b3.getSalesManCheck(<generated>) at cn.com.sinosoft.iecs.web.sale.ProductSaleActivitController.activit(ProductSaleActivitController.java:214) 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.invoke(InvocableHandlerMethod.java:215) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933) ... 63 more
最后附上搜索得来的结果,是从里面找到线索的:
1、当一个bai jar 文件的 MANIFEST.MF 中已经标记了 Sealed: true 时,这个 jar 内所有的du java package 中的类必zhi须来自这个 jar 包,这是 JVM 的安全措施,配合数字签名就能防止篡改,微软就把它的 SQLServer 驱动程序签名了。比如,JRE 的 rt.jar 就是 Sealed,所以你自己创建一个类 java.lang.MyClass 来运行的话,JVM 是拒绝的。通常情况下,如果你使用了基于动态代理的 AOP,比如 Hibernate 延迟加载或 Spring 的 AOP 就可能因为临时生成的一个子类本身生成在内存中而不是来自某个 jar 包,这时如果这个 jar 包是 Sealed 就无法工作,比如 Microsoft SQLServer JDBC 驱动程序在 Sealed 时你用 Hibernate 的延迟加载就会出错,因为 Hibernate 生成的代理类继承了某个 JDBC 驱动包内的类但这个驱动包是 Sealed,生成的类的包名在驱动名的 jar 中就会出错。
2、可能是类版本错误。这个错误是你说你当前的某个类它引用到的其它类库的版本与这个类在编译时所用的版本不相同 ,比如:你的类 A 用了 c_1.0.jar 中的某个类,编译之后拿到服务器上去用,但服务器上的只有 c_1.1.jar 这个类,它的版本与 c_1.0.jar 某个用到的类略有差异。
到此,关于“怎么解决java.lang.VerifyError问题”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。