当使用@EntityListeners(value = {MyEventListener.class})将EntityListeners添加到应用程序时,出现以下崩溃。这看起来像是反射的问题。应用程序具有为同一实体定义的自定义注释。请注意,只有在添加EntityListeners之后才会发生这种崩溃。如果自定义注释被注释,应用程序仍然会崩溃。奇怪的是,同样的代码在Netbeans调试器中运行得很好。getAnnotation()调用将读取为实体定义的所有注释。当我在调试器之外启动应用程序的时候,我就崩溃了。我找不到为什么类加载器找不到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)有没有人看过它并知道如何修复它?
发布于 2012-10-11 16:59:28
问题很可能是这样的:有一些注释的值使用了不在类路径中的类。
下面是一个简短的例子:
@MyAnnotation (value = MyClass.class)
public class TestClass您必须确保"Myclass“在您的类路径中可用。(例如,将其打包到您的应用程序中)
https://stackoverflow.com/questions/12301302
复制相似问题