简体   繁体   English

类ClassFormatError:方法不是本机的缺少代码属性

[英]Class ClassFormatError :Absent-Code-attribute-in-method-that-is-not-native

I have JSP project run on tomcat 6.0.32 and java 6, that suddenly threw this exception 我在tomcat 6.0.32和java 6上运行了JSP项目,这突然引发了此异常

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file com/company/secure/Account
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
java.lang.ClassLoader.defineClass(ClassLoader.java:615)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
java.lang.Class.getConstructor0(Class.java:2699)
java.lang.Class.newInstance0(Class.java:326)
java.lang.Class.newInstance(Class.java:308)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:150)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:338)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
filters.ObjectsCacheFilter.doFilter(ObjectsCacheFilter.java:43)
filters.FilterCach.doFilter(FilterCach.java:81)
filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:123)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs. note注意在Apache Tomcat / 6.0.32日志中可以找到根本原因的完整堆栈跟踪。 Apache Tomcat/6.0.32 Apache Tomcat / 6.0.32

The problem is due to your webapp (in this case the JSP framework) attempting to load classes from an API-only JAR file. 问题是由于您的Web应用程序(在本例中为JSP框架)试图从仅API的JAR文件中加载类。

Here is another example of the problem (though possibly for a different Java EE API): 这是问题的另一个示例(尽管可能是针对其他Java EE API的):

Explanation: some of the Java EE APIs are available in two forms; 说明:一些Java EE API有两种形式: ie 2 distinct JAR files: 即2个不同的JAR文件:

  • The platform-specific form has code for all of the methods. 特定于平台的表单具有用于所有方法的代码。 This JAR is typically part of the web container, and is included in every web-apps effective classpath by default. 此JAR通常是Web容器的一部分,默认情况下包含在每个Web应用程序有效类路径中。

  • The API-only form has methods that have had their executable code stripped out. 仅API形式的方法已去除了其可执行代码。 This JAR is provided by Oracle to allow you to compile your Java EE application code independently of any specific Java EE implementation. Oracle提供了此JAR,使您可以独立于任何特定的Java EE实现来编译Java EE应用程序代码。

The problem is most likely that you have put one of these API-only JARs onto the runtime classpath of your webapp, and it is taking precedence over the platform-specific JAR. 问题很可能是您将这些仅API的JAR之一放到了Webapp的运行时类路径上,并且它优先于特定于平台的JAR。

Given that this has "happened suddenly", I suspect that you have been changing the Maven dependencies for your project, and (accidentally) made an API-only JAR file a runtime dependency rather than a compile-time-only dependency. 鉴于这种情况“突然发生”,我怀疑您正在更改项目的Maven依赖关系,并且(偶然地)使仅API的JAR文件成为运行时依赖关系,而不是仅使编译时具有依赖关系。

Solution: Check your webapp's Maven (etc) dependencies, or if you are managing the dependencies by hand, check what JARs you have put into the webapp's WEB-INFO/lib directory and the web container's shared libraries directory. 解决方案:检查您Webapp的Maven(etc)依赖关系,或者如果您正在手动管理这些依赖关系,请检查已放入Webapp的WEB-INFO/lib目录和Web容器的共享库目录中的JAR。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.ClassFormatError:在类文件“类名”中非本机或抽象的方法中缺少代码属性 - java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file “name of class” ClassFormatError:在类文件 javax/mail/MessagingException 中非本机或抽象的方法中缺少代码属性 - ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/MessagingException java.lang.ClassFormatError:类文件javax / faces / FacesException中不是本机或抽象的方法中的缺少Code属性 - java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/FacesException java.lang.ClassFormatError:在类文件 javax/mail/MessagingException 中非本机或抽象的方法中缺少代码属性 - java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/MessagingException java.lang.ClassFormatError:类文件javax / mail / internet / ParseException中不是本机或抽象的方法中的缺少Code属性 - java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/internet/ParseException 类文件中不是本机或抽象的方法中的Testng缺少代码属性 - Testng Absent Code attribute in method that is not native or abstract in class file 线程“ main”中的异常java.lang.ClassFormatError:缺少代码属性 - Exception in thread “main” java.lang.ClassFormatError: Absent Code attribute Java EE 6中类文件javax / mail / MessagingException中不是本机或抽象的方法中的缺少Code属性 - Absent Code attribute in method that is not native or abstract in class file javax/mail/MessagingException in Java EE 6 方法中的Absent Code属性在类文件javax / servlet / ServletException中不是本机的或抽象的 - Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException class 文件 javax/validation/ConstraintViolationException 中非本机或抽象方法中的缺失代码属性 - Absent Code attribute in method that is not native or abstract in class file javax/validation/ConstraintViolationException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM