Question

I am getting an strange error which I cannot get past when using Assisted Injection:

[DEBUG] [project] - Rebinding com.gwtplatform.mvp.client.DesktopGinjector
[DEBUG] [project] - Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
    [ERROR] [project] - Factory com.jorsek.editor.gin.EditorClientFactory could not be created
    [ERROR] [project] - Error injecting com.jorsek.editor.gin.EditorClientFactory: Unable to create or inherit binding: No @Inject or default constructor found for com.jorsek.editor.gin.EditorClientFactory

Path to required node:

com.projectname.client.application.resourceworkspace.ResourceWorkspacePresenter [com.gwtplatform.mvp.client.gin.AbstractPresenterModule.bindPresenter(AbstractPresenterModule.java:122)] -> com.jorsek.editor.gin.EditorClientFactory [@Inject constructor of com.projectname.client.application.resourceworkspace.ResourceWorkspacePresenter]

Here is how I have everything setup:

My factory:

public interface EditorClientFactory {

/**
 * Create a new DOMModel via assisted injection initializing the model 
 * with the document entity and it's DOM document content.
 * 
 * @param document
 * @param domDocument
 * @return
 */
public DOMModel create(Entity document, Document domDocument);
}

My Module:

public class EditorClientModule extends AbstractGinModule {

@Override
protected void configure() {

    install(new GinFactoryModuleBuilder().build(EditorClientFactory.class));

    bind(DOMModel.class).to(SyncedDOMModel.class);
}

}

com.jorsek.editor.impl.SyncedDOMModel:

public class SyncedDOMModel implements DOMModel {



@Inject
private SyncedDOMModel(){} /* For GIN/GUICE */

@AssistedInject
public SyncedDOMModel(CollabClient client, CollabClientFactory collabFactory, @Assisted Entity ref, @Assisted Document domDoc){
    }
}

This is how I am trying to inject my factory for use:

@AssistedInject
public ResourceWorkspacePresenter(final EventBus eventBus, final MyView view, final MyProxy proxy, APIService apiService, EditorClientFactory editorFactory, @Assisted EntityLocator entityLocator) {
    super(eventBus, view, proxy, ApplicationPresenter.TYPE_SetMainContent);


    this.editorFactory = editorFactory;
    this.apiService = apiService;
     System.out.println("E Locator: " + entityLocator);

}

And this is how I am trying to use my factory (Never get this far though):

editorFactory.create(doc, domDoc);

Can anyone see why this would be happening?

I am using GWTP RC2 if that helps.

Thanks,

Casey

Was it helpful?

Solution

Your code is incorrect (I don't know if it'll fix your issue, but it's a start): you shouldn't bind(DOMModel.class) but rather tell the factory:

install(new GinFactoryModuleBuilder()
    .implement(DOMModel.class, SyncedDOMModel.class)
    .build(EditorClientFactory.class));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top