GWTP No Default Constructor For Interface
Asked Answered
B

3

7

Can anyone help me solve a problem please?

I'm upgrading from GWT 2.5.1 to 2.6.1 and am getting the following error when trying to run the codeserver of my project...

[INFO] Compiling module <SOME_MODULE>
[INFO]    Validating units:
[INFO]       Ignored 1 unit with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO]    Computing all possible rebind results for 'com.gwtplatform.mvp.client.DesktopGinjector'
[INFO]       Rebinding com.gwtplatform.mvp.client.DesktopGinjector
[INFO]          Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
[INFO]             [ERROR] Error injecting com.gwtplatform.mvp.client.proxy.PlaceManager: Unable to create or inherit binding: No @Inject or default constructor found for com.gwtplatform.mvp.client.proxy.PlaceManager
[INFO]   Path to required node:
[INFO] 
[INFO] com.gwtplatform.mvp.client.proxy.PlaceManager [com.gwtplatform.mvp.client.ClientGinjector#getPlaceManager()]
[INFO] 
[...etc.]

It seems the GIN deferred binding engine is trying to look for constructors on interfaces, which of course do not exist.

Any suggestions would be appreciated. I'm using Maven. http://mojo.codehaus.org/gwt-maven-plugin/

Pete

[EDIT:] This particular error is the result of removing this line from the Gin Module config:

install(new DefaultModule(DefaultPlaceManager.class));

The line was removed to try and trace a similar looking error. Will post a better formal answer when I know more.

Bartley answered 27/5, 2014 at 7:32 Comment(3)
What's your GWTP version?Sippet
GWTP 1.2.1 & GIN 2.1.2 I've tried to reproduce the problem in a learning project without success. The old version of my software would not run in codeserver either. However, Dev Mode is no longer an option for me.Bartley
Have edited question with what I've learned so far.Bartley
B
3

As mentioned at the end of the question, the error resulted from removing an important line from the module config. However, the original error I was trying to fix is all-but identical so my solution may still be useful...

For me, the code was not GWT compiling because of generics. The trouble is the code compiles fine in the IDE but the GWT compile error message gets suppressed and all that is left is '1 unit with compilation errors'.

The steps I used to find were:

  1. Pick the first error and identify the binding that is failing. You might notice a trend for the bindings that fail.
  2. Go to the implementation (presenter / view) and comment out anything non-trivial or remove the parent class. Remember it only needs to compile, it doesn't have to function.
  3. Running a clean+run-codeserver debug cycle will hopefully result in that first error disappearing
  4. Once the error disappears start putting things back. In my case, I found a parent class was causing the error so I duplicated the entire class and saw the compilation errors change from '1 unit' to '2 units'.
  5. Narrow down the code (deleting or commenting out) to find the bad line of code.
  6. You should be able to guess what's wrong from there.
Bartley answered 28/5, 2014 at 4:19 Comment(1)
This seems to be the standard way to investigate and resolve this kind of weird issues. Today, I used some classes in GWT code but forgot to mention <inherits name="xxx"/> in GWT xml file. The compile error output didn't tell me anything useful. I eventually used the steps you mentioned to figure it out and resolve it.Pathoneurosis
R
1

I believe you need to bind your place manager somehow.

Try adding the following line to your module class.

bind(PlaceManager.class).to(DefaultPlaceManager.class).in(Singleton.class);
Rill answered 28/5, 2014 at 13:18 Comment(0)
S
1

In My case the issue was that I was using wrong HashMap implementaion in my View class like below:

Map<String, String> map = new HashMap<String, String>();

The issue was with imported classes. I was importing correct Map interface but wrong HashMap class

The imports were like:

import java.util.Map;
import com.google.gwt.dev.util.collect.HashMap;

I Replaced the HashMap by the following and it worked :)

import java.util.HashMap;
Sherfield answered 18/8, 2017 at 14:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.