Question

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.

Was it helpful?

Solution 2

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.

enter image description here

OTHER TIPS

This works for me very well

Select the warning, right click and choose "Quick fix" -> "Synchronize /WEB-INF/lib with SDK libraries"

"Done"

To copy the sdk in the plugin directory is not the corret way to add another SDK version.

Use Preferences -> Google -> Web Toolkit to add another GWT SDK version.

In your project choose:

project properties -> Goolge -> Web Toolkit you can choose the SDK the project should use.

I changed my compiler from 1.8 to 1.7 and lost this message.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top