Proxy generation problem when Presenter contains a reference to PresenterWidget

2,214 views
Skip to first unread message

Otto Chrons

unread,
May 24, 2013, 12:00:53 PM5/24/13
to gwt-pl...@googlegroups.com
(Using GWTP 1.0 RC3)

I got a really weird problem when trying to inject PresenterWidgets into a Presenter. I reduced the problem to the following:

public class TestPresenter extends Presenter<TestPresenter.MyView, TestPresenter.MyProxy> {
    @ProxyStandard
    @NameToken(NameTokens.workspace)
    public interface MyProxy extends ProxyPlace<TestPresenter> {
    }

    public interface MyView extends View {
    }

    private KeyingTaskPresenter keyingPresenter;

    @Inject
    public TestPresenter(EventBus eventBus, MyView view, MyProxy proxy) {
        super(eventBus, view, proxy);
    }
}

This will cause the following error:

[DEBUG] [client] - Rebinding com.gwtplatform.mvp.client.DesktopGinjector
[DEBUG] [client] - Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
[ERROR] [client] - Error injecting xxx.TestPresenter$MyProxy: Unable to create or inherit binding: No @Inject or default constructor found for xxx.TestPresenter$MyProxy
  Path to required node:

xxx.TestPresenter$MyProxy [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:124)]


Now, if I remove the KeyingTaskPresenter definition, it works just fine. Also replacing the KeyingTaskPresenter (which extends PresenterWidget, not Presenter) with a normal Presenter causes no problems.

KeyingTaskPresenter is defined as:
public class KeyingTaskPresenter extends
        BaseTaskPresenter<KeyingTaskDTO, KeyingTaskResultDTO, KeyingTaskPresenter.MyView> implements
        KeyingTaskUiHandlers {
....

and the parent BaseTaskPresenter as:

public abstract class BaseTaskPresenter<T extends TaskDTO, R extends TaskResultDTO, V extends BaseTaskPresenter.MyView<? extends BaseTaskUiHandlers>>
        extends PresenterWidget<V> implements BaseTaskUiHandlers {

    public interface MyView<H extends BaseTaskUiHandlers> extends View, HasUiHandlers<H> {
....

I'm binding the KeyingTaskPresenter like this:

        bindSingletonPresenterWidget(KeyingTaskPresenter.class, KeyingTaskPresenter.MyView.class, KeyingTaskView.class);


and the TestPresenter using the normal bindPresenter:

        bindPresenter(TestPresenter.class, TestPresenter.MyView.class, TestView.class, TestPresenter.MyProxy.class);


Any ideas what might be going wrong with the Proxy generation?

- Otto


Otto Chrons

unread,
May 24, 2013, 1:11:40 PM5/24/13
to gwt-pl...@googlegroups.com
Ok, did a little more digging and isolated the problem. I had a TaskCache class referenced from the BaseTaskPresenter and in this class I used a LinkedList. Unfortunately I was using the pop() method of the LinkedList, which exists in Java 1.6 but not in GWT. This was causing the weird Proxy generation problem! Replacing the pop() with removeFirst() fixed everything :)

- Otto

Christian Goudreau

unread,
Jun 3, 2013, 3:53:49 PM6/3/13
to gwt-pl...@googlegroups.com
Great to hear! Glad that you found your problem :D


--
You received this message because you are subscribed to the Google Groups "GWTP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gwt-platform...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Christian Goudreau

Otto Chrons

unread,
Jun 27, 2013, 7:08:29 AM6/27/13
to gwt-pl...@googlegroups.com
Encountered the same problem in a bit different situation. Now the reason was a missing class (it was under a mock source tree that was not included in the production compilation).

I believe the problem is due to code generation happening earlier than actual compilation, which hides the real error. Without the code generation, the real error (missing method or class) would be displayed, but now the compilation process never gets that far.

Perhaps the GWTP code generation logic could be modified to give a more detailed error message, with the real reason for the failure in binding.

- Otto

Axel R

unread,
Jul 6, 2013, 6:56:42 PM7/6/13
to gwt-pl...@googlegroups.com
Hello,

I also have an error of kind : 

No @Inject or default constructor found for com.MS.client.application.events._Events_Presenter$MyProxy

I do not know what I am missing and I am actually trying to debug my error... : 

Here is the complete message :

   Computing all possible rebind results for 'com.gwtplatform.mvp.client.DesktopGinjector'
      Rebinding com.gwtplatform.mvp.client.DesktopGinjector
         Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
            [WARN] Class javax.ws.rs.DELETE is used in Gin, but not available in GWT client code.
            [WARN] Class javax.ws.rs.Path is used in Gin, but not available in GWT client code.
            [WARN] Class javax.ws.rs.POST is used in Gin, but not available in GWT client code.
            [WARN] Class javax.ws.rs.GET is used in Gin, but not available in GWT client code.
            [ERROR] Error injecting com.MS.client.application.events._Events_Presenter$MyProxy: Unable to create or inherit binding: No @Inject or default constructor found for com.MS.client.application.events._Events_Presenter$MyProxy
  Path to required node:

com.MS.client.application.events._Events_Presenter$MyProxy [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:124)]

            [ERROR] Error injecting com.MS.client.application.events.Events_View$Binder: Unable to create or inherit binding: No @Inject or default constructor found for com.MS.client.application.events.Events_View$Binder
  Path to required node:

com.MS.client.application.events.Events_View [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:123)]
 -> com.MS.client.application.events.Events_View$Binder [@Inject constructor of com.MS.client.application.events.Events_View]

   [ERROR] Errors in 'gen/com/gwtplatform/mvp/client/DesktopGinjectorProvider.java'
      [ERROR] Line 8: Failed to resolve 'com.gwtplatform.mvp.client.DesktopGinjector' via deferred binding
   [WARN] For the following type(s), generated source was never committed (did you forget to call commit()?)
      [WARN] com.gwtplatform.mvp.client.com_gwtplatform_mvp_client_DesktopGinjectorImpl


Could you help me ?

Axel R

unread,
Jul 6, 2013, 7:24:40 PM7/6/13
to gwt-pl...@googlegroups.com
Now it works, I had to delete my src folder (#1), and replace it with the src folder (#2) I backuped yesturday.
Then I was able to compile my project and to launch it...I finally have replaced again the src folder (#2) with the good one (#1).

So the only thing I can say, is that, after I have deleted some files generated by the compiler (cf. using super dev mode, there is lot of files created and using disk space....), I may encounter a problem to compile again my project. I do not know why, but that is true that most of the time I have this error message talking about "No @Inject or default constructor found for ...$Proxy"

Regards,

Axel R

unread,
Jul 6, 2013, 7:59:49 PM7/6/13
to gwt-pl...@googlegroups.com
Ok, sorry for the various posts....
I have precisely detected the error, I was using GWT MAP, and the error was because I call a code relative to gwt map and I had commented the line <inherits name='com.google.gwt.maps.Maps' />

So, yes, if the compiler could give the line where the error appears when generating presenter's proxy, it should help....

Christian Goudreau

unread,
Jul 7, 2013, 10:52:29 AM7/7/13
to gwt-pl...@googlegroups.com
Unable to create or inherit bindingNo @Inject or default constructor found for
This message come from Gin and is often an indication that something is not correctly bound or a dependency is missing form the parent.

Better logging is also one of our objective 


--
You received this message because you are subscribed to the Google Groups "GWTP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gwt-platform...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Christian Goudreau | CEO - Président
M: 1.877.635.1585 | S: christian.goudreau

Otto Chrons

unread,
Jul 7, 2013, 2:08:25 PM7/7/13
to gwt-pl...@googlegroups.com
One way to debug these is to temporarily remove the presenter binding call from your module definition. This will prevent the gwtp code generation phase for the presenter and will reveal the actual error message.

- Otto


--
You received this message because you are subscribed to a topic in the Google Groups "GWTP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gwt-platform/6C-EdZgmshU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gwt-platform...@googlegroups.com.

Martin Trummer

unread,
Oct 7, 2013, 10:22:07 AM10/7/13
to gwt-pl...@googlegroups.com
FYI:
I've just had kind of the same problem 
[ERROR] [webApp] - Error injectingXXX.ApplicationView$Binder: Unable to create or inherit binding: No @Inject or default constructor found for XXX.ApplicationView$Binder
Path to required node:
XXX.ApplicationView [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:123)]
-> XXX.ApplicationView$Binder [@Inject constructor of XXX.ApplicationView]

turned out, that the problem was using the java 7 diamond operator:
@ContentSlot
public static final Type<RevealContentHandler<?>> TYPE_SetMainContent = new Type<>();

AFAIK, GWT >= 2.6 will support java 7 - until then it's best to use a java 6 compiler which will force you to use the explicit version:
public static final Type<RevealContentHandler<?>> TYPE_SetMainContent = new Type<RevealContentHandler<?>>();

peter...@freshcode.biz

unread,
May 28, 2014, 12:25:36 AM5/28/14
to gwt-pl...@googlegroups.com
FYI, my error was caused by putting a non-IsSerializable class inside a Result wrapper.
See http://stackoverflow.com/questions/23883527/gwtp-no-default-constructor-for-interface/

peter...@freshcode.biz

unread,
May 28, 2014, 12:28:49 AM5/28/14
to gwt-pl...@googlegroups.com
NOTE: Don't comment out all the bindings in your module definition.  You'll get a whole raft of other errors that look similar.

Pete

Tushar Bhasme

unread,
Nov 18, 2014, 10:08:38 PM11/18/14
to gwt-pl...@googlegroups.com
Was facing the same issue. Just figured out I had mistakenly referenced server entity class in client VO. It took me a lot of time to debug this. We really need a more detailed error message for such minor issues.
Reply all
Reply to author
Forward
0 new messages