Maven 1.x JXR Plugin
  1. Maven 1.x JXR Plugin
  2. MPJXR-20

JXR does not close streams properly, and causes build failures with Maven and Cruisecontrol

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.1
    • Fix Version/s: 1.4.3
    • Labels:
      None
    • Environment:
      Cruisecontrol 2.2, Maven 1.0.2, JXR 1.4.2, 1.4.1_01, Windows 2000 Server.
    • Number of attachments :
      3

      Description

      When running my maven script (multiproject:site) from Cruisecontrol 2.2, the jxr plugin causes random build failures, even though my code is OK. I can not recreate this problem running outside Cruisecontrol. The build fails with this message:

      maven-jxr-plugin:report
      [echo]
      Scanning D:\builds\checkout****\java
      BUILD FAILED
      File...... C:\Documents and Settings\edialog\.maven\cache\maven-multiproject-plugin-1.3.1\plugin.jelly
      Element... maven:reactor
      Line...... 103
      Column.... 9
      Unable to obtain goal [site] – C:\Documents and Settings\edialog\.maven\cache\maven-jxr-plugin-1.4.2\plugin.jelly:105:31: <jxr:jxr> D:\builds\checkout***\target\docs\xref\index.html (The process cannot access the file because it is being used by another process)
      Total time: 6 minutes 41 seconds
      Finished at: Fri Dec 03 10:54:48 CET 2004

      I've created a workaround for this:

      In CodeTransform.java, I've added a catch statement before the finally block in the transform method:

      catch (FileNotFoundException e)

      { System.out.println("IGNORING: FileNotFoundException - file is probably in use by another process! Unable to process " + sourcefile + " => " + destfile); }

      catch (RuntimeException e)

      { System.out.println("Unable to process " + sourcefile + " => " + destfile); throw e; }

      Also, I've added some cleanup code in the doJellyFile method in the DirectoryIndexer.java:

      private void doJellyFile(String templateName, String outDir, JellyContext context)
      throws Exception
      {
      String outFile = outDir + "/" + templateName + ".html";
      OutputStream out = null;
      try
      {
      // Throws FileNotFoundException
      out = new FileOutputStream(outFile);

      String templateFileName = getTemplateDir() + "/" + templateName + ".jelly";
      File templateFile = new File(templateFileName);

      File theFile = new File(outFile);
      File dir = theFile.getParentFile();
      if (dir != null)

      { dir.mkdirs(); }

      // Throws UnsupportedEncodingException
      XMLOutput xmlOutput = XMLOutput.createXMLOutput(out, false);

      // Throws JellyException
      context.runScript(templateFile, xmlOutput);

      // Throws IOException
      xmlOutput.flush();
      }
      catch (Throwable e)

      { System.out.println("IGNORING: Failed to process file [" + outFile + "]. Closing streams and moving on. Exception: " + e); }

      finally
      {
      try
      {
      if( out != null )

      { out.close(); }

      }
      catch (IOException e)

      { System.out.println("Failed to close outputstream for file [" + outFile + "], which is a bad thing!" ); throw e; }

      }
      }

      This seems to do the trick for now, but I guess the xref docs could be in a state of limbo sometimes.

      1. CodeTransform.java
        39 kB
        Ola Sandness
      2. DirectoryIndexer.java
        10 kB
        Ola Sandness
      3. DirectoryIndexer.patch
        2 kB
        Ola Sandness

        Activity

        Hide
        Ola Sandness added a comment -

        The CodeTransform class with a little bit more catching and "logging"

        Show
        Ola Sandness added a comment - The CodeTransform class with a little bit more catching and "logging"
        Hide
        Ola Sandness added a comment -

        The DirectoryIndexer with try-catch-finally block

        Show
        Ola Sandness added a comment - The DirectoryIndexer with try-catch-finally block
        Hide
        Emmanuel Venisse added a comment -

        a patch file will be better.

        Show
        Emmanuel Venisse added a comment - a patch file will be better.
        Hide
        Ola Sandness added a comment -

        I'm sorry, but I'm stuck behind a proxy server which denies access to the repository. This means I cannot use the CVS diff, or Tortoise. Do you know of any good standalone diff'ers which I can use to create a valid patch file?

        Show
        Ola Sandness added a comment - I'm sorry, but I'm stuck behind a proxy server which denies access to the repository. This means I cannot use the CVS diff, or Tortoise. Do you know of any good standalone diff'ers which I can use to create a valid patch file?
        Hide
        Ola Sandness added a comment -

        Added DirectoryIndex patch file

        Show
        Ola Sandness added a comment - Added DirectoryIndex patch file

          People

          • Assignee:
            Carlos Sanchez
            Reporter:
            Ola Sandness
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: