代码之家  ›  专栏  ›  技术社区  ›  awudoin

无法让GAE+GWT+Objectify工作

  •  0
  • awudoin  · 技术社区  · 11 年前

    正如标题所说,我正在尝试使用Objectify创建一个GAE+GWT项目,但我甚至无法将其启动。我肯定我错过了一些简单的东西,但似乎不起作用。

    以下是我迄今为止所做的工作:

    • 创建新项目并添加 guava-17.0.jar , guava-gwt-17.0.jar , objectify-5.0.3.jar objectify-gwt-1.1jar 到我的 WEB-INF\lib 文件夹这些都是这些罐子的最新版本。
    • 运行应用程序。发送简单的RPC命令,服务器响应,客户端成功接收响应( onSuccess() 被称为)。
    • 添加线条 <inherits name="com.googlecode.objectify.Objectify" /> 到我的gwt.xml文件 Objectify-GWT's website 它应该在GWT中启用Objectify。
    • 运行应用程序。应用程序启动,发送相同的RPC命令,服务器接收并响应,但客户端表示命令失败( onFailure() 被称为)。

    我使用的是在首次创建新的web应用程序时预先填充的锅炉板代码。作为参考,以下是RPC命令:

    private void sendNameToServer() {
        // First, we validate the input.
        errorLabel.setText("");
        String textToServer = nameField.getText();
        if (!FieldVerifier.isValidName(textToServer)) {
            errorLabel.setText("Please enter at least four characters");
            return;
        }
    
        // Then, we send the input to the server.
        sendButton.setEnabled(false);
        textToServerLabel.setText(textToServer);
        serverResponseLabel.setText("");
        greetingService.greetServer(textToServer,
                new AsyncCallback<String>() {
                    public void onFailure(Throwable caught) {
                        // Show the RPC error message to the user
                        dialogBox
                                .setText("Remote Procedure Call - Failure");
                        serverResponseLabel
                                .addStyleName("serverResponseLabelError");
                        serverResponseLabel.setHTML(SERVER_ERROR);
                        dialogBox.center();
                        closeButton.setFocus(true);
                    }
    
                    public void onSuccess(String result) {
                        dialogBox.setText("Remote Procedure Call");
                        serverResponseLabel
                                .removeStyleName("serverResponseLabelError");
                        serverResponseLabel.setHTML(result);
                        dialogBox.center();
                        closeButton.setFocus(true);
                    }
                });
    }
    

    这是我尝试进行RPC调用后收到的错误:

    [DEBUG] [my_app] - Validating units:
    [INFO] [my_app] - Module my_app has been loaded
    [ERROR] [my_app] - Errors in 'com/google/gwt/dev/jjs/SourceOrigin.java'
        [ERROR] [my_app] - Line 77: The method synchronizedMap(new LinkedHashMap<SourceOrigin,SourceOrigin>(){}) is undefined for the type Collections
    [ERROR] [my_app] - Errors in 'com/google/gwt/dev/util/StringInterner.java'
        [ERROR] [my_app] - Line 29: No source code is available for type com.google.gwt.thirdparty.guava.common.collect.Interner<E>; did you forget to inherit a required module?
        [ERROR] [my_app] - Line 29: No source code is available for type com.google.gwt.thirdparty.guava.common.collect.Interners; did you forget to inherit a required module?
    

    在我看来,Objectify似乎在干扰GWT。我知道他们应该一起工作,所以不知道我做错了什么。任何建议都将不胜感激。

    2 回复  |  直到 11 年前
        1
  •  0
  •   stickfigure    11 年前

    使用objectify gwt 1.2。1.1合并不良PR可能会有一些问题。

    您可以看到一个示例应用程序,它使用objectify gwt从客户端来回传递GeoPt: https://github.com/stickfigure/objectify-gwt-test

        2
  •  0
  •   Zied Hamdi    11 年前

    在尝试做这类事情之前,应该在服务器端使用objectify。Objectify是一种服务器端的易失性技术。在服务器代码中调用它

    在服务方法中添加try-catch,并在服务器控制台上打印异常的堆栈跟踪,如果在GWT上收到onFailure(),则表示服务器端出现故障。你必须找到失败的原因。

    第二部分是建议:

     <inherits name="com.googlecode.objectify.Objectify" /> 
    

    这对我来说是一条红线。GWT不必知道您的持久性层。

    除非这是一个革命性的概念,否则我建议您不要使用这种类型的技术来控制您的数据库访问。。。

    推荐文章