sun.reflect.annotation.TypeNotPresentExceptionProxy exception after adding EntityListeners

a 夏天 提交于 2019-12-10 18:48:19

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/12301302/sun-reflect-annotation-typenotpresentexceptionproxy-exception-after-adding-entit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!