You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Michael Ralston <mi...@ralston.id.au> on 2005/10/11 10:14:35 UTC

Re: (FIXED) Deactivating a Page when Running On Windows, document could not be deleted

I fixed the problem.

javax.xml.DocumentParser wasn't closing the inputstream, so I called 
DocumentParser with my own input stream and then closed it myself. See patch.

Michael Ralston


On Tuesday 11 October 2005 16:17, Michael Ralston wrote:
> I'm having a problem with Lenya running on Windows.
>
> When I attempt to deactivate a document, Lenya gives me the following
> exception...
>
> 47   2005-10-11 16:07:09,765 [PoolThread-4] ERROR
> org.apache.lenya.cms.task.TaskSequence.execute():140  - Cannot execute
> TaskSequence:
> org.apache.lenya.cms.task.ExecutionException:
> org.apache.lenya.cms.publication.PublicationException: Source file [Y:
> \Java\apache-lenya-1.2.4-src\build\lenya\webapp\lenya\pubs\default\content\
>live\concepts\index_en.xml] of document [default:live:/concepts:en] could
> not be deleted!
>         at
> org.apache.lenya.defaultpub.cms.task.Deactivate.execute(Deactivate.java:75)
>
>
> I checked org.apache.lenya.cms.publication.file.FilePublication and the
> method deleteDocumentSource is where this exception originates.
>
> I have run this through a debugger and suspended execution when it reaches
> the deleteDocumentSource method, I then opened windows explorer and
> attempted to delete the file. Windows told me the file was in use and it
> could not be deleted.
>
> This error does not occur on Linux, as it allows the file to be deleted
> while it is still open, it will take care of cleaning up after the file is
> closed.
>
> Is it possible somewhere in Lenya, a fileinputstream or fileoutputstream is
> used but not closed?
>
> I have tried running lenya with incremental garbage collection to attempt
> to have the open file descriptor cleaned up, this didn't help either.
>
> Is this a known problem with running lenya on windows?
>
> Michael Ralston
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org

Re: (FIXED) Deactivating a Page when Running On Windows, document could not be deleted

Posted by Michael Ralston <mi...@ralston.id.au>.
On Tuesday 11 October 2005 20:04, Michael Wechner wrote:
> Michael Ralston wrote:
> >I fixed the problem.
> >
> >javax.xml.DocumentParser wasn't closing the inputstream, so I called
> >DocumentParser with my own input stream and then closed it myself. See
> > patch.
>
> well, I am not sure, but it might be better to fix the DocumentBuilder.

Yeah, javax.xml.parsers.DocumentBuilder is where the problem really lies. It 
is what is failing to close the input stream. I figured it was easier to make 
lenya use that class in a different way than fixing that class. I'm sure 
there is probably an update to that class somewhere, but this way works 
too :)

> another question re your patch: Why did you change the sequence re
> deleting from SiteStructure and  DocumentSource?
>

If deleting the file fails, and the sitetree has already been modified, then 
the sitetree is left in an inconsistent state. The sitetree doesn't have the 
page-node in it, but the file is still in the live directory. This causes a 
classcast exception if you attempt to deactivate the page again after it 
failed to deactivate ths first time.

With it switched around the sitetree is modified only after deletion succeeds.

Michael Ralston

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: (FIXED) Deactivating a Page when Running On Windows, document could not be deleted

Posted by Michael Wechner <mi...@wyona.com>.
Michael Ralston wrote:

>I fixed the problem.
>
>javax.xml.DocumentParser wasn't closing the inputstream, so I called 
>DocumentParser with my own input stream and then closed it myself. See patch.
>  
>

another question re your patch: Why did you change the sequence re
deleting from SiteStructure and  DocumentSource?

Thanks

Michi

>Michael Ralston
>
>
>On Tuesday 11 October 2005 16:17, Michael Ralston wrote:
>  
>
>>I'm having a problem with Lenya running on Windows.
>>
>>When I attempt to deactivate a document, Lenya gives me the following
>>exception...
>>
>>47   2005-10-11 16:07:09,765 [PoolThread-4] ERROR
>>org.apache.lenya.cms.task.TaskSequence.execute():140  - Cannot execute
>>TaskSequence:
>>org.apache.lenya.cms.task.ExecutionException:
>>org.apache.lenya.cms.publication.PublicationException: Source file [Y:
>>\Java\apache-lenya-1.2.4-src\build\lenya\webapp\lenya\pubs\default\content\
>>live\concepts\index_en.xml] of document [default:live:/concepts:en] could
>>not be deleted!
>>        at
>>org.apache.lenya.defaultpub.cms.task.Deactivate.execute(Deactivate.java:75)
>>
>>
>>I checked org.apache.lenya.cms.publication.file.FilePublication and the
>>method deleteDocumentSource is where this exception originates.
>>
>>I have run this through a debugger and suspended execution when it reaches
>>the deleteDocumentSource method, I then opened windows explorer and
>>attempted to delete the file. Windows told me the file was in use and it
>>could not be deleted.
>>
>>This error does not occur on Linux, as it allows the file to be deleted
>>while it is still open, it will take care of cleaning up after the file is
>>closed.
>>
>>Is it possible somewhere in Lenya, a fileinputstream or fileoutputstream is
>>used but not closed?
>>
>>I have tried running lenya with incremental garbage collection to attempt
>>to have the open file descriptor cleaned up, this didn't help either.
>>
>>Is this a known problem with running lenya on windows?
>>
>>Michael Ralston
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>>For additional commands, e-mail: user-help@lenya.apache.org
>>    
>>
>>------------------------------------------------------------------------
>>
>>diff -Nwurd apache-lenya-1.2.4-orig/src/java/org/apache/lenya/cms/publication/AbstractPublication.java apache-lenya-1.2.4-src/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
>>--- apache-lenya-1.2.4-orig/src/java/org/apache/lenya/cms/publication/AbstractPublication.java	2005-06-26 10:52:32.000000000 +1000
>>+++ apache-lenya-1.2.4-src/src/java/org/apache/lenya/cms/publication/AbstractPublication.java	2005-10-11 17:35:22.268846832 +1000
>>@@ -530,8 +530,8 @@
>>         if (!document.exists()) {
>>             throw new PublicationException("Document [" + document + "] does not exist!");
>>         }
>>-        deleteFromSiteStructure(document);
>>         deleteDocumentSource(document);
>>+        deleteFromSiteStructure(document);
>>     }
>> 
>>     /**
>>diff -Nwurd apache-lenya-1.2.4-orig/src/java/org/apache/lenya/xml/DocumentHelper.java apache-lenya-1.2.4-src/src/java/org/apache/lenya/xml/DocumentHelper.java
>>--- apache-lenya-1.2.4-orig/src/java/org/apache/lenya/xml/DocumentHelper.java	2005-06-26 10:52:33.000000000 +1000
>>+++ apache-lenya-1.2.4-src/src/java/org/apache/lenya/xml/DocumentHelper.java	2005-10-11 17:35:32.884233048 +1000
>>@@ -20,6 +20,7 @@
>> package org.apache.lenya.xml;
>> 
>> import java.io.File;
>>+import java.io.FileInputStream;
>> import java.io.IOException;
>> import java.io.InputStream;
>> import java.io.Writer;
>>@@ -47,6 +48,7 @@
>> import org.w3c.dom.Node;
>> import org.w3c.dom.NodeList;
>> import org.w3c.dom.Text;
>>+import org.xml.sax.InputSource;
>> import org.xml.sax.SAXException;
>> 
>> 
>>@@ -115,8 +117,10 @@
>>      */
>>     public static Document readDocument(File file)
>>         throws ParserConfigurationException, SAXException, IOException {
>>-        DocumentBuilder builder = createBuilder();
>>-        return builder.parse(file);
>>+        FileInputStream inStream=new FileInputStream(file);
>>+        Document result=readDocument(inStream);
>>+        inStream.close();
>>+        return result;
>>     }
>> 
>>     /**
>>
>>    
>>
>>------------------------------------------------------------------------
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>>For additional commands, e-mail: user-help@lenya.apache.org
>>


-- 
Michael Wechner
Wyona      -   Open Source Content Management   -    Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
michael.wechner@wyona.com                        michi@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: (FIXED) Deactivating a Page when Running On Windows, document could not be deleted

Posted by Michael Wechner <mi...@wyona.com>.

Michael Ralston wrote:

>I fixed the problem.
>
>javax.xml.DocumentParser wasn't closing the inputstream, so I called 
>DocumentParser with my own input stream and then closed it myself. See patch.
>  
>

well, I am not sure, but it might be better to fix the DocumentBuilder.

Thanks

Michi

>Michael Ralston
>
>
>On Tuesday 11 October 2005 16:17, Michael Ralston wrote:
>  
>
>>I'm having a problem with Lenya running on Windows.
>>
>>When I attempt to deactivate a document, Lenya gives me the following
>>exception...
>>
>>47   2005-10-11 16:07:09,765 [PoolThread-4] ERROR
>>org.apache.lenya.cms.task.TaskSequence.execute():140  - Cannot execute
>>TaskSequence:
>>org.apache.lenya.cms.task.ExecutionException:
>>org.apache.lenya.cms.publication.PublicationException: Source file [Y:
>>\Java\apache-lenya-1.2.4-src\build\lenya\webapp\lenya\pubs\default\content\
>>live\concepts\index_en.xml] of document [default:live:/concepts:en] could
>>not be deleted!
>>        at
>>org.apache.lenya.defaultpub.cms.task.Deactivate.execute(Deactivate.java:75)
>>
>>
>>I checked org.apache.lenya.cms.publication.file.FilePublication and the
>>method deleteDocumentSource is where this exception originates.
>>
>>I have run this through a debugger and suspended execution when it reaches
>>the deleteDocumentSource method, I then opened windows explorer and
>>attempted to delete the file. Windows told me the file was in use and it
>>could not be deleted.
>>
>>This error does not occur on Linux, as it allows the file to be deleted
>>while it is still open, it will take care of cleaning up after the file is
>>closed.
>>
>>Is it possible somewhere in Lenya, a fileinputstream or fileoutputstream is
>>used but not closed?
>>
>>I have tried running lenya with incremental garbage collection to attempt
>>to have the open file descriptor cleaned up, this didn't help either.
>>
>>Is this a known problem with running lenya on windows?
>>
>>Michael Ralston
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>>For additional commands, e-mail: user-help@lenya.apache.org
>>    
>>
>>------------------------------------------------------------------------
>>
>>diff -Nwurd apache-lenya-1.2.4-orig/src/java/org/apache/lenya/cms/publication/AbstractPublication.java apache-lenya-1.2.4-src/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
>>--- apache-lenya-1.2.4-orig/src/java/org/apache/lenya/cms/publication/AbstractPublication.java	2005-06-26 10:52:32.000000000 +1000
>>+++ apache-lenya-1.2.4-src/src/java/org/apache/lenya/cms/publication/AbstractPublication.java	2005-10-11 17:35:22.268846832 +1000
>>@@ -530,8 +530,8 @@
>>         if (!document.exists()) {
>>             throw new PublicationException("Document [" + document + "] does not exist!");
>>         }
>>-        deleteFromSiteStructure(document);
>>         deleteDocumentSource(document);
>>+        deleteFromSiteStructure(document);
>>     }
>> 
>>     /**
>>diff -Nwurd apache-lenya-1.2.4-orig/src/java/org/apache/lenya/xml/DocumentHelper.java apache-lenya-1.2.4-src/src/java/org/apache/lenya/xml/DocumentHelper.java
>>--- apache-lenya-1.2.4-orig/src/java/org/apache/lenya/xml/DocumentHelper.java	2005-06-26 10:52:33.000000000 +1000
>>+++ apache-lenya-1.2.4-src/src/java/org/apache/lenya/xml/DocumentHelper.java	2005-10-11 17:35:32.884233048 +1000
>>@@ -20,6 +20,7 @@
>> package org.apache.lenya.xml;
>> 
>> import java.io.File;
>>+import java.io.FileInputStream;
>> import java.io.IOException;
>> import java.io.InputStream;
>> import java.io.Writer;
>>@@ -47,6 +48,7 @@
>> import org.w3c.dom.Node;
>> import org.w3c.dom.NodeList;
>> import org.w3c.dom.Text;
>>+import org.xml.sax.InputSource;
>> import org.xml.sax.SAXException;
>> 
>> 
>>@@ -115,8 +117,10 @@
>>      */
>>     public static Document readDocument(File file)
>>         throws ParserConfigurationException, SAXException, IOException {
>>-        DocumentBuilder builder = createBuilder();
>>-        return builder.parse(file);
>>+        FileInputStream inStream=new FileInputStream(file);
>>+        Document result=readDocument(inStream);
>>+        inStream.close();
>>+        return result;
>>     }
>> 
>>     /**
>>
>>    
>>
>>------------------------------------------------------------------------
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>>For additional commands, e-mail: user-help@lenya.apache.org
>>


-- 
Michael Wechner
Wyona      -   Open Source Content Management   -    Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
michael.wechner@wyona.com                        michi@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org