- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用下面的代码扫描我的实体类中的 JPA @Column
注释;
for (Method m : User.class.getMethods())
{
if (m.isAnnotationPresent(javax.persistence.Column.class))
{
javax.persistence.Column column = m.getAnnotation(javax.persistence.Column.class);
System.out.println(column.name());
}
}
但是我遇到了异常。我可以确认我已将 javax-api jar 作为依赖项的一部分加载。有谁知道我做错了什么?
Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/CascadeType 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 java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2442) at java.lang.Class.getDeclaredMethods(Class.java:1808) at sun.reflect.annotation.AnnotationType$1.run(AnnotationType.java:104) at sun.reflect.annotation.AnnotationType$1.run(AnnotationType.java:101) at java.security.AccessController.doPrivileged(Native Method) at sun.reflect.annotation.AnnotationType.(AnnotationType.java:100) at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:84) at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:221) at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88) at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) at java.lang.reflect.Method.declaredAnnotations(Method.java:699) at java.lang.reflect.Method.getAnnotation(Method.java:685) at java.lang.reflect.AccessibleObject.isAnnotationPresent(AccessibleObject.java:189)
最佳答案
您的 jar 不包含任何方法体,而仅包含 API 规范。这不适合与您的应用程序一起运行或部署。提取 jar 文件并在反编译器中打开类,您将了解它为何未运行。我不确定你从哪里获得 javax-api jar,但你肯定需要这个 jar 的原始完整版本。
关于java - 线程中的异常 "main"java.lang.ClassFormatError : Absent Code attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16416375/
从 Eclipse 运行程序时它工作正常。 在 Eclipse 之外运行它时,我得到了这个: java.lang.ClassFormatError: Duplicate method name&si
我尝试在我的网络应用程序中使用小程序。 小程序类: public class TestApplet extends JApplet { @Override public void in
使用 ASM,我将一个方法中的代码替换为另一个方法。该方法称为“checkIfShouldDisconnect”,使用BytecodeOutline插件,我获得了我想要转换的源代码的ASM代码。但是,
我的项目有问题,经过一些测试后我认为它与源代码无关。即使回到以前的工作修订版,我在尝试部署到 Tomcat 时仍然会收到错误消息。 错误是由 java.lang.ClassFormatError 引起
我需要开发一个示例应用程序并将其部署在 Linux 中并进行测试。 问题是我得到了 Exception in thread "main" java.lang.ClassFormatError: com
最近我遇到了这个错误 Caught: java.lang.ClassFormatError: Illegal field modifier in class **** : 0x3 java.lang.
我正在运行一个已部署并在诺基亚 S60 sdk 上运行的 midlet 应用程序。我想让我的应用程序在每个 java 和 symbian 设备上运行。我尝试在 Java_ME_platform_SDK
我正在尝试使用 EMMA 生成代码覆盖率报告使用一些测试 JMockit作为模拟框架。在大多数情况下,它是有效的,但我的一些测试因 ClassFormatError 而崩溃,如下所示: java.la
在研究 Java,特别是字节码编辑时,我偶然发现了 this tutorial ,它指导您完成使用十六进制编辑器编辑已编译的 Java .class 文件的步骤。出于好奇,我尝试了一下。 我确保我输入
我正在创建一个类似于 java.util.LinkedList 的类,但得到了一个完全出乎意料的 ClassFormatError。我的 IDE 没有显示任何警告。仅供引用,我正在使用 Java 8u
欢迎, 我写了简单的测试类形式示例a JavaMail API – Sending email - by mkyong工作完美,但如果我在没有主方法的情况下创建单独的类,如下所示: import co
我正在尝试使用 EMMA 来衡量一些使用 JMockit 的 JUnit 测试的覆盖率。但是当我在使用 EMMA 进行检测后尝试运行 JMockit 测试时,大约四分之一的测试失败并出现以下错误: c
感谢这里的一些帮助。 刚刚安装了Android Studio 1.5.1(使用1.2之后)。然后我创建了一个新项目来尝试并在事件日志中显示以下内容: 7:15:26 PM ClassFormatErr
当我尝试在已注释的 @Controller 方法中使用 @Secured 或 @PreAuthorize 时,抛出了一个奇怪的错误@RequestMapping。当我尝试启动应用程序时(在 win 7
我正在使用Equinox Transforms将一个类替换为类路径上该类的自定义版本。转换机制似乎工作正常,我从转换器类的 public InputStream getInputStream(Inpu
我正在玩《我的世界》,我玩的客户端有一个错误,导致我的《我的世界》在退出后崩溃,所以我想修复这个问题。我反编译客户端并在 NetBeans 中编辑 .java 文件(我编辑得很少),然后将该文件另存为
这个问题在这里已经有了答案: How to properly install and configure JSF libraries via Maven? (1 个回答) 关闭 7 年前。 在我的
我正在使用以下方法从 jar 条目(仅包含类文件)中读取字节。 jar里面没有jar文件。 private List readFromJarFile(File cp) { List cbyte
控制台错误:- Initial SessionFactory creation failed.java.lang.ClassFormatError: Absent Code attribute in
我正在使用 javassist 来更改方法体。当该方法在应用程序中定义时我可以做到这一点。但是,当我想更改应用程序使用的 jar 文件中定义的方法时,我会收到以下运行时错误: javassist.Ca
我是一名优秀的程序员,十分优秀!