We are trying to develop a mobile application using GWT 2.4 , but now it seems that I hit the wall and cannot solve the problem.
We wrote 4 types of Overlay for the data that we get from the server as JSON and 1 Overlay Type with static utility functions.
Depending on where we use this utility function, we get this error:
java.lang.ClassFormatError: Illegal method name "<init>$" in class com/our/company/DataUtil at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:1085) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... ... ...
Things I tested:
- Calling various methods from DataUtil in a module that is loaded via deferred binding
Result: no matter what method is called, an error appears during compilation with an additional message:
[ERROR] [wwapp] Failed to create an instance of'com.our.company.mobileapp.client.model.data.GimmeData' via deferred binding
- Calling methods from DataUtil in actions:
Result: an error appears at runtime as a warning popup.
Let me quickly illustrate all the relevant classes:
DataUtil → Overlay Type
AData → Overlay Type
BData → Overlay Type
CData → Overlay Type
DData → Overlay Type
A -
B -
C -
D → corresponding data types as “pure” Java classes
This is a simplified version of the DataUtil class:
public final class DataUtil extends JavaScriptObject { protected DataUtil() { } private final native static JsArray<AData> asArrayOfAData( String json ) ; private final static native BData asBData( String json ) ; private final static native JsArray<CData> asArrayOfCData( String json ) ; private final static native JsArray<DData> asArrayOfDData( String json ) ; public final static List<A> getListOfAs( String json ) { JsArray<AData> arr = asArrayOfAData( json ); List<A> list = new ArrayList<A>(); for ( int i = 0; i < arr.length(); ++i ) { list.add( arr.get( i ).asA() ); } return list; } public final static B getB( String json ) { return asBData( json ).asB(); } public final static List<C> getListOfC( String json ) { JsArray<CData> arr = asArrayOfCData( json ); List<C> list = new ArrayList<C>(); for ( int i = 0; i < arr.length(); ++i ) { list.add( arr.get( i ).asC() ); } return list; } public final static List<D> getListOfD( String json) { JsArray<DData> arr = asArrayOfDData( json); List<D> list = new ArrayList<D>(); for ( int i = 0; i < arr.length(); ++i ) { list.add( arr.get( i ).asD() ); } return list; } }
If necessary, I will also publish other types of overlays. I really hope someone came across and solved this earlier, thanks a lot in advance, if so;).
As requested I will send full classes. I just deleted comments, imports and packages.
JSData
(Formerly DataUtil
):
public final class JSData extends JavaScriptObject { protected JSData() { } private final native static JsArray<POIData> asArrayOfPOIData( String json ) ; private final static native UserData asUserData( String json ) ; private final static native JsArray<CategoryData> asArrayOfCategoryData( String json ) ; private final static native JsArray<RouteData> asArrayOfRouteData( String json ) ; public final static List<WWCategory> getListOfCategories( String json ) { JsArray<CategoryData> arr = asArrayOfCategoryData( json ); List<WWCategory> list = new ArrayList<WWCategory>(); for ( int i = 0; i < arr.length(); ++i ) { list.add( arr.get( i ).asWWCategory() ); } return list; } public final static List<WWPOI> getListOfPOIs( String json ) { JsArray<POIData> arr = asArrayOfPOIData( json ); List<WWPOI> list = new ArrayList<WWPOI>(); for ( int i = 0; i < arr.length(); ++i ) { list.add( arr.get( i ).asWWPOI() ); } return list; } public final static WWUser getUser( String json ) { return asUserData( json ).asWWUser(); } public final static List<WWRoute> getListOfRoutes( String routesJSON ) { JsArray<RouteData> arr = asArrayOfRouteData( routesJSON ); List<WWRoute> list = new ArrayList<WWRoute>(); for ( int i = 0; i < arr.length(); ++i ) { list.add( arr.get( i ).asWWRoute() ); } return list; } }
UserData
:
public final class UserData extends JavaScriptObject { protected UserData() { } private static final Logger log = Logger.getLogger( "com.isp.wwapp.core.client.model.jsdata.UserData" ); public final String getUserName() { String benutzername_js = getUserName_JS(); String benutzername = Utils.unescape( benutzername_js ); return benutzername; } private final native String getUserName_JS() ; public final String getName() { String vorname_js = getName_JS(); String vorname = Utils.unescape( vorname_js ); log.info( vorname ); return vorname; } private final native String getName_JS() ; public final String getSurname() { String nachname_js = getSurname_JS(); String nachname = Utils.unescape( nachname_js ); log.info( nachname ); return nachname; } private final native String getSurname_JS() ; public final Boolean getGender() { String geschlecht_js = getGender_JS(); Boolean geschlecht = null; geschlecht = geschlecht_js.equals( "w" ); return geschlecht; } private final native String getGender_JS() ; public final String getNickname() { String nickname_js = getNickname_JS(); String nickname = Utils.unescape( nickname_js ); return nickname; } private final native String getNickname_JS() ; public final Date getBirthday() { String geburtstag_js = getBirthday_JS(); Date geburtstag = null; try { geburtstag = DateTimeFormat.getFormat( "yyyy-MM-dd" ).parse( geburtstag_js ); } catch ( IllegalArgumentException e ) { log.log( Level.SEVERE, "Das Geburtsdatum konnte nicht richtig geparst werden.", e ); } return geburtstag; } private final native String getBirthday_JS() ; public final String getPassword() { String passwort_crypt_js = getPassword_JS(); String passwort_crypt = Utils.unescape( passwort_crypt_js ); log.info( passwort_crypt ); return passwort_crypt; } private final native String getPassword_JS() ; public final String getStreet() { String strasse_js = getStreet_JS(); String strasse = Utils.unescape( strasse_js ); return strasse; } private final native String getStreet_JS() ; public final String getStreetNumber() { String hausnr_js = getStreetNumber_JS(); String hausnr = Utils.unescape( hausnr_js ); return hausnr; } private final native String getStreetNumber_JS() ; public final String getZIP() { String plz_js = getZIP_JS(); String plz = Utils.unescape( plz_js ); return plz; } private final native String getZIP_JS() ; public final String getDistrict() { String ortsteil_js = getDistrict_JS(); String ortsteil = Utils.unescape( ortsteil_js ); return ortsteil; } private final native String getDistrict_JS() ; public final String getLocation() { String ort_js = getLocation_JS(); String ort = Utils.unescape( ort_js ); return ort; } private final native String getLocation_JS() ; public final String getState() { String landesteil_js = getState_JS(); String landesteil = Utils.unescape( landesteil_js ); return landesteil; } private final native String getState_JS() ; public final String getRegion() { String region_js = getRegion_JS(); String region = Utils.unescape( region_js ); return region; } private final native String getRegion_JS() ; public final String getCountry() { String landname_js = getCountry_JS(); String landname = Utils.unescape( landname_js ); return landname; } private final native String getCountry_JS() ; public final String getImageURL() { String foto_js = getImageURL_JS(); String foto = Utils.unescape( foto_js ); return foto; } private final native String getImageURL_JS() ; public final String getWebsite() { String webseite_js = getWebsite_JS(); String webseite = Utils.unescape( webseite_js ); return webseite; } private final native String getWebsite_JS() ; public final Integer getDbId() { String idBenutzer_js = getDbId_JS(); Integer idBenutzer = null; idBenutzer = Integer.parseInt( idBenutzer_js ); return idBenutzer; } private final native String getDbId_JS() ; public final String getEmail() { String email_js = getEmail_JS(); String email = Utils.unescape( email_js ); return email; } private final native String getEmail_JS() ; public final String getTel() { String festnetz_js = getTel_JS(); String festnetz = Utils.unescape( festnetz_js ); return festnetz; } private final native String getTel_JS() ; public final String getMobile() { String mobil_js = getMobile_JS(); String mobil = Utils.unescape( mobil_js ); return mobil; } private final native String getMobile_JS() ; public final String getIMEI() { String imei_js = getIMEI_JS(); String imei = imei_js; log.info( imei ); return imei; } private final native String getIMEI_JS() ; public final String getFax() { String fax_js = getFax_JS(); String fax = Utils.unescape( fax_js ); return fax; } private final native String getFax_JS() ; public final String getSkype() { String skype_js = getSkype_JS(); String skype = Utils.unescape( skype_js ); return skype; } private final native String getSkype_JS() ; public final String getICQ() { String icq_js = getICQ_JS(); String icq = Utils.unescape( icq_js ); return icq; } private final native String getICQ_JS() ; public final String getTwitter() { String twitter_js = getTwitter_JS(); String twitter = Utils.unescape( twitter_js ); return twitter; } private final native String getTwitter_JS() ; public final Integer getMyPoiDbID() { String persPoi_js = getMyPoi_JS(); Integer persPoiId = null; try { persPoiId = Integer.parseInt( persPoi_js ); } catch ( NumberFormatException e ) { log.log( Level.SEVERE, "Fehler beim Parsen der POI Datenbank-Id.", e ); } return persPoiId; } private final native String getMyPoi_JS() ; public final WWUser asWWUser() { Contact con = new Contact( this.getEmail(), this.getTel(), this.getMobile() );
POIData
:
public class POIData extends JavaScriptObject { private final Logger log = Logger.getLogger( "com.isp.wwapp.core.client.model.jsdata.POIData" ); protected POIData() { } public final Integer getDbId() { Integer dbid = null; String dbid_js = getDbId_JS(); try { dbid = Integer.parseInt( dbid_js ); } catch ( NumberFormatException nfe ) { log.log( Level.INFO, "Die Datenbank-ID " + dbid_js + " konnte nicht in ein Integer geparst werden.", nfe ); } return dbid; } private final native String getDbId_JS() ; public final String getLabel() { return Utils.unescape( getLabel_JS() ); } private final native String getLabel_JS() ; public final String getDescription() { return Utils.unescape( getDescription_JS() ); } private final native String getDescription_JS() ; public final Double getLongitude() { Double lon = null; String lon_js = getLongitude_JS(); try { lon = Double.parseDouble( lon_js ); } catch ( NumberFormatException nfe ) { log.log( Level.SEVERE, "Die Longitude " + lon_js + " konnte nicht in ein Double geparst werden.", nfe ); } return lon; } private final native String getLongitude_JS() ; public final Double getLatitude() { Double lat = null; String lat_js = getLatitude_JS(); try { lat = Double.parseDouble( lat_js ); } catch ( NumberFormatException nfe ) { log.log( Level.SEVERE, "Die Latitude " + lat_js + " konnte nicht in ein Double geparst werden.", nfe ); } return lat; } private final native String getLatitude_JS() ; public final String getStreet() { return Utils.unescape( getStreet_JS() ); } private final native String getStreet_JS() ; public final String getStreetNumber() { return Utils.unescape( getStreetNumber_JS() ); } private final native String getStreetNumber_JS() ; public final String getZIP() { return Utils.unescape( getZIP_JS() ); } private final native String getZIP_JS() ; public final String getLocation() { return Utils.unescape( getLocation_JS() ); } private final native String getLocation_JS() ; public final String getCountry() { return Utils.unescape( getCountry_JS() ); } private final native String getCountry_JS() ; public final String getDistrict() { return Utils.unescape( getDistrict_JS() ); } private final native String getDistrict_JS() ; public final String getState() { return Utils.unescape( getState_JS() ); } private final native String getState_JS() ; public final String getRegion() { return Utils.unescape( getRegion_JS() ); } private final native String getRegion_JS() ; public final String getURL() { return Utils.unescape( getURL_JS() ); } private final native String getURL_JS() ; public final String getContactEmail() { return Utils.unescape( getContactEmail_JS() ); } private final native String getContactEmail_JS() ; public final String getContactTel() { return Utils.unescape( getContactTel_JS() ); } private final native String getContactTel_JS() ; public final String getContactMobile() { return Utils.unescape( getContactMobile_JS() ); } private final native String getContactMobile_JS() ; public final String getContactFax() { return Utils.unescape( getContactFax_JS() ); } private final native String getContactFax_JS() ; @Deprecated public final List<String> getCategoryLabels() { JsArrayString labelsArray = getCategoryLabels_JS(); List<String> labelsList = new ArrayList<String>(); for ( Integer i = 0; i < labelsArray.length(); ++i ) { labelsList.add( Utils.unescape( labelsArray.get( i ) ) ); } return labelsList; } private final native JsArrayString getCategoryLabels_JS() ; public final List<WWCategory> getCategories() { List<WWCategory> cats = new ArrayList<WWCategory>(); JsArray<CategoryData> cats_js = getCategories_JS(); for ( Integer i = 0; i < cats_js.length(); ++i ) { cats.add( cats_js.get( i ).asWWCategory() ); } return cats; } private final native JsArray<CategoryData> getCategories_JS() ; public final Date getLastModified() { String geaendertAm_js = getLastModified_JS(); Date geaendertAm = null; DateTimeFormat wwDTFormat = DateTimeFormat.getFormat( "yyyy-MM-dd HH:mm:ss" ); try { geaendertAm = wwDTFormat.parse( geaendertAm_js ); } catch ( IllegalArgumentException e ) { log.log( Level.SEVERE, "Parsen des Datums " + geaendertAm_js + "ist fehlgeschlagen.", e ); } return geaendertAm; } private final native String getLastModified_JS() ; public final int getPosition() { String position_js = getPosition_JS(); int position = 0; try { position = Integer.parseInt( position_js ); } catch ( NumberFormatException e ) { log.log( Level.SEVERE, "Fehler beim Parsen der Position des POIs.", e ); } return position; } private final native String getPosition_JS() ; public final WWPOI asWWPOI() { WWPOI poi = new WWPOI( this.getDbId(), this.getLatitude(), this.getLongitude(), this.getLabel() ); poi.setDescription( this.getDescription() ); poi.setUrl( this.getURL() ); poi.setPosition( this.getPosition() ); Address adr = new Address(); adr.setCountry( this.getCountry() ); adr.setDistrict( this.getDistrict() ); adr.setLocation( this.getLocation() ); adr.setZip( this.getZIP() ); adr.setState( this.getState() ); adr.setStreet( this.getStreet() ); adr.setStreetNumber( this.getStreetNumber() ); poi.setAddress( adr ); Contact con = new Contact(); con.setEmail( this.getContactEmail() ); con.setFax( this.getContactFax() ); con.setTel( this.getContactTel() ); con.setMobile( this.getContactMobile() ); poi.setContactData( con ); List<WWCategory> categories = GimmeThatSingleton.getInstance().getCategories(); List<WWCategory> poiCats = this.getCategories(); for ( WWCategory poiCat : poiCats ) { for ( WWCategory cat : categories ) {
RouteData
:
public final class RouteData extends JavaScriptObject { protected RouteData() { } private final Logger log = Logger.getLogger( "com.isp.wwapp.core.client.model.jsdata.RouteData" ); public final String getLabel() { return Utils.unescape( getLabel_JS() ); } private final native String getLabel_JS() ; public final Integer getDbId() { Integer dbid = null; String dbid_js = getDbId_JS(); try { dbid = Integer.parseInt( dbid_js ); } catch ( NumberFormatException nfe ) { log.log( Level.SEVERE, "Die Datenbank-ID " + dbid_js + " konnte nicht in ein Integer geparst werden.", nfe ); } return dbid; } private final native String getDbId_JS() ; public final WWRoute asWWRoute() { WWRoute route = new WWRoute( getDbId(), null, getLabel(), null ); return route; } }
CategoryData
:
public final class CategoryData extends JavaScriptObject { protected CategoryData() { } private final Logger log = Logger.getLogger( "com.isp.wwapp.core.client.model.jsdata.CategoryData" ); public final String getLabel() { return Utils.unescape( getLabel_JS() ); } private final native String getLabel_JS() ; public final String getDescription() { return Utils.unescape( getDescription_JS() ); } private final native String getDescription_JS() ; public final Integer getDbId() { Integer dbid = null; String dbid_js = getDbId_JS(); try { dbid = Integer.parseInt( dbid_js ); } catch ( NumberFormatException nfe ) { log.log( Level.SEVERE, "Die Datenbank-ID " + dbid_js + " konnte nicht in ein Integer geparst werden.", nfe ); } return dbid; } private final native String getDbId_JS() ; public final native Boolean isSubcategory() ; public final native Boolean hasSubcategory() ; public final Integer getParentDbId() { Integer parentdbid = null; String parentdbid_js = getParentDbId_JS(); if ( parentdbid_js == null ) return null; try { parentdbid = Integer.parseInt( parentdbid_js ); } catch ( NumberFormatException nfe ) { log.log( Level.SEVERE, "Die Datenbank-ID " + parentdbid_js + " konnte nicht in ein Integer geparst werden.", nfe ); parentdbid = null; } return parentdbid; } private final native String getParentDbId_JS() ; public final Date getlastModified() { String geaendertAm_js = getlastModified_JS(); Date geaendertAm = null; DateTimeFormat wwDTFormat = DateTimeFormat.getFormat( "yyyy-MM-dd HH:mm:ss" ); try { geaendertAm = wwDTFormat.parse( geaendertAm_js ); } catch ( IllegalArgumentException e ) { log.log( Level.SEVERE, "Parsen des Datums " + geaendertAm_js + "ist fehlgeschlagen.", e ); } return geaendertAm; } private final native String getlastModified_JS() ; public final WWCategory asWWCategory() { WWCategory cat = new WWCategory( this.getParentDbId(), this.getDbId(), this.getLabel() ); cat.setDescrition( this.getDescription() ); return cat; } }