安装GWT 2.6的问题 [英] Issue with installation of GWT 2.6

查看:174
本文介绍了安装GWT 2.6的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了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中。然后,我右键单击该项目并选择属性/ Google / Web工具包/配置SDK ... /添加。然后我浏览到GWT-2.6.0目录,添加并选择它。






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

编译模块org.AwardTracker.AwardTracker
验证单元:
忽略了2个编译错误的单元第一遍。
使用-strict编译或使用-logLevel设置为TRACE或DEBUG以查看所有错误。
计算'gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl'的所有可能重新绑定结果
重新绑定gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl
找不到完全匹配规则。使用基于回退值的最接近规则。你可能需要实现一个特定的绑定,以防止回退行为不能替换缺失的绑定
[ERROR]'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 +>项未找到< /+ 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;

/ **
*这是一个如何使用UploadAction类的例子。
*
*此servlet将所有收到的文件保存在临时文件夹
*中,并在用户发送删除请求时将其删除。
*
* @author Manolo CarrascoMoñino
*
* /
public class MyCustomisedUploadServlet extends UploadAction {

private static final long serialVersionUID = 1L;
protected static final String XML_ERROR_ITEM_NOT_FOUND =< + TAG_ERROR +>项未找到< /+ TAG_ERROR +>;

Hashtable< String,String> receivedContentTypes = new Hashtable< String,String>();
/ **
*维护一个收到文件及其内容类型的列表。
* /
Hashtable< String,File> receivedFiles = new Hashtable< String,File>();

/ **
*重写exe​​cuteAction以将接收到的文件保存在自定义位置
*中,并从会话中删除这些项目。
* /
@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 ++;
尝试{

///创建一个放置在默认系统临时文件夹中的临时文件
文件文件= File.createTempFile(upload-,.bin);
item.write(file);

///用收到的文件保存一个列表
receivedFiles.put(item.getFieldName(),file);
receivedContentTypes.put(item.getFieldName(),item.getContentType());

///向客户端发送定制消息。
response + = file.getAbsolutePath();

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



$ b ///从会话中删除文件,因为我们有它们的副本
removeSessionFileItems(request);

///将您的自定义消息发送给客户端。
返回响应;
}

/ **
*获取上传文件的内容。
* /
@Override
public void getUploadedFile(HttpServletRequest request,HttpServletResponse response)throws IOException {
String fieldName = request.getParameter(UConsts.PARAM_SHOW);
文件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);
}
}

/ **
*用户发送删除请求时删除文件。
* /
@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 =<+ TAG_ERROR +> item not found;),重新编译并运行它,它工作正常。我希望这一切都能帮助别人。感谢Braj的帮助。

解决方案


每当您更改GWT版本时,您必须清理您的项目来自前一个GWT版本自动生成的存根,如下图所示。


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



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




I have just installed GWT 2.6 and am now getting the error "Description Resource Path Location Type The file war\WEB-INF\lib\gwt-servlet.jar has a different size than GWT SDK library gwt-servlet.jar; perhaps it is a different version? gwt-servlet.jar /AwardTracker/war/WEB-INF/lib Unknown Google Web Toolkit Problem"

I downloaded the GWT 2.6 zip and then copied the directory "GWT-2.6.0" into "Eclipse\eclipse-jee-juno-SR1-win32\eclipse\plugins". I then right clicked on the project and selected "properties/Google/Web Toolkit/Configure SDKs.../Add". I then browsed to the "GWT-2.6.0" directory, added it and selected it.


I followed the solution from Braj and received the following errors when I recompiled:

Compiling module org.AwardTracker.AwardTracker Validating units: Ignored 2 units with compilation errors in first pass. Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors. Computing all possible rebind results for 'gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl' Rebinding gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl Could not find an exact match rule. Using 'closest' rule based on fall back values. You may need to implement a specific binding in case the fall back behavior does not replace the missing binding [ERROR] Errors in 'gwtupload/client/DecoratedFileUpload.java' [ERROR] Line 347: Rebind result 'gwtupload.client.DecoratedFileUpload.DecoratedFileUploadImpl' cannot be abstract

The above was fixed by downloading gwtupload-1.0.1.jar, using 'Add External JARS' to add it to the library and removing the old gwtupload-0.6.6.jar. I then recompiled and the compile work. However, now I have an error in my "MyCustomisedUploadServlet" on the line (this error was not present before):

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

The rest of the code is:

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();
    }
  }
}

I simply commented this line out (" protected static final String XML_ERROR_ITEM_NOT_FOUND = "<" + TAG_ERROR + ">item not found";"), recompiled and ran it and it works fine. I hope all this helps others. Thank you to Braj for his help.

解决方案

Whenever you change the GWT version you have to clean your project from the stub that is auto-generated by the previous GWT version as shown in below screenshots.

Problem: The file war\WEB-INF\lib\gwt-servlet.jar has a different size than GWT SDK library gwt-servlet.jar; perhaps it is a different version?

Solution: The problem in your case is gwt-servlet.jar that is auto-generated by previous GWT version. Just delete it along with other stub and re-compile project again.

这篇关于安装GWT 2.6的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆