我遇到了使用maven編譯GWT項目的異常,但它在eclipse中工作。我花了最近幾個小時的搜索和搜索StackOverflow,但有幾個結果是相關的,但沒有一個適合我的情況。GWT編譯使用maven而不是eclipse - NoSuchMethodError UiBinderWriter失敗。 <init>
環境:
- OSX 10.10.1
- 爪哇1.7.0_67 64位
- GWT 2.7.0
- GWTP 1.3.1
- GAE 1.9.17
- Maven的3.2.3
我可以r un使用超級開發模式在eclipse中的項目,它工作正常。我可以使用Eclipse GWT插件來編譯項目 - 它成功完成。但是,如果我嘗試通過使用mvn clean compile gwt:compile
終端編譯,我得到以下錯誤:
[INFO] Compiling module com.example.foo.Foo
[INFO] [ERROR] An internal compiler exception occurred
[INFO] com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
[INFO] at com.google.gwt.dev.jjs.ast.JVisitor.translateException(JVisitor.java:121)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:296)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
[INFO] at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:128)
[INFO] at com.google.gwt.dev.jjs.ast.JDeclarationStatement.traverse(JDeclarationStatement.java:49)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor$ListContext.traverse(JModVisitor.java:95)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemove(JModVisitor.java:351)
[INFO] at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:92)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
[INFO] at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:149)
[INFO] at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:145)
[INFO] at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:83)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
[INFO] at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:600)
[INFO] at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:569)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:285)
[INFO] at com.google.gwt.dev.jjs.impl.UnifyAst.mainLoop(UnifyAst.java:1505)
[INFO] at com.google.gwt.dev.jjs.impl.UnifyAst.exec(UnifyAst.java:870)
[INFO] at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.unifyJavaAst(JavaToJavaScriptCompiler.java:1305)
[INFO] at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.constructJavaAst(JavaToJavaScriptCompiler.java:1038)
[INFO] at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler$Precompiler.precompile(JavaToJavaScriptCompiler.java:954)
[INFO] at com.google.gwt.dev.jjs.MonolithicJavaToJavaScriptCompiler.precompile(MonolithicJavaToJavaScriptCompiler.java:303)
[INFO] at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:38)
[INFO] at com.google.gwt.dev.Precompile.precompile(Precompile.java:286)
[INFO] at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
[INFO] at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
[INFO] at com.google.gwt.dev.Compiler.run(Compiler.java:206)
[INFO] at com.google.gwt.dev.Compiler.run(Compiler.java:158)
[INFO] at com.google.gwt.dev.Compiler$1.run(Compiler.java:120)
[INFO] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55)
[INFO] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)
[INFO] at com.google.gwt.dev.Compiler.main(Compiler.java:127)
[INFO] Caused by: java.lang.NoSuchMethodError: com.google.gwt.uibinder.rebind.UiBinderWriter.<init>(Lcom/google/gwt/core/ext/typeinfo/JClassType;Ljava/lang/String;Ljava/lang/String;Lcom/google/gwt/core/ext/typeinfo/TypeOracle;Lcom/google/gwt/uibinder/rebind/MortalLogger;Lcom/google/gwt/uibinder/rebind/FieldManager;Lcom/google/gwt/uibinder/rebind/messages/MessagesWriter;Lcom/google/gwt/uibinder/rebind/DesignTimeUtils;Lcom/google/gwt/uibinder/rebind/UiBinderContext;ZZLjava/lang/String;)V
[INFO] at com.google.gwt.uibinder.rebind.UiBinderGenerator.generateOnce(UiBinderGenerator.java:187)
[INFO] at com.google.gwt.uibinder.rebind.UiBinderGenerator.generate(UiBinderGenerator.java:135)
[INFO] at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40)
[INFO] at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:760)
[INFO] at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:160)
[INFO] at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:79)
[INFO] at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:276)
[INFO] at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:265)
[INFO] at com.google.gwt.dev.DistillerRebindPermutationOracle.getAllPossibleRebindAnswers(DistillerRebindPermutationOracle.java:87)
[INFO] at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.createStaticRebindExpression(UnifyAst.java:485)
[INFO] at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.createRebindExpression(UnifyAst.java:443)
[INFO] at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.handleMagicMethodCall(UnifyAst.java:576)
[INFO] at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.endVisit(UnifyAst.java:306)
[INFO] at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:248)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:381)
[INFO] at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:293)
[INFO] ... 35 more
[INFO] [ERROR] at com_gwtplatform_mvp_client_DesktopGinjector_DesktopGinjectorGinjector_fragment.java(91): GWT.create(ApplicationView$Binder.class)
[INFO] com.google.gwt.dev.jjs.ast.JMethodCall
[INFO] [ERROR] at com_gwtplatform_mvp_client_DesktopGinjector_DesktopGinjectorGinjector_fragment.java(91): Object created = GWT.create(ApplicationView$Binder.class)
[INFO] com.google.gwt.dev.jjs.ast.JDeclarationStatement
[INFO] [ERROR] at com_gwtplatform_mvp_client_DesktopGinjector_DesktopGinjectorGinjector_fragment.java(90): {
[INFO] Object created = GWT.create(ApplicationView$Binder.class);
[INFO] assert created instanceof ApplicationView$Binder;
[INFO] ApplicationView$Binder result = (ApplicationView$Binder) created;
[INFO] this.memberInject_Key$type$com$example$foo$client$application$ApplicationView$Binder$_annotation$$none$$(result);
[INFO] return result;
[INFO] }
[INFO] com.google.gwt.dev.jjs.ast.JBlock
[INFO] [ERROR] at com_gwtplatform_mvp_client_DesktopGinjector_DesktopGinjectorGinjector_fragment.java(90): {
[INFO] Object created = GWT.create(ApplicationView$Binder.class);
[INFO] assert created instanceof ApplicationView$Binder;
[INFO] ApplicationView$Binder result = (ApplicationView$Binder) created;
[INFO] this.memberInject_Key$type$com$example$foo$client$application$ApplicationView$Binder$_annotation$$none$$(result);
[INFO] return result;
[INFO] }
[INFO] com.google.gwt.dev.jjs.ast.JMethodBody
[INFO] [ERROR] at com_gwtplatform_mvp_client_DesktopGinjector_DesktopGinjectorGinjector_fragment.java(90): public ApplicationView$Binder get_Key$type$com$example$foo$client$application$ApplicationView$Binder$_annotation$$none$$();
[INFO]
[INFO] com.google.gwt.dev.jjs.ast.JMethod
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.013 s
[INFO] Finished at: 2014-12-06T20:28:36-05:00
[INFO] Final Memory: 13M/310M
[INFO] ------------------------------------------------------------------------
我用GWTP插件生成對谷歌應用程序引擎使用的基礎工程,而不得不調整一些東西以獲得它,以便它能在本地工作並推送到應用程序引擎。它在當時編譯得很好,日食或maven。我做了一些修改,主要是搞UI和GWT日誌記錄,在超級開發模式下進行測試,並且它運行良好。現在工作正常。由於沒有完成,我沒有嘗試上傳到GAE。
研究:
一位參與inherited modules這是壓倒一切的GWT UiBinder的實現,但我沒有加入或繼承依賴從我用來生成它的原型。另外,它通過eclipse/SuperDevMode工作。 other是關於在eclipse中編譯工作的,我可能用它在一週前第一次工作時得到eclipse的工作。但它在eclipse中工作,但不通過maven命令行。
我試過去掉gwt/gwtp不需要的各種模塊,但都沒有運氣。我指定了一個gwt-user和gwt-dev導入版本,沒有任何東西。我總是得到同樣的錯誤,這讓我很生氣!我只是無法弄清楚爲什麼它不會用'普通'的maven編譯。
如果某些依賴項「隱藏」了com.google.gwt.uibinder.rebind.UiBinderWriter類,那麼它必定是類路徑排序問題。要麼你改變了你的Maven版本,並且以不同的順序依賴,或者你改變了'pom.xml'中的依賴聲明順序。嘗試在Eclipse中使用「open type」來查找包含違規的過期類的依賴項,並嘗試使用與GWT 2.7兼容的一個更新依賴項(和/或重新排序POM) – 2014-12-07 02:16:49
您是對的 - 它是依賴性順序。我不記得改變它,但我通過重新排序依賴來修復它。也就是說,我將gwt-user移動到列表的前面,問題就消失了。謝謝! – 2014-12-09 20:06:32