GWT exporter cast exception from GWT.create; Tried to use mvp4g with GWT-Exporter but GWT.create did


I tried to use GWT-Exporter and it worked just fine when I copied the example. Then I tried to export an mvp4g Presenter Here's what I did:

@Export() @Presenter(view = RegisterPluginDisplay.class) public class RegisterPluginPresenterImpl extends BasePresenter<RegisterPluginView, MyBus implements RootPresenter { ... } public interface RegisterPluginPresenter extends Exportable { ... } //then in the start event I said: ExporterUtil.exportAll();

It gave me this error:

Uncaught java.lang.AssertionErrorcom_mvp4g_client_Mvp4gModuleImpl_com_mvp4g_client_Mvp4gModuleGinjector_com_mvp4g_client_Mvp4gModule…:62 get_Key$type$com$joseph$draw4$client$presenter$RegisterPluginPresenterImpl$_annotation$$none$$_0_g$com_mvp4g_client_Mvp4gModuleImpl_com_mvp4g_client_Mvp4gModuleGinjectorImpl.java:34 getcom_joseph_draw4_client_presenter_RegisterPluginPresenterImpl_0_g$Mvp4gModuleImpl.java:101 createAndStartModule_0_g$Mvp4gEntryPoint.java:35 onModuleLoad_5_g$com_00046joseph_00046draw4_00046Draw4JUnit__EntryMethodHolder.java:3 init_2_g$ModuleUtils.java:44 initializeModules_0_g$Impl.java:247 apply_0_g$Impl.java:306 entry0_0_g$Impl.java:72 (anonymous function)ModuleUtils.java:55 gwtOnLoad_0_g$Map.java:29 (anonymous function)

I looked at the code and found that GWT.create() was unsucessful in creating the presenter. I tried to create an exported class and then using GWT.create on it and found that I can't use GWT.create with any class that implements Exportable even if I don't do ExporterUtils.exportAll(). The documentation for the Exportable interface says that the GWT.create() statement returns an Exportable. That explains the class cast exception. So how do I fix this?


mvp4g uses GIN to create instances of presenters. GIN uses GWT.create(YourPresenter.class) to create an instance of the class.

As long as you don't have any deferred binding rule related to YourPresenter class GWT.create will behave like a new in Java.

In cases you are marking anything with the Exporter interface, the GWT Exporter Generator will be triggered. The generator create the exporter implementation which can not be used with mvp4g.


I switched to using the experimental js interop and still got the same problem. Mvp4g uses gin to get the Presenter. According to <a href="https://code.google.com/p/google-gin/wiki/GinTutorial" rel="nofollow">the gin wiki</a> "if GIN can't find a binding for a class, it falls back to calling GWT.create() on that class" in order to instantiate it. It can't use GWT.create on an Exportable because GWT.create(an Exportable) returns an Exporter. Like the documentation says you have to bind the class for it to not use GWT.create. The solution is to <strong>add a binding for the class</strong>. I just had to go in the configure method of my GinModule and add this line of code:


Then I had to create the MyPresenterProvider class:

public static class MyPresenterProvider.class implements Provider<MyPresenter> { @Override public MyPresenter get() { return new MyPresenter(); }


  • EF 4.1 DbContext Generattor - Put Entities in different project?
  • Clarification :MVC,MVP,MVVM
  • TypeScript generating wrong JS in Release Mode
  • Android TV, how to change color of title and color of headeritem?
  • Windows Forms Form hanging after calling show from another thread
  • Error handling in WPF PasswordBox
  • How to Moq this view?
  • Cannot send user message with Spring Websocket
  • Declare PtrSafe Compatibility in Excel
  • How to add plugin dependencies to pom.xml
  • PostgreSQL 9.1 timezones
  • OAuth2 flow for mobile app
  • How to update docker-compose on Docker for Windows?
  • How to reply a tweet using the Twitter gem?
  • iPhone dealing with xml vs soap vs JSON vs RESTful
  • PHP websocket on SSL with proxy_wsTunnel - Apache
  • Adding Client Certifcate to Service Fabric
  • Handling exceptions in a class library enveloping a device driver
  • How to stop a goroutine that is listening for RethinkDB changefeeds?
  • Is the Go HTTP handler goroutine expected to exit immediately in this case?
  • Android gcm notification payload vs data payload?
  • Type Native Wifi.Wlan + WlanReasonCode cannot be marshaled error
  • Telerik Radgrid GridDataItem.DataItem is empty when updating (OnUpdateCommand handler)
  • Spring Boot OAuth2 SSO with access/refresh tokens is not stored in a database correctly
  • Multiple sockets for clients to connect to
  • Catch 500 internal server error with System.WebClient
  • oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Invalid JWT
  • Using an enum contained in a Cloud Endpoint model on a Android client
  • GWT Widget.addHandler
  • Python: sending key press events over SSH
  • Error in making a socket connection
  • What is the difference between a “service account” and an “installed application”?
  • Problem with Django using Apache2 (mod_wsgi), Occassionally is “unable to import from module” for no
  • Python pandas melting data to multiple columns and coulmn names in another column
  • what makes a request a new request in asp.net C#
  • Spring Cloud Microservice Architecture Confusion
  • Transactional Create with Validation in ServiceStack Redis Client
  • Handling un-mapped Rest path
  • Projection media query: browser support and workarounds?
  • PHP - How to update data to MySQL when click a radio button