Discussion:
[Exist-open] NullPointerException at org.exist.xquery.update.Modification.selectAndLock(Modification.java:157)
Abdeslam Nasri
2017-07-12 22:18:00 UTC
Permalink
Hello,


We are using eXist DB 2.0 to store XML documents. The CRUD operations are
orchestrated by an Apache ServiceMix. In conf.xml we scheduled a database
backup every night through a cron XML tag. Recently we started to have a
recurrent issue in that the scheduled backup do not fire over night because
an update operation crashes in the day causing a document set to stay
locked until a database restart is performed.

On the basis of the stacktrace bellow we are suggesting a small change in
the method "org.exist.xquery.update.Modification.selectAndLock()" in
Modification.java at 157 and an unlockDocuments() in the catch block. Can
anybody help validate the suggested change ? Because the test case can only
be produced in production.

The stacktrace:
========================

An unknown error occurred: null</pre></p><h3>Caused
by:</h3><pre>javax.servlet.ServletException: An unknown error occurred: null
at org.exist.http.servlets.EXistServlet.doPost(EXistServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:229)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
at org.exist.http.urlrewrite.Forward.doRewrite(Forward.java:47)
at
org.exist.http.urlrewrite.XQueryURLRewrite.service(XQueryURLRewrite.java:211)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536)
at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at
org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
at
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.exist.xquery.update.Modification.selectAndLock(Modification.java:157)
at org.exist.xquery.update.Replace.eval(Replace.java:125)
at
org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:96)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.UserDefinedFunction.eval(UserDefinedFunction.java:153)
at
org.exist.xquery.DynamicCardinalityCheck.eval(DynamicCardinalityCheck.java:74)
at org.exist.xquery.Atomize.eval(Atomize.java:66)
at org.exist.xquery.DynamicTypeCheck.eval(DynamicTypeCheck.java:61)
at org.exist.xquery.FunctionCall.evalFunction(FunctionCall.java:324)
at org.exist.xquery.FunctionCall.eval(FunctionCall.java:229)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at
org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:96)
at
org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:96)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.UserDefinedFunction.eval(UserDefinedFunction.java:153)
at org.exist.xquery.FunctionCall.evalFunction(FunctionCall.java:324)
at org.exist.xquery.FunctionCall.eval(FunctionCall.java:229)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.SequenceConstructor.eval(SequenceConstructor.java:84)
at
org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:96)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.EnclosedExpr.eval(EnclosedExpr.java:80)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.ElementConstructor.eval(ElementConstructor.java:307)
at org.exist.xquery.DebuggableExpression.eval(DebuggableExpression.java:57)
at org.exist.xquery.DebuggableExpression.eval(DebuggableExpression.java:64)
at org.exist.xquery.LetExpr.eval(LetExpr.java:189)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.XQuery.execute(XQuery.java:257)
at org.exist.xquery.XQuery.execute(XQuery.java:204)
at org.exist.http.RESTServer.executeXQuery(RESTServer.java:1525)
at org.exist.http.RESTServer.doPost(RESTServer.java:663)
at org.exist.http.servlets.EXistServlet.doPost(EXistServlet.java:445)
... 41 more
</pre>
<h3>Caused by:</h3><pre>java.lang.NullPointerException
at org.exist.xquery.update.Modification.selectAndLock(Modification.java:157)
at org.exist.xquery.update.Replace.eval(Replace.java:125)
at
org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:96)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.UserDefinedFunction.eval(UserDefinedFunction.java:153)
at
org.exist.xquery.DynamicCardinalityCheck.eval(DynamicCardinalityCheck.java:74)
at org.exist.xquery.Atomize.eval(Atomize.java:66)
at org.exist.xquery.DynamicTypeCheck.eval(DynamicTypeCheck.java:61)
at org.exist.xquery.FunctionCall.evalFunction(FunctionCall.java:324)
at org.exist.xquery.FunctionCall.eval(FunctionCall.java:229)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at
org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:96)
at
org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:96)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.UserDefinedFunction.eval(UserDefinedFunction.java:153)
at org.exist.xquery.FunctionCall.evalFunction(FunctionCall.java:324)
at org.exist.xquery.FunctionCall.eval(FunctionCall.java:229)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.SequenceConstructor.eval(SequenceConstructor.java:84)
at
org.exist.xquery.ConditionalExpression.eval(ConditionalExpression.java:96)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.EnclosedExpr.eval(EnclosedExpr.java:80)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.ElementConstructor.eval(ElementConstructor.java:307)
at org.exist.xquery.DebuggableExpression.eval(DebuggableExpression.java:57)
at org.exist.xquery.DebuggableExpression.eval(DebuggableExpression.java:64)
at org.exist.xquery.LetExpr.eval(LetExpr.java:189)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.XQuery.execute(XQuery.java:257)
at org.exist.xquery.XQuery.execute(XQuery.java:204)
at org.exist.http.RESTServer.executeXQuery(RESTServer.java:1525)
at org.exist.http.RESTServer.doPost(RESTServer.java:663)
at org.exist.http.servlets.EXistServlet.doPost(EXistServlet.java:445)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:229)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
at org.exist.http.urlrewrite.Forward.doRewrite(Forward.java:47)
at
org.exist.http.urlrewrite.XQueryURLRewrite.service(XQueryURLRewrite.java:211)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536)
at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at
org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
at
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)


===============

The new lines are in bold font face :

protected StoredNode[] selectAndLock(Txn transaction, Sequence nodes)
throws LockException, PermissionDeniedException,
XPathException, TriggerException {
Lock globalLock =
context.getBroker().getBrokerPool().getGlobalUpdateLock();
try {
globalLock.acquire(Lock.READ_LOCK);

lockedDocuments = nodes.getDocumentSet();

// acquire a lock on all documents
// we have to avoid that node positions change
// during the modification
lockedDocuments.lock(context.getBroker(), true, false);

StoredNode ql[] = new StoredNode[nodes.getItemCount()];
for (int i = 0; i < ql.length; i++) {
Item item = nodes.itemAt(i);
if (!Type.subTypeOf(item.getType(), Type.NODE))
throw new XPathException(this, "XQuery update
expressions can only be applied to nodes. Got: " +
item.getStringValue());
NodeValue nv = (NodeValue)item;
if (nv.getImplementationType() == NodeValue.IN_MEMORY_NODE)
throw new XPathException(this, "XQuery update
expressions can not be applied to in-memory nodes.");
Node n = nv.getNode();

* // ANI : sometimes n is null, so check it first*
* if (null == n)*
* throw new XPathException(this, "XQuery update
expressions can not be continued when node value is empty. Item is: " +*
* item.getStringValue() + ", node value is: " +
nv.getStringValue());*

if (n.getNodeType() == Node.DOCUMENT_NODE)
throw new XPathException(this, "Updating the document
object is not allowed.");
ql[i] = (StoredNode) n;
DocumentImpl doc = (DocumentImpl)ql[i].getOwnerDocument();
//prepare Trigger
prepareTrigger(transaction, doc);
}
return ql;
} finally {
globalLock.release(Lock.READ_LOCK);
* //ANI : In case: nv.getNode() returns a null pointer, we should
unlock the locked documents so cron jobs can proceed.*
* unlockDocuments();*
}
}


Any help is highly appreciated.
--
Kind Regards,
Dannes Wessels
2017-07-13 09:59:35 UTC
Permalink
Hi,
Post by Abdeslam Nasri
We are using eXist DB 2.0 to store XML documents
which *exact* version of eXist are you using? Version 2.0 is dated 2013 so that is pretty out dated.
we recommend to upgrade to a more recent 3.x version.

thnx

D.
Abdeslam Nasri
2017-07-13 13:55:49 UTC
Permalink
Hi,

We are using Version : 2.0 Build : 20130207

I know it is a bit outdated but we are not going to migrate right now. Do
you have an explanation to why this happens since the nodes are locked ?
And do you think that unlocking the nodes in the finally bloc will enable
the system scheduled tasks to fire ?

As I can see on the master branche the method has not evolved since v2.0.
Post by Abdeslam Nasri
Hi,
We are using eXist DB 2.0 to store XML documents
which *exact* version of eXist are you using? Version 2.0 is dated 2013
so that is pretty out dated.
we recommend to upgrade to a more recent 3.x version.
thnx
D.
--
Kind Regards,
Abdeslam NASRI
Adam Retter
2017-07-13 23:25:50 UTC
Permalink
In eXist 3.3.0 and probably earlier, all calls to
Modification#selectAndLock are made within a try/catch/finally block (from
Delete, Insert, Rename, Replace, Update), and the finally block always
includes a call to Modification#unlockDocuments.

Having had a quick look back at the eXist 3.0 code, this also appears to be
the case. So I am not sure the locking issue you see is directly related to
that.


However, I did spot a potential problem, although I cannot say that it is
what you are experiencing but... DocumentSet#lock can throw a LockException.

However it seems the implementations of such (e.g. DefaultDocumentSet) are
buggy, because none of them record which documents were actually locked
(before the exception occurred), which means if you call unlockDocuments(),
it may cause the release of more locks than what was actually acquired.
That is quite bad! Although I doubt this really happens in practice as
LockExceptions are very rare!

Regardless, I have created a patch for the latest version of eXist to
address this, see here - https://github.com/eXist-db/exist/pull/1479
I guess you would be quite capable of porting that to your eXist 2.0 ;-)
Post by Abdeslam Nasri
Hello,
We are using eXist DB 2.0 to store XML documents. The CRUD operations are
orchestrated by an Apache ServiceMix. In conf.xml we scheduled a database
backup every night through a cron XML tag. Recently we started to have a
recurrent issue in that the scheduled backup do not fire over night because
an update operation crashes in the day causing a document set to stay
locked until a database restart is performed.
On the basis of the stacktrace bellow we are suggesting a small change in
the method "org.exist.xquery.update.Modification.selectAndLock()" in
Modification.java at 157 and an unlockDocuments() in the catch block. Can
anybody help validate the suggested change ? Because the test case can only
be produced in production.
========================
An unknown error occurred: null</pre></p><h3>Caused
by:</h3><pre>javax.servlet.ServletException: An unknown error occurred: null
at org.exist.http.servlets.EXistServlet.doPost(EXistServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(
ServletHandler.java:455)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(
SecurityHandler.java:578)
at org.eclipse.jetty.server.session.SessionHandler.
doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.
doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(
ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.
doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.
doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:135)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:229)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
at org.exist.http.urlrewrite.Forward.doRewrite(Forward.java:47)
at org.exist.http.urlrewrite.XQueryURLRewrite.service(
XQueryURLRewrite.java:211)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(
ServletHandler.java:455)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(
SecurityHandler.java:536)
at org.eclipse.jetty.server.session.SessionHandler.
doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.
doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(
ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.
doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.
doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerCollection.
handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.content(
AbstractHttpConnection.java:937)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(
AbstractHttpConnection.java:998)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(
AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.exist.xquery.update.Modification.selectAndLock(
Modification.java:157)
at org.exist.xquery.update.Replace.eval(Replace.java:125)
at org.exist.xquery.ConditionalExpression.eval(
ConditionalExpression.java:96)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.UserDefinedFunction.eval(UserDefinedFunction.java:153)
at org.exist.xquery.DynamicCardinalityCheck.eval(
DynamicCardinalityCheck.java:74)
at org.exist.xquery.Atomize.eval(Atomize.java:66)
at org.exist.xquery.DynamicTypeCheck.eval(DynamicTypeCheck.java:61)
at org.exist.xquery.FunctionCall.evalFunction(FunctionCall.java:324)
at org.exist.xquery.FunctionCall.eval(FunctionCall.java:229)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.ConditionalExpression.eval(
ConditionalExpression.java:96)
at org.exist.xquery.ConditionalExpression.eval(
ConditionalExpression.java:96)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.UserDefinedFunction.eval(UserDefinedFunction.java:153)
at org.exist.xquery.FunctionCall.evalFunction(FunctionCall.java:324)
at org.exist.xquery.FunctionCall.eval(FunctionCall.java:229)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.SequenceConstructor.eval(SequenceConstructor.java:84)
at org.exist.xquery.ConditionalExpression.eval(
ConditionalExpression.java:96)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.EnclosedExpr.eval(EnclosedExpr.java:80)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.ElementConstructor.eval(ElementConstructor.java:307)
at org.exist.xquery.DebuggableExpression.eval(
DebuggableExpression.java:57)
at org.exist.xquery.DebuggableExpression.eval(
DebuggableExpression.java:64)
at org.exist.xquery.LetExpr.eval(LetExpr.java:189)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.XQuery.execute(XQuery.java:257)
at org.exist.xquery.XQuery.execute(XQuery.java:204)
at org.exist.http.RESTServer.executeXQuery(RESTServer.java:1525)
at org.exist.http.RESTServer.doPost(RESTServer.java:663)
at org.exist.http.servlets.EXistServlet.doPost(EXistServlet.java:445)
... 41 more
</pre>
<h3>Caused by:</h3><pre>java.lang.NullPointerException
at org.exist.xquery.update.Modification.selectAndLock(
Modification.java:157)
at org.exist.xquery.update.Replace.eval(Replace.java:125)
at org.exist.xquery.ConditionalExpression.eval(
ConditionalExpression.java:96)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.UserDefinedFunction.eval(UserDefinedFunction.java:153)
at org.exist.xquery.DynamicCardinalityCheck.eval(
DynamicCardinalityCheck.java:74)
at org.exist.xquery.Atomize.eval(Atomize.java:66)
at org.exist.xquery.DynamicTypeCheck.eval(DynamicTypeCheck.java:61)
at org.exist.xquery.FunctionCall.evalFunction(FunctionCall.java:324)
at org.exist.xquery.FunctionCall.eval(FunctionCall.java:229)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.ConditionalExpression.eval(
ConditionalExpression.java:96)
at org.exist.xquery.ConditionalExpression.eval(
ConditionalExpression.java:96)
at org.exist.xquery.LetExpr.eval(LetExpr.java:142)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.UserDefinedFunction.eval(UserDefinedFunction.java:153)
at org.exist.xquery.FunctionCall.evalFunction(FunctionCall.java:324)
at org.exist.xquery.FunctionCall.eval(FunctionCall.java:229)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.SequenceConstructor.eval(SequenceConstructor.java:84)
at org.exist.xquery.ConditionalExpression.eval(
ConditionalExpression.java:96)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.EnclosedExpr.eval(EnclosedExpr.java:80)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.ElementConstructor.eval(ElementConstructor.java:307)
at org.exist.xquery.DebuggableExpression.eval(
DebuggableExpression.java:57)
at org.exist.xquery.DebuggableExpression.eval(
DebuggableExpression.java:64)
at org.exist.xquery.LetExpr.eval(LetExpr.java:189)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.LetExpr.eval(LetExpr.java:187)
at org.exist.xquery.BindingExpression.eval(BindingExpression.java:156)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.PathExpr.eval(PathExpr.java:264)
at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71)
at org.exist.xquery.XQuery.execute(XQuery.java:257)
at org.exist.xquery.XQuery.execute(XQuery.java:204)
at org.exist.http.RESTServer.executeXQuery(RESTServer.java:1525)
at org.exist.http.RESTServer.doPost(RESTServer.java:663)
at org.exist.http.servlets.EXistServlet.doPost(EXistServlet.java:445)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(
ServletHandler.java:455)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(
SecurityHandler.java:578)
at org.eclipse.jetty.server.session.SessionHandler.
doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.
doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(
ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.
doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.
doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:135)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:229)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
at org.exist.http.urlrewrite.Forward.doRewrite(Forward.java:47)
at org.exist.http.urlrewrite.XQueryURLRewrite.service(
XQueryURLRewrite.java:211)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(
ServletHandler.java:455)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(
SecurityHandler.java:536)
at org.eclipse.jetty.server.session.SessionHandler.
doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.
doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(
ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.
doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.
doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerCollection.
handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.content(
AbstractHttpConnection.java:937)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(
AbstractHttpConnection.java:998)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(
AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
===============
protected StoredNode[] selectAndLock(Txn transaction, Sequence nodes)
throws LockException, PermissionDeniedException,
XPathException, TriggerException {
Lock globalLock = context.getBroker().getBrokerPool().
getGlobalUpdateLock();
try {
globalLock.acquire(Lock.READ_LOCK);
lockedDocuments = nodes.getDocumentSet();
// acquire a lock on all documents
// we have to avoid that node positions change
// during the modification
lockedDocuments.lock(context.getBroker(), true, false);
StoredNode ql[] = new StoredNode[nodes.getItemCount()];
for (int i = 0; i < ql.length; i++) {
Item item = nodes.itemAt(i);
if (!Type.subTypeOf(item.getType(), Type.NODE))
throw new XPathException(this, "XQuery update
expressions can only be applied to nodes. Got: " +
item.getStringValue());
NodeValue nv = (NodeValue)item;
if (nv.getImplementationType() == NodeValue.IN_MEMORY_NODE)
throw new XPathException(this, "XQuery update
expressions can not be applied to in-memory nodes.");
Node n = nv.getNode();
* // ANI : sometimes n is null, so check it first*
* if (null == n)*
* throw new XPathException(this, "XQuery update
expressions can not be continued when node value is empty. Item is: " +*
* item.getStringValue() + ", node value is: " +
nv.getStringValue());*
if (n.getNodeType() == Node.DOCUMENT_NODE)
throw new XPathException(this, "Updating the document
object is not allowed.");
ql[i] = (StoredNode) n;
DocumentImpl doc = (DocumentImpl)ql[i].getOwnerDocument();
//prepare Trigger
prepareTrigger(transaction, doc);
}
return ql;
} finally {
globalLock.release(Lock.READ_LOCK);
* //ANI : In case: nv.getNode() returns a null pointer, we should
unlock the locked documents so cron jobs can proceed.*
* unlockDocuments();*
}
}
Any help is highly appreciated.
--
Kind Regards,
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
https://lists.sourceforge.net/lists/listinfo/exist-open
--
Adam Retter

eXist Core Developer
{ United Kingdom / United States }
***@exist-db.org
Loading...