安装GWT 2.6的问题

时间:2014-05-04 11:10:06

标签: java eclipse gwt google-plugin-eclipse

我刚安装了GWT 2.6,现在收到错误“描述资源路径位置类型 文件war \ WEB-INF \ lib \ gwt-servlet.jar的大小与GWT SDK库gwt-servlet.jar不同;也许它是一个不同的版本? gwt-servlet.jar / AwardTracker / war / WEB-INF / lib未知的Google Web Toolkit问题“

我下载了GWT 2.6 zip,然后将目录“GWT-2.6.0”复制到“Eclipse \ eclipse-jee-juno-SR1-win32 \ eclipse \ plugins”中。然后我右键单击该项目并选择“properties / Google / Web Toolkit / Configure SDKs ... / Add”。然后我浏览了“GWT-2.6.0”目录,添加并选择了它。


我遵循Braj的解决方案,并在重新编译时收到以下错误:

编译模块org.AwardTracker.AwardTracker    验证单位:       在第一遍中忽略了2个带有编译错误的单元。 使用-strict或-logLevel进行编译设置为TRACE或DEBUG以查看所有错误。    计算'gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl'的所有可能重新绑定结果       重新绑定gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl          无法找到完全匹配规则。使用基于后退值的“最接近”规则。如果回退行为不替换缺少的绑定,您可能需要实现特定绑定    [错误]'gwtupload / client / DecoratedFileUpload.java'中的错误       [错误]第347行:重新绑定结果'gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl'不能是抽象的

通过下载gwtupload-1.0.1.jar,使用“Add External JARS”将其添加到库并删除旧的gwtupload-0.6.6.jar来解决上述问题。然后我重新编译并编译工作。但是,现在我的“MyCustomisedUploadServlet”出现了错误(之前没有出现此错误):

 protected static final String XML_ERROR_ITEM_NOT_FOUND = "<" + TAG_ERROR + ">item not found</" + TAG_ERROR + ">";

其余代码是:

package org.AwardTracker.server;

import gwtupload.server.UploadAction;
import gwtupload.server.exceptions.UploadActionException;
import gwtupload.shared.UConsts;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Hashtable;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;

/**
 * This is an example of how to use UploadAction class.
 *  
 * This servlet saves all received files in a temporary folder, 
 * and deletes them when the user sends a remove request.
 * 
 * @author Manolo Carrasco Moñino
 *
 */
public class MyCustomisedUploadServlet extends UploadAction {

  private static final long serialVersionUID = 1L;
  protected static final String XML_ERROR_ITEM_NOT_FOUND = "<" + TAG_ERROR + ">item not found</" + TAG_ERROR + ">";

  Hashtable<String, String> receivedContentTypes = new Hashtable<String, String>();
  /**
   * Maintain a list with received files and their content types. 
   */
  Hashtable<String, File> receivedFiles = new Hashtable<String, File>();

  /**
   * Override executeAction to save the received files in a custom place
   * and delete this items from session.  
   */
  @Override
  public String executeAction(HttpServletRequest request, List<FileItem> sessionFiles) throws UploadActionException {
    String response = "";
    @SuppressWarnings("unused")
    int cont = 0;
    for (FileItem item : sessionFiles) {
      if (false == item.isFormField()) {
        cont ++;
        try {

          /// Create a temporary file placed in the default system temp folder
          File file = File.createTempFile("upload-", ".bin");
          item.write(file);

          /// Save a list with the received files
          receivedFiles.put(item.getFieldName(), file);
          receivedContentTypes.put(item.getFieldName(), item.getContentType());

          /// Send a customised message to the client.
          response += file.getAbsolutePath();

        } catch (Exception e) {
          throw new UploadActionException(e);
        }
      }
    }

    /// Remove files from session because we have a copy of them
    removeSessionFileItems(request);

    /// Send your customised message to the client.
    return response;
  }

  /**
   * Get the content of an uploaded file.
   */
  @Override
  public void getUploadedFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String fieldName = request.getParameter(UConsts.PARAM_SHOW);
    File f = receivedFiles.get(fieldName);
    if (f != null) {
      response.setContentType(receivedContentTypes.get(fieldName));
      FileInputStream is = new FileInputStream(f);
      copyFromInputStreamToOutputStream(is, response.getOutputStream());
    } else {
      renderXmlResponse(request, response, XML_ERROR_ITEM_NOT_FOUND);
   }
  }

  /**
   * Remove a file when the user sends a delete request.
   */
  @Override
  public void removeItem(HttpServletRequest request, String fieldName)  throws UploadActionException {
    File file = receivedFiles.get(fieldName);
    receivedFiles.remove(fieldName);
    receivedContentTypes.remove(fieldName);
    if (file != null) {
      file.delete();
    }
  }
}

我只是注释掉这一行(“protected static final String XML_ERROR_ITEM_NOT_FOUND =”&lt;“+ TAG_ERROR +”&gt; item not found“;”),重新编译并运行它并且工作正常。我希望这一切都有助于他人。感谢Braj的帮助。

4 个答案:

答案 0 :(得分:7)

这对我很有用

选择警告,右键单击并选择 “快速修复” - &gt; “将/ WEB-INF / lib与SDK库同步”

“完成”

答案 1 :(得分:4)

  

每当您更改GWT版本时,您必须从之前GWT版本自动生成的存根中清除项目,如下面的屏幕截图所示。

问题:文件war\WEB-INF\lib\gwt-servlet.jar的大小与GWT SDK库gwt-servlet.jar不同;也许它是一个不同的版本?

解决方案:您的案例中的问题是gwt-servlet.jar,它是以前的GWT版本自动生成的。只需将其与其他存根一起删除并重新编译项目。

enter image description here

答案 2 :(得分:2)

复制插件目录中的sdk并不是添加其他SDK版本的正确方法。

使用偏好设置 - &gt; Google - &gt; Web Toolkit添加另一个GWT SDK版本。

在您的项目中选择:

项目属性 - &gt; Goolge - &gt; Web Toolkit您可以选择项目应该使用的SDK。

答案 3 :(得分:0)

我将编译器从1.8更改为1.7并丢失了此消息。