Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWTP No Default Constructor For Interface

Tags:

gwt

gwt-gin

gwtp

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.

like image 729
Peter L Avatar asked May 27 '14 07:05

Peter L


1 Answers

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.
like image 186
Peter L Avatar answered Oct 18 '22 07:10

Peter L