Re: File locking issue
Adam Retter <adam <at> exist-db.org>
2010-09-01 14:53:20 GMT
This is very strange, perhaps the issue was fixed in trunk?
I didnt actually mean for you to use eXist-db as a library in
NetBeans, more that you could use NetBeans to find the problem with
the file locking...
But if it works
On 1 September 2010 15:00, Jason Liu <liu.canada <at> gmail.com> wrote:
> Hi Adam,
>
> I have tried your suggestion, and checked out the project into my Netbeans
> and imported the project into my tool as a library, and it does not have the
> same file locking issue.
>
>
> Jason
>
>
> On Wed, Sep 1, 2010 at 08:20, Adam Retter <adam <at> exist-db.org> wrote:
>>
>> eXist is configured as a NetBeans project (amongst others), so you can
>> simply use the Team -> Checkout menu item in NetBeans and give it the
>> path https://exist.svn.sourceforge.net/svnroot/exist/trunk/eXist
>>
>> The functions and classes of interest are -
>> org.exist.xmldb.RemoteXMLResource org.exist.xmldb.RemoteCollection and
>> validateXmlResource(...) and stroreXmlResource(...) in
>> org.exist.collections.Collection
>>
>> Cheers Adam.
>>
>> On 31 August 2010 23:02, Jason Liu <liu.canada <at> gmail.com> wrote:
>> > That was my initial guess too that an InputStream object is not
>> > releasing
>> > the file. I do develop/debug with NetBeans (PS. I love this IDE). I
>> > didn't
>> > have the eXist source so I could not step-in. I will try find the source
>> > and
>> > step through it when I have time.
>> >
>> > Thanks for your help Adam!
>> >
>> > Jason
>> >
>> >
>> > On Tue, Aug 31, 2010 at 17:58, Adam Retter <adam <at> exist-db.org> wrote:
>> >>
>> >> The only thing that I could imagine was that somewhere an InputStream
>> >> or Reader was not being correctly closed. I did read through the code
>> >> for the process but could not see that the issue is in eXist-db code
>> >> and I find it difficult to believe that it would be in the XMLReader
>> >> code itself as this is widely used.
>> >>
>> >> Really you would need to step through it with something like the
>> >> NetBeans or Eclipse Java debuggers to understand where the lock is
>> >> acquired and why it is not released. Do you have any experience of
>> >> Java and debugging?
>> >>
>> >> Cheers Adam.
>> >>
>> >> On 31 August 2010 22:54, Jason Liu <liu.canada <at> gmail.com> wrote:
>> >> > Hi Adam,
>> >> >
>> >> > Yes, this is very odd, and it has bugged me for a few hours on a
>> >> > Sunday
>> >> > night.
>> >> >
>> >> > It is the java runtime placing the lock on the file. I used both
>> >> > unlockit
>> >> > and process explorer and confirmed the source.
>> >> >
>> >> > You are right, I am passing a File object to setContent.
>> >> >
>> >> > My document is at c:\checkout\tools\topic.xml
>> >> >
>> >> > Thanks for your thoughts!
>> >> >
>> >> >
>> >> > Jason
>> >> >
>> >> >
>> >> > On Tue, Aug 31, 2010 at 17:47, Adam Retter <adam <at> exist-db.org> wrote:
>> >> >>
>> >> >> Hmm this is strange, I cannot reproduce the issue here using
>> >> >> eXist-db
>> >> >> trunk version.
>> >> >>
>> >> >> I assume you are also passing a java.io.File object to the
>> >> >> setContent() function?
>> >> >>
>> >> >> I just copied the code from the example on the eXist-db website. I
>> >> >> am
>> >> >> testing this on Windows XP SP3 and Java 1.6.0_21-b07.
>> >> >>
>> >> >> Where are your documents that you are loading? I know there are some
>> >> >> restrictions in Windows with regards to the "My Documents" folder.
>> >> >>
>> >> >> Perhaps there is something else locking the file? Do you also have
>> >> >> it
>> >> >> open in an editor, or does your code perhaps also do something else
>> >> >> with this file?
>> >> >>
>> >> >> Cheers Adam.
>> >> >>
>> >> >> On 31 August 2010 14:26, Jason Liu <liu.canada <at> gmail.com> wrote:
>> >> >> > Hi Adam,
>> >> >> >
>> >> >> > Sorry, I could of included the information in my first email. Here
>> >> >> > are
>> >> >> > the
>> >> >> > info,
>> >> >> >
>> >> >> > OS: Win XP SP3
>> >> >> >
>> >> >> > Java:
>> >> >> > java version "1.6.0_17"
>> >> >> > Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
>> >> >> > Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
>> >> >> >
>> >> >> > eXist: (from version.txt)
>> >> >> > #eXist build info (updated using svnkit)
>> >> >> > #Wed Nov 11 17:37:17 CET 2009
>> >> >> > project.version=1.4.0
>> >> >> > project.build=20091111
>> >> >> > svn.revision=10440
>> >> >> >
>> >> >> >
>> >> >> > Thanks!
>> >> >> >
>> >> >> > Jason
>> >> >> >
>> >> >> >
>> >> >> > On Tue, Aug 31, 2010 at 08:59, Adam Retter <adam <at> exist-db.org>
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> Which OS, Java platform and eXist-db version are you on please?
>> >> >> >>
>> >> >> >> On 29 August 2010 16:18, Jason Liu <liu.canada <at> gmail.com> wrote:
>> >> >> >> > Hi,
>> >> >> >> >
>> >> >> >> > Sorry to bug you guys again, but there is a client file locking
>> >> >> >> > issue
>> >> >> >> > that
>> >> >> >> > is bothering me for awhile, and I could not find any related
>> >> >> >> > info
>> >> >> >> > in
>> >> >> >> > the
>> >> >> >> > archive.
>> >> >> >> >
>> >> >> >> > I have a java client, that is storing content into eXist db
>> >> >> >> > using
>> >> >> >> > the
>> >> >> >> > following code (written based on the demo source code):
>> >> >> >> >
>> >> >> >> > XMLResource document = (XMLResource)
>> >> >> >> > collection.createResource(fileName,
>> >> >> >> > "XMLResource");
>> >> >> >> > document.setContent(file);
>> >> >> >> > System.out.print("storing document " + document.getId() +
>> >> >> >> > "...");
>> >> >> >> > collection.storeResource(document);
>> >> >> >> > System.out.println("ok.");
>> >> >> >> >
>> >> >> >> > The content stores properly, but after the content is stored, I
>> >> >> >> > want
>> >> >> >> > to
>> >> >> >> > remove the file from the disk, but it is somehow locked, and I
>> >> >> >> > could
>> >> >> >> > not
>> >> >> >> > find a way to release the lock the file unless I close the
>> >> >> >> > client.
>> >> >> >> > I looked around and try to find function like
>> >> >> >> > XMLResource.release(),
>> >> >> >> > or
>> >> >> >> > Collection.release(XMLResource), but no luck.
>> >> >> >> >
>> >> >> >> > Is there a function that release the file lock?
>> >> >> >> >
>> >> >> >> > Thanks!
>> >> >> >> >
>> >> >> >> > Jason
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > ------------------------------------------------------------------------------
>> >> >> >> > This SF.net Dev2Dev email is sponsored by:
>> >> >> >> >
>> >> >> >> > Show off your parallel programming skills.
>> >> >> >> > Enter the Intel(R) Threading Challenge 2010.
>> >> >> >> > http://p.sf.net/sfu/intel-thread-sfd
>> >> >> >> > _______________________________________________
>> >> >> >> > Exist-open mailing list
>> >> >> >> > Exist-open <at> lists.sourceforge.net
>> >> >> >> > https://lists.sourceforge.net/lists/listinfo/exist-open
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> --
>> >> >> >> Adam Retter
>> >> >> >>
>> >> >> >> eXist Developer
>> >> >> >> { United Kingdom }
>> >> >> >> adam <at> exist-db.org
>> >> >> >> irc://irc.freenode.net/existdb
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Adam Retter
>> >> >>
>> >> >> eXist Developer
>> >> >> { United Kingdom }
>> >> >> adam <at> exist-db.org
>> >> >> irc://irc.freenode.net/existdb
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Adam Retter
>> >>
>> >> eXist Developer
>> >> { United Kingdom }
>> >> adam <at> exist-db.org
>> >> irc://irc.freenode.net/existdb
>> >
>> >
>>
>>
>>
>> --
>> Adam Retter
>>
>> eXist Developer
>> { United Kingdom }
>> adam <at> exist-db.org
>> irc://irc.freenode.net/existdb
>
>
--
--
Adam Retter
eXist Developer
{ United Kingdom }
adam <at> exist-db.org
irc://irc.freenode.net/existdb
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd