开发者

A ClassFormatError using StrutsTestCase on NetBeans6.9

I'm trying to use StrutsTestCase to do unit test on my java application using Struts 1.3.8 framework. However, it's quite upset that when I write a test class and try to run it, here comes an error. The error information is given below.

I'm quite confused for when I open the class HttpServletRequestWrapper, there's a red line below the construction method. I use Java-EE-glassfish-v3 as the lib, and when I changed it to Java EE 6 the condition is still the same.

I use Struts 1.3.8 and StrutsTestCase 2.1.4, and my IDE is NetBeans 6.9 and the operating system is Fedora 14 (The Java jdk is OpenJDK). I failed to figure out why this error happens. I would really appreciate it if anyone can give me any help.

Here's the error msg in NetBeans:

Absent Code attribute in method that is not native or abstract in class file javax/servlet/http/HttpServletRequestWrapper java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/http/HttpServletRequestWrapper at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) at java.net.URLClassLoader.access$000(URLClassLoader.java:73) at java.开发者_如何学Pythonnet.URLClassLoader$1.run(URLClassLoader.java:212) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:186)

    at java.lang.ClassLoader.defineClass(ClassLoader.java:634)

My thanks.


Have you defined your main function?
You may try this:

public static void main(String[] args) {
    junit.textui.TestRunner.run(LoginActionTest.class);
}

Hope this can help you.


Looks like a version mismatch.app j2ee version and the version for which struts lib is written should be same.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜