2014-11-25 29 views
0

我有以下問題:錯誤注入com.gwtplatform.dispatch.rest.client.ActionMetadataProvider

12:45:47.505 [ERROR] [cGui] Error injecting com.gwtplatform.dispatch.rest.client.ActionMetadataProvider: Unable to create or inherit binding: No @Inject or default constructor found for com.gwtplatform.dispatch.rest.client.ActionMetadataProvider 
Path to required node: 

com.gwtplatform.dispatch.rest.client.RestRequestBuilderFactory [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:100)] 
->; com.gwtplatform.dispatch.rest.client.DefaultRestRequestBuilderFactory [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:100)] 
->; com.gwtplatform.dispatch.rest.client.ActionMetadataProvider [@Inject constructor of com.gwtplatform.dispatch.rest.client.DefaultRestRequestBuilderFactory] 

gwt.xml

<?xml version='1.0' encoding='UTF-8'?> 
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.6.1//EN" 
    "https://raw.githubusercontent.com/gwtproject/gwt/2.6.1/distro-source/core/src/gwt-module.dtd"> 
<module rename-to="cGui"> 
<!-- Inherit the core Web Toolkit stuff. --> 
<inherits name='com.google.gwt.user.User' /> 
<inherits name='com.google.gwt.inject.Inject' /> 

<!-- Default css --> 
<inherits name='com.google.gwt.user.theme.standard.Standard' /> 
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> 
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> 

<!-- Other module inherits --> 
<inherits name='com.gwtplatform.dispatch.Dispatch' /> 
<inherits name='com.gwtplatform.mvp.MvpWithEntryPoint' /> 
<!-- <inherits name="de.barop.gwt.PushState" /> --> 

<inherits name='com.gwtplatform.dispatch.rest.DispatchRest' /> 
<inherits name="com.google.gwt.uibinder.GinUiBinder" /> 
<!-- <inherits name="com.gwtplatform.mvp.MvpWithFormFactor" /> --> 

<inherits name="com.google.gwt.query.Query" /> 
<inherits name="com.google.common.collect.Collect" /> 
<!-- <inherits name="com.googlecode.objectify.Objectify" /> --> 
<inherits name="com.gwtplatform.dispatch.rpc.DispatchRpc" /> 

<source path='client' /> 
<source path='shared' /> 

<set-configuration-property name="gin.ginjector.modules" 
    value="*CENSORED*.client.gin.ClientModule" /> 
</module> 

ClientModule.java

public class ClientModule extends AbstractPresenterModule { 

private static Logger logger = Logger.getLogger(ClientModule.class.getName()); 

@Override 
protected void configure() { 
    logger.log(Level.INFO, "Installing Client Module dependencies"); 
    install(new DefaultModule()); 
    logger.log(Level.INFO, "DefaultModule installed"); 
    install(new SecurityModule()); 
    logger.log(Level.INFO, "SecurityModule installed"); 
    install(new ApplicationModule()); 
    logger.log(Level.INFO, "ApplicationModule installed"); 
    install(new RestDispatchAsyncModule()); 
    logger.log(Level.INFO, "RestDispatchAsyncModule installed"); 
    install(new RpcDispatchAsyncModule()); 
    logger.log(Level.INFO, "RpcDispatchAsyncModule installed"); 
    // DefaultPlaceManager Places 
    bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.LOGIN); 
    bindConstant().annotatedWith(ErrorPlace.class).to(NameTokens.ERROR); 
    bindConstant().annotatedWith(UnauthorizedPlace.class).to(NameTokens.UNAUTHORIZED); 
    bindConstant().annotatedWith(RestApplicationPath.class).to("/rest"); 
    } 
} 

的代碼是基於在ArcBees carstore標籤1.3.1

我的依賴關係:pastebin.com

有什麼我想:

我確信每一個枚舉和DTO是可序列化

試過擺弄gwt.xml

Google搜索了很多

過去5個小時我一直在努力。

如果我忘記附上一些文件,或者沒有提供足夠的細節,請告訴我。我會相應地更新這篇文章。

回答

2

在您的gwt.xml中,DispatchRest必須在之前MvpWithEntryPoint。你應該在這裏閱讀的重要注意事項,因爲所有的陷阱解釋:https://github.com/ArcBees/GWTP/wiki/Rest-Dispatch#add-rest-dispatch-to-your-gwt-module

<!-- Other module inherits --> 
<inherits name='com.gwtplatform.dispatch.rpc.DispatchRpc' /> 
<inherits name='com.gwtplatform.dispatch.rest.DispatchRest' /> 
<inherits name='com.gwtplatform.mvp.MvpWithEntryPoint' /> 
<inherits name="com.google.gwt.uibinder.GinUiBinder" /> 

<extend-configuration-property name="gin.ginjector.modules" 
    value="*CENSORED*.client.gin.ClientModule" /> 

而且Dispatch是棄用的模塊,所以你應該使用DispatchRpc代替。

+0

非常感謝。很好的解答。 :) – q99 2014-11-25 13:55:50

+0

這個答案也幫了我。它不僅適用於MvpWithEntryPoint,還適用於常規的com.gwtplatform.mvp.Mvp。結果列入順序很重要。你可能會節省幾個小時。 – 2016-01-04 21:28:34