1 2 Previous Next 19 Replies Latest reply: Jan 11, 2007 1:33 PM by 843844 Go to original post RSS
      • 15. Re: File.exists() failing on Windows XP SP 2 ?
        843844
        Hi warelock,

        Here it is....
        This works fine from a java program. but doesnt work when run inside SAP WebAS 6.40

        String filePath = "//197.162.8.29/textfolder/";
                  String urlText="file://///197.162.8.29/textfolder/";
                  URI fileLocation=null;
                  File f=new File(filePath);
                  File j=null;
                  try {
                       fileLocation=new URI(urlText);
                       j=new File(fileLocation);
                       File[] list=j.listFiles();
                       for(int i=0;i<list.length;i++){
                       response.write(list.getName()+"<br>");
                       }
                  }catch (Throwable e) {
                       response.write("<br>"+e.getMessage()+"<br>" );
                       e.printStackTrace();
                       e.printStackTrace(new PrintWriter(response.getWriter()));
                       e.printStackTrace();
                  }
        • 16. Re: File.exists() failing on Windows XP SP 2 ?
          843844
          i have the same problem on windows server 2003.

          any solution for that?
          • 17. Re: File.exists() failing on Windows XP SP 2 ?
            cowwoc
            Guys, there is a simple solution to this that worked for me under Windows Server 2003 and probably works for everyone else who reported this problem:

            Simple modify the Tomcat service to run under a normal account, not the service one, and UNC paths will suddenly work just fine. The key is to not use the Tomcat configuration tool because it is worth than useless. For example, I tried changing the login username from their tool, got no error yet UNC paths didn't work. I then went into control panel -> services and noticed that they never even modified the Tomcat service!

            Modify the service yourself and try it. I highly suspect this will work for everyone.

            Gili
            • 18. Re: File.exists() failing on Windows XP SP 2 ?
              843844
              I can't say that this will work in all cases, but we finally were able to get a little success by following the information from several posts and hacks:

              1) In your java code, use UNC/URI notation and URI object instead of File (just like the example above)
              2) Make an EXTRA subdirectory under the shared directory, i.e. if the shared directory is, say somserver/someshare, then create another subdirectory under someshare like �someStupidHackedNameDir�
              3) Make sure the service uses a log-in account that is not "Local System" (the otherwise default account for services) but instead is
              a) a regular user, e.g. johnDoe or Administrator
              b) can map to the drive in question (but does not have to be mapped)
              c) HAS a password
              4) Our uri string wound up something like:
              "file://///192.169.20.6/shared/stupiddir/TESTINGIT2"
              • 19. Re: File.exists() failing on Windows XP SP 2 ?
                843844
                I posted this elsewhere, too, but we found a combination of tricks to be needed to get our java code to access a mapped drive via a service:

                1) Use UNC/URI notation and URI object instead of File (like mentioned above)

                2) Make an EXTRA subdirectory under the shared directory, i.e. if the shared directory is, say server/sharedName, then create another subdirectory under sharedName like �someStupidHackedNameDir�

                3) Use a log-in account that is not Local System (the default) but instead is

                a) a regular user

                b) can map to the drive in question (but does not have to be mapped)

                c) HAS a password
                1 2 Previous Next