troubleshooting Question

file upload from windows working to one linux server, but not another

Avatar of jalbersh2
jalbersh2 asked on
Linux SecurityWindows 7Web Browsers
10 Comments1 Solution1120 ViewsLast Modified:
I have 3 linux servers running with Ubuntu. All have JBoss 1.5.0 and Java 1.6. All have the save file structures, users, and permissions.

The following code breaks on item.getInputStream:

      private String processFile(DiskFileItem item) {

            File tempDir = null;
            ResourceBundle rBundle = null;
            try {
                  rBundle = ResourceBundle.getBundle(SPREADSHEET_PROPERTIES_FILE_NAME);
                  tempDir = new File(rBundle.getString(FILE_DIR));
            } catch (MissingResourceException mre) {
                  log.warning("in missing resource sxception");
                  rBundle = new MyResources();
                  tempDir = new File(rBundle.getString(FILE_DIR));
            boolean ret = tempDir.mkdirs();
            if (!ret) {
                  log.warning("failed to create directories for "+tempDir.getPath());
            fileName = item.getName().toLowerCase();
  "fileName from item (client) = "+fileName);
            String separator = FORWARD_SLASH;
            if (fileName.indexOf(separator) != (-1))
                  fileName = fileName.substring(fileName.lastIndexOf(separator) + 1);
            separator = DOUBLE_BACK_SLASH;
            if (fileName.indexOf(separator) != (-1))
                  fileName = fileName.substring(fileName.lastIndexOf(separator) + 1);

            String newFileName = SERVER_FILE_PREFIX + new Date().getTime() + fileName;
            //String newFileName = SERVER_FILE_PREFIX + "_" + fileName;
            File newFile = null;
            try {// tempDir.getPath() + File.separator +
                  String fname = tempDir.getPath() + File.separator + newFileName;
        "filename = " + fname);
                  newFile = new File(fname);
              if (DevTestProdConstants.DEV_PROD_TEST.equals(DevTestProdConstants.LOCAL))
                    FileUtils.copyFile(new File(item.getName()), newFile);
              else {
                BufferedInputStream in = new BufferedInputStream(
                BufferedOutputStream    out = new BufferedOutputStream(
                            new FileOutputStream(newFile));
                IOUtils.copy(in, out);
                    newFile.setReadable(true, false);
          "is readable="+newFile.canRead());
           + (newFile.exists() ? " does " : " does NOT ") + " exist");

                  if (c_or_m)
                        saveFile(fileName, newFile.getPath());
                        updateFile(fileName, newFile.getPath());

                  long id = -1;
                  id = parseFile(newFile);
                  if (id < 0) {
                        workbookId = id;

            } catch (Exception e) {
                  log.warning("Error ingesting spreadsheet file! File: "
                              + newFile.getPath() + "; Error: " + e);
                  String stack = getStackTrace(e);
                  workbookId = -1;
            return newFile.getPath();

with the following trace:

2011-05-16 15:32:05,097 INFO  [STDOUT] (http- INFO    [gov.nrel.nbc.spreadsheet.server.SpreadSheetUploadServiceImpl.processFile()] fileName from item (client) = us_city_wages.xls
2011-05-16 15:32:05,097 INFO  [STDOUT] (http-10.20.52011-05-16 15:32:05,098 INFO  [STDOUT] (http- WARNING [gov.nrel.nbc.spreadsheet.server.SpreadSheetUploadServiceImpl.processFile()] Error ingesting spreadsheet file! File: /usr/local/NREL_ARCHIVE/NBC/SPREADSHEET/spreadsheet1305581525097us_city_wages.xls; Error: /usr/local/NREL_ARCHIVE/NBC/SPREADSHEET/tmp/upload_1fde2b39_12ff9cbcac0__7fb7_00000011.tmp (No such file or directory)
2011-05-16 15:32:05,098 INFO  [STDOUT] (http- WARNING [gov.nrel.nbc.spreadsheet.server.SpreadSheetUploadServiceImpl.processFile()] /usr/local/NREL_ARCHIVE/NBC/SPREADSHEET/tmp/upload_1fde2b39_12ff9cbcac0__7fb7_00000011.tmp (No such file or directory)
      at Method)
      at org.apache.commons.fileupload.disk.DiskFileItem.getInputStream(
      at gov.nrel.nbc.spreadsheet.server.SpreadSheetUploadServiceImpl.processFile(
      at gov.nrel.nbc.spreadsheet.server.SpreadSheetUploadServiceImpl.doPost(


The problem looks like the commons.fileupload.DiskFileItem.write is trying to create a temporary file with a unique GUID in the filename. The directory that it is trying to create the file in is totally open (777) and owned by the process user (jboss).

Any clues would be very much appreciated.
David Johnson, CD
The More I know, the more I don't know
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros