6 Replies Latest reply on Dec 3, 2007 5:15 AM by heiko.braun

    Big problem with WebXMLRewriterImpl.java rename

    heiko.braun

      In WindowsNT systems, your modification in these lines doesn't work:

       FileInputStream stream = new FileInputStream(webXML);
       String modifyProperty =
      (String)dep.getProperty("org.jboss.ws.webapp.modify");
      
       // JBWS 1762
       if ((modifyProperty == null) || (!modifyProperty.equals("false")))
       {
       String suffix =
      (String)dep.getProperty("org.jboss.ws.webapp.descriptor.suffix");
       if (suffix == null)
       suffix = ".org";
       File orgWebXML = new File(webXML.getCanonicalPath() + suffix);
      
       // Rename the web.xml
       if (webXML.renameTo(orgWebXML) == false)
       throw new WebServiceException("Cannot rename web.xml: "
      + orgWebXML);
      
       stream = new FileInputStream(orgWebXML);
       }
      


      As you open a FileInputStream over webXML, it can't be renamed to
      orgWebXML because the stream is open in this point, and Windows blocks
      te rename operation.
      It can be solved as below:

       // WindowsNT correction
       FileInputStream stream = null;
       String modifyProperty =
      (String)dep.getProperty("org.jboss.ws.webapp.modify");
      
       // JBWS 1762
       if ((modifyProperty == null) || (!modifyProperty.equals("false")))
       {
       String suffix =
      (String)dep.getProperty("org.jboss.ws.webapp.descriptor.suffix");
       if (suffix == null)
       suffix = ".org";
       File orgWebXML = new File(webXML.getCanonicalPath() + suffix);
      
       // Rename the web.xml
       if (webXML.renameTo(orgWebXML) == false)
       throw new WebServiceException("Cannot rename web.xml: "
      + orgWebXML);
      
       stream = new FileInputStream(orgWebXML);
       } else {
       stream = new FileInputStream(webXML);
       }
      
      

      Cheers,

      Leonardo Penczek