10.2 Inspectors

10.2.1 General Inspectors

My Inspector does not return anything

If your custom Inspector returns no <entity> blocks, or returns <entity> blocks with the wrong type attribute, Metawidget will ignore their result. Try wrapping your Inspector inside CompositeInspector and enabling TRACE logging, to see what your Inspector is returning.

10.2.2 Annotation-Based Inspectors

I get "java.lang.TypeNotPresentException"

If you are using Oracle's implementation of Java, Metawidget's annotation support requires Java 5.0u6 or later, which includes a fix for this bug (Bug Parade ID: 6322301).

My inspector is not finding my annotations

First, if you are using custom annotations check they are marked to 'retain at runtime':

@Retention( RetentionPolicy.RUNTIME )
@Target( { ElementType.FIELD, ElementType.METHOD } )	
public @interface MyAnnotation {

	String value();
}

Next, remember that annotations are designed to 'silently fall away' in environments that do not support them: they never throw ClassDefNotFoundError. For example, if a JPA-annotated class is transferred to an application tier without ejb3-persistence.jar (or equivalent) in its classpath, the JPA annotations will disappear. If this is the case, either add the appropriate JAR to the tier, or consider implementing a remote inspector (see Section 9.1, “Order Properties”).

Finally, note that by default Metawidget discovers annotations placed on public fields and public getter/setter methods, but not on private fields. Metawidget must work with public properties because the various widget libraries, binding frameworks and validation frameworks it wires together all need to access public properties. And because there is no standardized way to infer which private field relates to which public getter/setter method, Metawidget cannot relate the two. Either: