[jbossws-dev] [Fwd: Big problem with WebXMLRewriterImpl.java rename]

Thomas Diesler thomas.diesler at jboss.com
Thu Nov 29 10:48:12 EST 2007


Heiko,

could you please follow up on this?

cheers
-thomas

-------- Forwarded Message --------
From: Leonardo Penczek <lpenczek at gmail.com>
To: thomas.diesler at jboss.com
Subject: Big problem with WebXMLRewriterImpl.java rename
Date: Thu, 29 Nov 2007 12:11:25 -0200

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
-- 
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thomas Diesler
Web Service Lead
JBoss, a division of Red Hat
xxxxxxxxxxxxxxxxxxxxxxxxxxxx





More information about the jbossws-dev mailing list