Hi Christian,

Thanks for your answer. I am back in my office only today, and try to implement your recommendation:
making sure that every sessions is created and used by only one thread.

It seems that the java.lang.IllegalMonitorStateException
at org.basex.core.locks.DBLocking.acquire
and org.basex.core.locks.DBLocking.release

does not occur anymore.

But the java.util.ConcurrentModificationException
at org.basex.core.users.User.find

is still happening.

What I did is basically, in the test application, replace all session creations

try (final Session session = new LocalSession(rootContext, ...)) {
 ...
}
catch {...}

by

Thread t = new Thread(new Runnable() { public void run() {
try (final Session session = new LocalSession(rootContext, ...)) {
 ...
}
catch {...}

     }
})
;

Not very elegant but should be enough to make sure every session is executed in its own Java thread.


Am I still missing something ?

Thank you very much for your help, it is very appreciated.

Regards

Simon


On Tue, Apr 7, 2015 at 12:16 PM, Christian Grün <christian.gruen@gmail.com> wrote:
Hi Simon,

Thanks for the detailed description of your setup and your test code.

In BaseX, every session needs to be executed in a separate Java
thread. The exceptions will e.g. disappear if you pass on your admin
session to the store() and updateMetaStore() functions (or if you run
these operations in a separate thread).

Hope this helps,
Christian


On Thu, Apr 2, 2015 at 1:58 PM, Simon Chatelain <schatela@gmail.com> wrote:
> Hello all,
>
> I have the following problem.
>
> Using:
>
> BaseX 8.1.1 beta cf713e2 (20150328.133759)
> Java 1.8.0_31
> Windows 7
>
> The context: I have several sources of data from which I receive XML
> documents. My application will create a collection for each of these sources
> and store each received document into the collection corresponding to the
> source, and then update some kind of metadata about the collection. The
> metadata of all collections are stored into a common collection. Each source
> is handled by a different thread.
> I am using an embedded BaseX, and access to it through LocalSession.
>
> Now the problem is that after a certain amount of time (not constant, could
> be seconds or minutes) there is some exceptions.
> Either: java.lang.IllegalMonitorStateException
> at org.basex.core.locks.DBLocking.acquire
> and org.basex.core.locks.DBLocking.release
>
> Or: java.util.ConcurrentModificationException
> at org.basex.core.users.User.find
>
> I put the full stack trace in attachment.
>
> I build a test application that mimic what happens in the real application
> and it seems to exhibit the same problem. The source of this test
> application is attached
>
> My question: Am I doing something wrong, or is there a bug in BaseX?
>
> Thanks a lot
>
> Simon