Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Bug in XMLOutput?

  1. #1
    Join Date
    Oct 2006
    Posts
    817

    Default Bug in XMLOutput?

    I think I've found a bug in XMLOutput.

    To reproduce:

    1. Add an XMLOutput step.
    2. Save the KTR file.
    3. Edit the step's filename property to be ${Internal.Transformation.Filename.Directory}/out
    4. Run the transformation.


    At this point, you should see something similar to:
    2007/07/27 10:11:21 - XML Output.0 - ERROR (version 2.5.0, build 25002 from 2007/05/04 00:20:04) : Error opening new file : java.io.FileNotFoundException: file:/home/mlowery/My Documents/temp2/out.xml (No such file or directory)

    (where file:/home/mlowery/My Documents/temp2 was the value of ${Internal.Transformation.Filename.Directory} in my case. See attached for KTR file.) Notice that the path printed in the FileNotFoundException doesn't conform to the pattern file://path.

    The problem seems to be when the filename property value uses Kettle variables that contain "file://..." When this value is passed to the constructor of the java.io.File, the result is a FileNotFoundException. The proper usage of the "file://..." string is to use it to construct a java.net.URI which is passed to the File constructor. I've tested this and it works. The final piece of the puzzle is support for paths with spaces.

    My question to the Kettle community is if this looks like a good solution and more importantly, is this a bigger problem than just this XMLOutput?

    Below is the new code:

    Code:
    public class XMLOutput extends BaseStep implements StepInterface
    {
    
      ...omitted...
    
      public boolean openNewFile()
      {
    
        ...omitted...
    
        URI uri = new URI(buildFilename(true).replaceAll("\\s", "%20"));
        File file = new File(uri);
    
       ...omitted...
    
      }
    
      ...omitted...
    
    }
    Attached Files Attached Files

  2. #2
    Join Date
    May 2006
    Posts
    4,882

    Default

    ROTFL ... your statement that 'file:/home...' is passed to the constructor of File, is wrong. If you use a debugger you will see that string is actually "file:///home..." which is ok.

    Your ONLY problem is the space in the directory path, but it's part of a bigger problem so I would not fix it in XMLOutput. It happened during the file/VFS change.

    Short term: don't use use directories that contain spaces

    Regards,
    Sven

  3. #3
    Join Date
    Oct 2006
    Posts
    817

    Default

    I'm sorry for my incorrect post. I didn't mean to imply that the string going into the java.io.File constructor is "file:/home..." It is in fact, "file:///home..." However, the code is still incorrect in that it uses the wrong java.io.File constructor. It should be using the java.io.File(java.net.URI uri) constructor.

    If you look at the path property of the java.io.File object after construction, you'll see its value is "file:/home..."

  4. #4
    Join Date
    May 2006
    Posts
    4,882

    Default

    Anyway the problem is not only in the XMLOutput, it's in a lot more places. So if possible I would like a general solution, else we have to track down where all the problem cases are.

    Regards,
    Sven

  5. #5
    Join Date
    Oct 2006
    Posts
    817

    Default

    Quote Originally Posted by mlowery
    ...and more importantly, is this a bigger problem than just this XMLOutput?
    Quote Originally Posted by sboden
    Anyway the problem is not only in the XMLOutput, it's in a lot more places. So if possible I would like a general solution...
    So my question has been answered. Since I'm new to Kettle development, I was hesitant to start making changes without understanding all of the ramifications. Should I take a stab at a solution? Is there anything special I should keep in mind?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.