You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by thomasg <th...@hotmail.com> on 2006/04/06 18:58:51 UTC

ItemNotFoundException when adding files from multiple threads

Hi guys,

I've been trying to get multiple threads to add a file to the same
workspace. Each thread gets its own session in its run() method, creates a
nt:folder and adds a nt:file and nt:resource. One thread succeeds but all
others fail with an ItemNotFoundException. The output is as follows:


thread 1 added in 1343ms, logging out of session
javax.jcr.ItemNotFoundException:
5cc05aef-5ad0-434a-9b47-4d7e3d3ba7be/{http://www.jcp.org/jcr/1.0}data
	at
org.apache.jackrabbit.core.ItemManager.createItemInstance(ItemManager.java:465)
	at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:321)
	at
org.apache.jackrabbit.core.ItemImpl.restoreTransientItems(ItemImpl.java:709)
	at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1209)
	at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:806)
	at com.axxia.test.JackrabbitThreadTests.run(JackrabbitThreadTests.java:102)
thread 0 caught repositoryexception in run():
javax.jcr.ItemNotFoundException:
5cc05aef-5ad0-434a-9b47-4d7e3d3ba7be/{http://www.jcp.org/jcr/1.0}data
thread 0 added in -1144342173968ms, logging out of session

Anybody suggest what I'm doing wrong. 

Thanks, Thomas
--
View this message in context: http://www.nabble.com/ItemNotFoundException-when-adding-files-from-multiple-threads-t1407106.html#a3788575
Sent from the Jackrabbit - Dev forum at Nabble.com.


Re: ItemNotFoundException when adding files from multiple threads

Posted by thomasg <th...@hotmail.com>.
Thanks Stefan,

I'm hoping that the latest code from
http://svn.apache.org/repos/asf/jackrabbit/trunk should contain this fix. (I
couldn't find svn r392978) I'll get the latest code, try to get the
'correct' InvalidItemSateException and then fix it by getting each thread to
lock the item before calling save(), then unlocking. Cheers again and sorry
for the multiple posting, (i was bad).

Thomas
--
View this message in context: http://www.nabble.com/ItemNotFoundException-when-adding-files-from-multiple-threads-t1407106.html#a3845690
Sent from the Jackrabbit - Dev forum at Nabble.com.


Re: ItemNotFoundException when adding files from multiple threads

Posted by Stefan Guggisberg <st...@gmail.com>.
hi thomas,

the ItemNotFoundException is a bug; it is a side effect of a
legitimate error condition encountered during the save operation
(InvalidItemSateException).

i fixed the issue that caused the ItemNotFoundException being thrown
(svn r392978).

note that your test case still fails, this time with the correct
InvalidItemSateException since you're trying to concurrently modify
the same item from multiple threads. you can use locks to avoid
such situations.

see http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/5685/focus=5687

cheers
stefan

btw: posting the same issue concurrently in multiple threads is not
very helpful and doesn't improve response time...

On 4/6/06, thomasg <th...@hotmail.com> wrote:
>
> Hi guys,
>
> I've been trying to get multiple threads to add a file to the same
> workspace. Each thread gets its own session in its run() method, creates a
> nt:folder and adds a nt:file and nt:resource. One thread succeeds but all
> others fail with an ItemNotFoundException. The output is as follows:
>
>
> thread 1 added in 1343ms, logging out of session
> javax.jcr.ItemNotFoundException:
> 5cc05aef-5ad0-434a-9b47-4d7e3d3ba7be/{http://www.jcp.org/jcr/1.0}data
>         at
> org.apache.jackrabbit.core.ItemManager.createItemInstance(ItemManager.java:465)
>         at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:321)
>         at
> org.apache.jackrabbit.core.ItemImpl.restoreTransientItems(ItemImpl.java:709)
>         at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1209)
>         at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:806)
>         at com.axxia.test.JackrabbitThreadTests.run(JackrabbitThreadTests.java:102)
> thread 0 caught repositoryexception in run():
> javax.jcr.ItemNotFoundException:
> 5cc05aef-5ad0-434a-9b47-4d7e3d3ba7be/{http://www.jcp.org/jcr/1.0}data
> thread 0 added in -1144342173968ms, logging out of session
>
> Anybody suggest what I'm doing wrong.
>
> Thanks, Thomas
> --
> View this message in context: http://www.nabble.com/ItemNotFoundException-when-adding-files-from-multiple-threads-t1407106.html#a3788575
> Sent from the Jackrabbit - Dev forum at Nabble.com.
>
>

Re: ItemNotFoundException when adding files from multiple threads

Posted by Stefan Guggisberg <st...@gmail.com>.
hi thomas,

please provide a simple test case. i'll then investigate the issue.

thanks
stefan

On 4/6/06, thomasg <th...@hotmail.com> wrote:
>
> Hi guys,
>
> I've been trying to get multiple threads to add a file to the same
> workspace. Each thread gets its own session in its run() method, creates a
> nt:folder and adds a nt:file and nt:resource. One thread succeeds but all
> others fail with an ItemNotFoundException. The output is as follows:
>
>
> thread 1 added in 1343ms, logging out of session
> javax.jcr.ItemNotFoundException:
> 5cc05aef-5ad0-434a-9b47-4d7e3d3ba7be/{http://www.jcp.org/jcr/1.0}data
>         at
> org.apache.jackrabbit.core.ItemManager.createItemInstance(ItemManager.java:465)
>         at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:321)
>         at
> org.apache.jackrabbit.core.ItemImpl.restoreTransientItems(ItemImpl.java:709)
>         at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1209)
>         at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:806)
>         at com.axxia.test.JackrabbitThreadTests.run(JackrabbitThreadTests.java:102)
> thread 0 caught repositoryexception in run():
> javax.jcr.ItemNotFoundException:
> 5cc05aef-5ad0-434a-9b47-4d7e3d3ba7be/{http://www.jcp.org/jcr/1.0}data
> thread 0 added in -1144342173968ms, logging out of session
>
> Anybody suggest what I'm doing wrong.
>
> Thanks, Thomas
> --
> View this message in context: http://www.nabble.com/ItemNotFoundException-when-adding-files-from-multiple-threads-t1407106.html#a3788575
> Sent from the Jackrabbit - Dev forum at Nabble.com.
>
>