5 Replies Latest reply on Jan 28, 2011 2:02 PM by peterj

    Give permission to write to a folder?

    brandx

      I want to be able to upload a file and stick it in a public folder (for instance, ROOT.war). I haven't tested uploading yet, but I did try listing and deleting files which are already there. I can list them, but not delete. I checked the Windows permissions and I'm relatively sure that everything is allowed there (for example, I ran the command line as Administrator and started JBoss that way).

       

      I'm not sure whether I need to set the permissions for ROOT.war or for my own application, but I do have the freedom to do either one. I'm just not sure what exactly I have to change, nor what I need to change it to.

        • 1. Give permission to write to a folder?
          peterj

          A few questions come to mind:

           

          1) Which version of JBoss AS, which version of Windows, and which version of the JVM?

           

          2) How are you starting JBoss AS? Via the command line or as a service? If as a service, which mechanism are you using to register and run JBoss AS as a service?

           

          3) Look in Task Managare and tell us the account used for the java.exe process. (You might have to add that column.)

           

          4) Post the full stack trace for the exception you are getting.

           

          5) Post the code snippet that is attempting the delete. Also post the values of any pertinent variables (such as the file name).

           

          6) Have you run the delete code in a stand-alone Java app? Did it work there?

          • 2. Re: Give permission to write to a folder?
            brandx

            1) To be truthful, it's JBoss EWP 5.1 not the community edition (I didn't think that it might be a version specific issue, hence asking here. I do have a question out to our reseller as well). Win 7. Java 6 update 23.

            2) I'm starting it on the command line.

            3) JBoss is being run as myself (chris.williams). If I start it as an Administrator, then it's run as my Admin account.

            4) There is no exception since java.io.File.delete() just returns a boolean rather than throwing an exception.

            5) ->

             

             

             

                                String resFolder = getInitParameter("resources.folder");

             

                                if (request.getParameter("page_action") != null) {

                                          if (request.getParameter("page_action").compareTo("delete") == 0) {

                                                    File f = new File(resFolder + request.getParameter("filename"));

                                                    if (!f.delete()) {

                                                              ServletOutputStream out = response.getOutputStream();

                                                              out.print("Couldn't delete");

                                                              out.close();

                                                              return;

                                                    }

             

                                                    response.sendRedirect("Resources.html");

                                                    return;

                                          }

                                }

             

            6) Yes, a standalone application is able to delete from the target folder, even while JBoss is still running. I also tried setting the scan folder for the servlet to C:\ and was able to delete a file there, just not a file from the target folder.

            • 3. Re: Give permission to write to a folder?
              peterj

              My only guess is that the file is use by something. Process Monitor from sysinternals could let you know if that is the case.

               

              Exactly which file in ROOT.war are you trying to delete? Perhaps copy some other file to there, some file that would not be assumed to be part of the root web app, and see if you can remove that.

               

              Also, where is EAP installed? Full path, please.

              • 4. Re: Give permission to write to a folder?
                brandx

                I created an empty (0 byte) file named test.txt. That's what I was trying to delete.

                 

                C:\jboss-ewp-5.1\jboss-as-web\server\default\deploy\ROOT.war\test.txt

                 

                It should never have thought that was a key file of the system.

                • 5. Re: Give permission to write to a folder?
                  peterj

                  What di you find out from Process Monitor?