1
votes

I am attempting to scan my entity class for JPA @Column annotation using the code below;

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());
    }
}

But I am getting below exception. I can confirm that I have javax-api jar loaded as part of my dependencies. Do anyone know what I am doing wrong?

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)

1

1 Answers

2
votes

You jar does not contain any method bodies, but only the APIs specification. This is not suitable to use for running or deploying along with your application. Extract the jar open the class in a decompiler you will get to know why it is not running. I am not sure from where you get javax-api jar but you surely need original full version of this jar.