10 Replies Latest reply on Jun 13, 2011 5:16 AM by rkimiti

    Directory path in Windows

    rkimiti
      Hi Comrades,

      I have had a honeymoon with seam on Linux, all works fine.
      I have developed an application on ubuntu, and implemented live on debian; with PostgreSQL as the db engine.
      Nightmares begin when I try and move the environment to Windows. All works well, again, except one damn thing. Quite small.
      I just cant get the directories work right on Windows. When I do reports, or save files on linux, it works quite fine.
      The following replacement is not working on Windos
      Linux:
      public static String repObj = "/opt/pearltx/reports/obj/";
      Windows:
      public static String repObj = "C:/opt/pearltx/reports/obj/"; OR
      public static String repObj = "C:\\opt\\pearltx\\reports\\obj\\";
      I am getting the following errors:
      FileNotFoundException - when I try to open a file in the dir
      Error saving file : C:\opt\pearltx\reports\obj\<filename> - when I try to create and save a jasperreport file
      The directories are well created, with the right permissions.

      Has anyone experienced such a problem?
      Someone, please come to my rescue. I have chewed a whole elephant, I just need to munch its tail.

      Thanks for your time,
      Robert Kimiti
        • 1. Re: Directory path in Windows
          kragoth

          Put a breakpoint where it fails and make sure it is doing what you think it is doing. Most of the time I find out that I've missed something really simple and that's why your getting the error. Either of the paths should work if everything else is right.

          • 2. Re: Directory path in Windows
            rkimiti

            Thanks Tim for your contribution.
            This is still giving me nightmares.
            The same code is working ok when hosted on linux, but it is not working on Windows.

            • 3. Re: Directory path in Windows
              rogermorituesta.rogermori.yahoo.com

              Try this pathname:


              //C:/opt/pearltx/reports/obj
              



              Roger.

              • 4. Re: Directory path in Windows
                rkimiti

                Hi Roger,


                I appreciate your contribution.
                But it is also not working. Incidentally, all the three paths/strings are giving the same error message.
                I wonder what could be wrong with Windows, it is so smooth on linux.


                More suggestions are welcome.


                Kind Regards,
                Robert.

                • 5. Re: Directory path in Windows
                  jaikiran.jai_forums2005.yahoo.co.in

                  Please post the entire exception stacktraces. Those might give us a hint.

                  • 6. Re: Directory path in Windows
                    jaikiran.jai_forums2005.yahoo.co.in

                    And yes, even the relevant code where you are opening/writing these files.

                    • 7. Re: Directory path in Windows
                      rkimiti
                      Hi Jaikiran,

                      I have the following settings for directories:
                          //Reports parameters
                          //public static String repObj = "/opt/pearltx/reports/obj/";
                          public static String repObj = "//C:/opt/pearltx/reports/obj/";
                          //public static String repDest = "/opt/pearltx/reports/dest/";
                          public static String repDest = "//C:/opt/pearltx/reports/dest/";
                          //Resources parameters
                          //public static String contactResource = "/opt/pearltx/resources/contact/";
                          public static String contactResource = "//C:/opt/pearltx/resources/contact/";
                          //Image parameters
                          //public static String contactImage = "/opt/pearltx/resources/contact_photo/";
                          public static String contactImage = "//C:/opt/pearltx/resources/contact_photo/";
                      The obj is where I have my .jasper files, and the .jrprint generated is also temporarily saved here.
                      The dest is where I am saving the exported file in .pdf or other formats.
                      To avoid collision in file names, time stamp is being added to the original filename before saving. This is working perfectly in linux, not unless the strings could have differences from linux to windows.But windows is not completing the process even where it generates its own timestamp.
                      I have a file student\Transcript.jasper
                      The creating a .jrprint from it, and the subsequent .pdf yields the following errors in Windows:

                      2011-06-07 12:17:48,278 INFO  [com.parlor.express.action.reports.ReportSetup] (http-192.168.1.16-8080-1) Error saving file : C:\opt\pearltx\reports\obj\student\Transcript2011-06-07 12:17:39.869.jrprint

                      2011-06-07 12:17:48,801 INFO  [com.parlor.express.action.reports.ReportSetup] (http-192.168.1.16-8080-1) java.io.FileNotFoundException: C:\opt\pearltx\reports\obj\student\Transcript2011-06-07 12:17:39.869.jrprint

                      In uploading a user photo. A user with id - 11762, and a filename m20.jpeg, and addint a timestamp to these:
                      When I upload, I log the generated filename as follows:

                      2011-06-07 12:29:52,179 INFO  [com.parlor.express.action.files.ImageAction] (http-192.168.1.16-8080-1) C:\opt\pearltx\resources\contact_photo\11762_2011-06-07 12:29:52.179m20.jpeg
                      It eventually gives the following error:

                      2011-06-07 12:29:52,180 INFO  [com.parlor.express.action.files.ImageAction] (http-192.168.1.16-8080-1) C:\opt\pearltx\resources\contact_photo\11762_2011-06-07 12:29:52.179m20.jpeg (The filename, directory name, or volume label syntax is incorrect)

                      In uploading a file, Financial.txt, associated with the user I get the following error:

                      2011-06-07 12:31:44,255 INFO  [com.parlor.express.action.files.UploadHandler] (http-192.168.1.16-8080-3) C:\opt\pearltx\resources\contact\11762_2011-06-07 12:31:44.253Financial.txt (The filename, directory name, or volume label syntax is incorrect)
                      which means the file is not saved


                      Other than the update on the directory string, the it works very well in linux.

                      Kind Regards,
                      Robert.


                      • 8. Re: Directory path in Windows
                        jaikiran.jai_forums2005.yahoo.co.in
                        Your file name has characters which aren't permitted by Windows. For example

                        <blockquote>
                        _Robert Kimiti wrote on Jun 07, 2011 05:58:_<br/>



                        2011-06-07 12:29:52,180 INFO  [com.parlor.express.action.files.ImageAction] (http-192.168.1.16-8080-1) C:\opt\pearltx\resources\contact_photo\11762_2011-06-07 12:29:52.179m20.jpeg (The filename, directory name, or volume label syntax is incorrect)


                        </blockquote>

                        You use 12:29:52 as part of the file name but the character : isn't allowed for a file name.

                        See this for conventions and restrictions on file names in Windows http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx#naming_conventions


                        • 9. Re: Directory path in Windows
                          rkimiti
                          Wow,

                          Thanks a lot, Jaikiran.
                          I will try your solution.
                          Incidentally I had been able to transfer the files that had already been generated on linux, but they were not accessible on Windows.
                          .replace(":", "_") will come to my rescue, if this is the case, when generating the file name.

                          Thanks once again.

                          Kind Regards,
                          Robert.
                          • 10. Re: Directory path in Windows
                            rkimiti

                            Happy to report that the .replace() solution worked.
                            Thanks a lot, Jaikiran.