Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT Deferred binding failed for custom class: No class matching "..." in urn:import:

I am developing a couple of custom widgets that I would like to be able to use with UiBinder. Unfortunately I keep wasting my life away with chasing down the following error:

No class matching "..." in urn:import:...

This seems to be the catch-all exception that is thrown any time there is any error in the class that prevents the GWT compiler from processing it. This includes anything in the class's entire dependency tree.

To save myself and anyone of you who is running into the same issue some time and pain, let's compile a list here of the most unexpected and hard to find causes for this. I'll start with my latest one, which has made me decide to post this here.

like image 770
Markus A. Avatar asked Nov 06 '12 03:11

Markus A.


3 Answers

I was using a CellList thusly:

private static RelationshipViewerUiBinder uiBinder = GWT.create(RelationshipViewerUiBinder.class);

@UiField(provided=true)
CellList<String> prioritisedDisplay;

public RelationshipViewer() {

    prioritisedDisplay = new CellList<>(new TextCell());
    initWidget(uiBinder.createAndBindUi(this));
}

note the Java 7 style <> on the CellList. Despite my IDE's protestations to the contrary, it turns out you DO need to explicitly say CellList< String> in that new call, or it wont compile and all you get is the above mentioned error. Thanks by the way, the existance of this question prompted me to scrutinise my code and probably saved me a couple of hours! This fixed it:

private static RelationshipViewerUiBinder uiBinder = GWT.create(RelationshipViewerUiBinder.class);

@UiField(provided=true)
CellList<String> prioritisedDisplay;

public RelationshipViewer() {

    prioritisedDisplay = new CellList<String>(new TextCell());
    initWidget(uiBinder.createAndBindUi(this));
}
like image 109
Joseph Rogers Avatar answered Nov 15 '22 11:11

Joseph Rogers


I had written a component that used the GWT JSON functionality, but hadn't imported com.google.gwt.json.JSON into the module.

Thanks to your message here, this was only 2 hours down the drain...

like image 39
JaysonRaymond Avatar answered Nov 15 '22 11:11

JaysonRaymond


I wrote a helper-class that this widget uses somewhere deep inside its dependency tree.

For this helper-class, I told Eclipse to auto-generate the hashCode() and equals(...) functions. The class contained a field of type double, for which Eclipse generates code that uses Double.doubleToLongBits().

Turns out GWT does not implement this method on its version of Double. But of course, neither does Eclipse detect this as a possible compile-error, nor does it cause any issues in Dev Mode if I use the widget inside the GWT-App's Java code rather than inside UiBinder.

3 hours down the drain... Great... Yay for helpful error messages.

UPDATE:

As of GWT 2.5.0 (RC1) GWT now supports Double.doubleToLongBits() rendering this particular error obsolete, but the general error mechanism of a missing JRE emulation remains and will probably manifest itself in a similarly unhelpful way.

like image 20
Markus A. Avatar answered Nov 15 '22 10:11

Markus A.