问题描述
我正在调查以下 java.lang.VerifyError
java.lang.VerifyError: (class: be/post/ehr/wfm/application/serviceorganization/report/DisplayReportServlet, method: getMonthData signature: (IILjava/util/Collection;Ljava/util/Collection;Ljava/util/HashMap;Ljava/util/Collection;Ljava/util/Locale;Lorg/apache/struts/util/MessageRe˜̴MtÌ´MÚw€mçw€mp:Â"MŒŒ
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
在部署servlet的jboss服务器启动时发生.它是用 jdk-1.5.0_11 编译的,我尝试用 jdk-1.5.0_15 重新编译它,但没有成功.那就是编译运行良好,但在部署时,发生 java.lang.VerifyError.
It occurs when the jboss server in which the servlet is deployed is started.It is compiled with jdk-1.5.0_11 and I tried to recompile it with jdk-1.5.0_15 without succes. That is the compilation runs fine but when deployed, the java.lang.VerifyError occurs.
当我更改方法名称并收到以下错误时:
When I changed the method name and got the following error:
java.lang.VerifyError: (class: be/post/ehr/wfm/application/serviceorganization/report/DisplayReportServlet, method: getMD signature: (IILjava/util/Collection;Lj ava/util/Collection;Ljava/util/HashMap;Ljava/util/Collection;Ljava/util/Locale;Lorg/apache/struts/util/MessageResources ØÅN|ØÅNÚw€mçw€mX#ÖM|XÔM
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
您可以看到显示了更多的方法签名.
You can see that more of the method signature is shown.
实际的方法签名是
private PgasePdfTable getMonthData(int month, int year, Collection dayTypes,
Collection calendarDays,
HashMap bcSpecialDays,
Collection activityPeriods,
Locale locale, MessageResources resources) throws Exception {
我已经尝试过使用 javap
来查看它,并且它给出了应该的方法签名.
I already tried looking at it with javap
and that gives the method signature as it should be.
当我的其他同事检查代码,编译它并部署它时,他们遇到了同样的问题.当构建服务器获取代码并将其部署到开发或测试环境 (HPUX) 时,会发生同样的错误.运行 Ubuntu 的自动化测试机在服务器启动期间也显示相同的错误.
When my other colleagues check out the code, compile it and deploy it, they have the same problem. When the build server picks up the code and deploys it on development or testing environments (HPUX), the same error occurs. Also an automated testing machine running Ubuntu shows the same error during server startup.
应用程序的其余部分运行正常,只有一个 servlet 出现故障.任何去哪里寻找的想法都会有所帮助.
The rest of the application runs okay, only that one servlet is out of order.Any ideas where to look would be helpful.
推荐答案
java.lang.VerifyError
可能是针对与运行时使用的库不同的库进行编译的结果.
java.lang.VerifyError
can be the result when you have compiled against a different library than you are using at runtime.
例如,当我尝试运行针对 Xerces 1 编译的程序时,就发生了这种情况,但在类路径中发现了 Xerces 2.在运行时找到了所需的类(在 org.apache.*
命名空间中),所以 ClassNotFoundException
是 not结果.类和方法发生了变化,因此在运行时发现的方法签名与编译时存在的方法签名不匹配.
For example, this happened to me when trying to run a program that was compiled against Xerces 1, but Xerces 2 was found on the classpath. The required classes (in org.apache.*
namespace) were found at runtime, so ClassNotFoundException
was not the result. There had been changes to the classes and methods, so that the method signatures found at runtime did not match what was there at compile-time.
通常,编译器会标记方法签名不匹配的问题.JVM 将在类加载时再次验证字节码,并在字节码尝试执行不应允许的操作时抛出 VerifyError
- 例如调用返回 String
的方法,然后将该返回值存储在包含 List
的字段中.
Normally, the compiler will flag problems where method signatures do not match. The JVM will verify the bytecode again when the class is loaded, and throws VerifyError
when the bytecode is trying to do something that should not be allowed -- e.g. calling a method that returns String
and then stores that return value in a field that holds a List
.
这篇关于获取 java.lang.VerifyError 的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!