users@glassfish.java.net

Unable to use annotations that refer to classes that cannot be loaded

From: <glassfish_at_javadesktop.org>
Date: Tue, 29 Dec 2009 07:18:53 PST

Hi,

When trying to use the newest Vaadin version with Glassfish v3 we have noted that it fails completely due to annotations that refer to classes which in turn cannot be loaded. The idea with the annotation is that during runtime it is only necessary to check if the annotation is present or not, not to check its actual value.

With all other servers we have tested, including Glassfish v2, this works just fine by doing

ClientWidget annotation = class1.getAnnotation(ClientWidget.class);

This will return null or an instance of ClientWidget which contains a sun.reflect.annotation.TypeNotPresentExceptionProxy as its value.
With Glassfish v3 however a RuntimeException is thrown with the message
"WEB9033: Unable to load class with name [com.vaadin.terminal.gwt.client.ui.VView], reason: java.lang.NoClassDefFoundError: com/google/gwt/event/logical/shared/ResizeHandler"

The reason as far as I saw using the debugger (might be completely wrong, never looked at Glassfish or java annotation parser code before) is that the java annotation parser (AnnotationParser.parseClassValue) expects the classloader to throw a NoClassDefFoundError while loading the annotation if there is a problem. This is caught and a new TypeNotPresentExceptionProxy is created. In Glassfish v3 a RuntimeException is thrown instead of the NoClassDefFoundError and this is not caught in the annotation parser.

Any suggestions on how to get around this in Glassfish v3 or how to get it fixed as soon as possible?
[Message sent by forum member 'artur_s' (artur_at_vaadin.com)]

http://forums.java.net/jive/thread.jspa?messageID=377932