简体   繁体   English

类文件javax / servlet / ServletException中不是本机或抽象的方法中的Embedded Jetty Absent Code属性

[英]Embedded Jetty Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException

I am attempting to embed Jetty 9.1.4.v20140401 into my application. 我正在尝试将Jetty 9.1.4.v20140401嵌入到我的应用程序中。 I can get the code to compile, but I get this error when attempt to run the project: 我可以编译代码,但是在尝试运行项目时出现此错误:

Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:144)
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:119)
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:107)
at com.example.WebService.main(WebService.java:82)
Java Result: 1

I am using Netbeans to compile the project, and I am not using Maven. 我正在使用Netbeans来编译项目,并且没有在使用Maven。 Based on other searches I appear to be missing a jar when I attempt to run the code, but I included both the jetty-all and servlet-api jars in my run profile. 基于其他搜索,当我尝试运行代码时,我似乎缺少了一个jar,但是在运行配置文件中同时包含了jetty-all和servlet-api jar。 What do I need to include to get this code to run correctly? 我需要包括什么才能使此代码正确运行? Thanks! 谢谢!

I had this exception when I was running jetty + jersey + atmosphere in a stand alone way. 当我以独立方式运行码头+球衣+大气时,我遇到了这个例外。

These are links that could help: 这些链接可以帮助您:

I will write it down in case the links are fallen (it works for me to solve it) 如果链接断开,我会写下来(它可以解决我的问题)

Root Cause: This is because of javaeeapi.jar present in your build path, for the transaction annotation 根本原因:这是因为在构建路径中存在javaeeapi.jar,用于事务注释

Explanation: The Java EE API jar has been published via a Maven repository. 说明: Java EE API jar已通过Maven存储库发布。 You can compile your code with this jar, but of course you cannnot run your application with it since it contains only the Java EE APIs and does not contain any method bodies. 您可以使用此jar编译代码,但是当然不能使用它运行应用程序,因为它仅包含Java EE API,并且不包含任何方法主体。 If you try to run, you would get this exception. 如果尝试运行,则会出现此异常。

Solution: Remove the javaeeapi.jar from the build path as it doesn't have proper class definition instead only class body 解决方案:从构建路径中删除javaeeapi.jar,因为它没有正确的类定义,而只有类主体

Note: In my case I removed that: 注意:就我而言,我删除了:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
</dependency>

暂无
暂无

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

相关问题 方法中的Absent Code属性在类文件javax / servlet / ServletException中不是本机的或抽象的 - Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException Struts2单元测试给出错误:类文件javax / servlet / ServletException中不是本机或抽象的方法中的缺少Code属性 - Struts2 Unit test gives the error: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException 在类文件javax / faces / webapp / FacesServlet中的非本机或抽象方法中的Absent Code属性 - Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/FacesServlet 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 ClassFormatError:在类文件 javax/mail/MessagingException 中非本机或抽象的方法中缺少代码属性 - ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/MessagingException class 文件 javax/validation/ConstraintViolationException 中非本机或抽象方法中的缺失代码属性 - Absent Code attribute in method that is not native or abstract in class file javax/validation/ConstraintViolationException 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 类文件javax / transaction / SystemException中不是本机或抽象的方法中的缺少Code属性 - Absent Code attribute in method that is not native or abstract in class file javax/transaction/SystemException 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
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM