您好,登錄后才能下訂單哦!
這篇文章主要介紹“怎么解決java.lang.VerifyError問題”,在日常操作中,相信很多人在怎么解決java.lang.VerifyError問題問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么解決java.lang.VerifyError問題”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
測試環(huán)境,沒有任何改動,啟動突然出現(xiàn)這個問題:java.lang.VerifyError
網(wǎng)上搜了大部分的問題,基本判斷是jar包重復,或者更本質是class重復導致觸發(fā)了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) -執(zhí)行Log4j過濾器攔截到Controller執(zhí)行失敗,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 中已經(jīng)標記了 Sealed: true 時,這個 jar 內所有的du java package 中的類必zhi須來自這個 jar 包,這是 JVM 的安全措施,配合數(shù)字簽名就能防止篡改,微軟就把它的 SQLServer 驅動程序簽名了。比如,JRE 的 rt.jar 就是 Sealed,所以你自己創(chuàng)建一個類 java.lang.MyClass 來運行的話,JVM 是拒絕的。通常情況下,如果你使用了基于動態(tài)代理的 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問題”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。