Guest
Guest

Reputation: 33

sun.reflect.annotation.TypeNotPresentExceptionProxy exception after adding EntityListeners

When an EntityListeners was added to the application using the @EntityListeners(value = {MyEventListener.class}), got the following crash. It looks an issue with reflection. The application has a custom annotation defined for the same entity. Note that this crash only happens after adding the EntityListeners. If the custom annotation is commented the application will still crash. The weird thing is that the same code will work fine when run through the Netbeans debugger. The getAnnotation() call will read all the annotations defined for the entity. The moment I launch the application outside the debugger I get the crash. I haven't been able to find why the class loader cannot find MyEventListener.class.

at sun.reflect.annotation.AnnotationParser.parseClassArray(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseArray(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(Unknown Source)
at java.lang.Class.initAnnotationsIfNecessary(Unknown Source)
at java.lang.Class.getAnnotation(Unknown Source)
at com.feedoffice.FOEDataCache.initializeInternalListeners(FOEDataCache.java:34)
at com.DataCache.<init>(DataCache.java:20)
at com.feedoffice.FOEDataCache.<init>(FOEDataCache.java:16)
at com.feedoffice.ClientDataCache.<init>(ClientDataCache.java:163)
at com.ClientDataCache.<clinit>(ClientDataCache.java:171)
at com.feedoffice.forms.FOENumericTextFieldFactory.<init>(FOENumericTextFieldFactory.java:14)
at com.feedoffice.forms.FOENumericTextFieldFactory.getInstance(FOENumericTextFieldFactory.java:24)
at com.feedoffice.FOEApplet.displayMenu(FOEApplet.java:282)
at com.feedoffice.FOEApplet.loginWindowClosed(FOEApplet.java:215)
at com.feedoffice.forms.AppLogin.submitButtonClicked(AppLogin.java:49)
at com.feedoffice.forms.AppLogin.performSubmitAction(AppLogin.java:106)

Has anyone seen this and knows how to fix it?

Upvotes: 3

Views: 13060

Answers (1)

Manuel Brnjic
Manuel Brnjic

Reputation: 726

The issue is most probably the following: There's some annotation whose value uses a class which isn't in the classpath.

Here is a short exmample:

@MyAnnotation (value = MyClass.class)
public class TestClass

You have to make sure that "Myclass" is available in your classpath. (e.g. by packaging it into your app)

Upvotes: 12

Related Questions