Behaviour of doc() changed?

Monday, 13 July 2015 · 4 messages · last reply 14 Jul 2015
ML
Marco Lettere13 Jul 2015 16:51 #
Hello, when using doc() we used to pass into it a relative (to the static base uri) filesystem path to an xml file. This was parsed without any problems. Now (basex 8.2.2) the parsing works but we get on the standard output stating that the database (named as the first path element) does not exist. I understand that the doc function first looks up the database server and then accesses the filesystem. Is it like that? Has this changed or is the exception just printed out whereas in previous versions it was not? Regards, Marco.
CG
Christian Grün14 Jul 2015 09:25 #
Hi Marco,
Quoted text · Marco Lettere · 4 lines
> when using doc() we used to pass into it a relative (to the static base uri) > filesystem path to an xml file. This was parsed without any problems. > Now (basex 8.2.2) the parsing works but we get on the standard output > stating that the database (named as the first path element) does not exist.
Could you write down the single steps for reproducing this? What I did was.. * creating a folder 'dir' on my desktop, * creating a well-formed xml file 'file.xml' in the 'dir' folder, and * running the following query from the desktop: basex "doc('dir/file.xml') I got the contents of file.xml as result without any error message.
Quoted text · Marco Lettere · 1 line
> I understand that the doc function first looks up the database server and then accesses the filesystem. Is it like that?
Exactly. It's described somewhere in the last paragraph of [1] in the documentation (...not easy to find). Cheers, Christian [1] http://docs.basex.org/wiki/Databases#XML_Documents
ML
Marco Lettere14 Jul 2015 10:22 #
Hi Christian, you're right usual mistake of sending emails in the evening. :-D This morning I setup an example that reproduced the strange issue. Added this function to restxq.xqm:
declare
  %rest:path("/doc/{$dir}")
  %rest:GET
  function page:getdoc($dir as xs:string)
{
  doc($dir || "/doc.xml")
};
Then created the file doc.xml containing "<a/>" in the folder "webapp/tmp" of basex. Invoked the function from my browser and got correctly <a/> back. But the log reports the exception attached at the end. If I put the absolute path name the exception disappears. It's minor but caused a lot of headache because we were chasing a bug and thought that this exception was the issue (while it apparently was not at the end of the day). Hope it helps. Ciao, Marco. The exception:
org.basex.core.BaseXException: Database 'tmp' was not found.
	at org.basex.core.cmd.Open.open(Open.java:92)
	at org.basex.query.QueryResources.open(QueryResources.java:357)
	at org.basex.query.QueryResources.doc(QueryResources.java:173)
	at org.basex.query.func.fn.Docs.doc(Docs.java:54)
	at org.basex.query.func.fn.FnDoc.item(FnDoc.java:16)
	at org.basex.query.func.StandardFunc.optimize(StandardFunc.java:81)
	at org.basex.query.expr.Arr.inline(Arr.java:64)
	at org.basex.query.expr.gflwor.GFLWOR.inline(GFLWOR.java:727)
	at org.basex.query.expr.gflwor.GFLWOR.inlineLets(GFLWOR.java:379)
	at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:148)
	at org.basex.query.func.StaticFunc.inlineExpr(StaticFunc.java:283)
	at org.basex.query.func.StaticFuncCall.compile(StaticFuncCall.java:71)
	at org.basex.query.MainModule.compile(MainModule.java:74)
	at org.basex.query.QueryCompiler.compile(QueryCompiler.java:113)
	at org.basex.query.QueryCompiler.compile(QueryCompiler.java:104)
	at org.basex.query.QueryContext.analyze(QueryContext.java:330)
	at org.basex.query.QueryContext.compile(QueryContext.java:319)
	at org.basex.query.QueryContext.iter(QueryContext.java:345)
	at org.basex.http.restxq.RestXqResponse.create(RestXqResponse.java:55)
	at org.basex.http.restxq.RestXqModule.process(RestXqModule.java:101)
	at org.basex.http.restxq.RestXqFunction.process(RestXqFunction.java:109)
	at org.basex.http.restxq.RestXqServlet.run(RestXqServlet.java:44)
	at org.basex.http.BaseXServlet.service(BaseXServlet.java:64)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:370)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
	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(Thread.java:745)
Quoted text · Christian Grün · 22 lines
From: Christian Grün <christian.gruen at gmail.com> Sent: Tuesday, July 14, 2015 9:25 AM To: Marco Lettere Cc: BaseX Subject: Re: [basex-talk] Behaviour of doc() changed? Hi Marco, > when using doc() we used to pass into it a relative (to the static base uri) > filesystem path to an xml file. This was parsed without any problems. > Now (basex 8.2.2) the parsing works but we get on the standard output > stating that the database (named as the first path element) does not exist. Could you write down the single steps for reproducing this? What I did was.. * creating a folder 'dir' on my desktop, * creating a well-formed xml file 'file.xml' in the 'dir' folder, and * running the following query from the desktop: basex "doc('dir/file.xml') I got the contents of file.xml as result without any error message. > I understand that the doc function first looks up the database server and then accesses the filesystem. Is it like that? Exactly. It's described somewhere in the last paragraph of [1] in the documentation (...not easy to find). Cheers, Christian [1] http://docs.basex.org/wiki/Databases#XML_Documents
CG
Christian Grün14 Jul 2015 10:55 #
Hi Marco, thanks for the details. Do you possibly have debug set to true? In that case, there is no need to worry. Best, Christian
Quoted text · Marco Lettere · 112 lines
On Tue, Jul 14, 2015 at 10:22 AM, Marco Lettere <marco.lettere at dedalus.eu> wrote: > Hi Christian, > you're right usual mistake of sending emails in the evening. :-D > This morning I setup an example that reproduced the strange issue. > > Added this function to restxq.xqm: > > declare > %rest:path("/doc/{$dir}") > %rest:GET > function page:getdoc($dir as xs:string) > { > doc($dir || "/doc.xml") > }; > > Then created the file doc.xml containing "<a/>" in the folder "webapp/tmp" of basex. > Invoked the function from my browser and got correctly <a/> back. > But the log reports the exception attached at the end. If I put the absolute path name the exception disappears. > > It's minor but caused a lot of headache because we were chasing a bug and thought that this exception was the issue (while it apparently was not at the end of the day). > > Hope it helps. > Ciao, > Marco. > > The exception: > > org.basex.core.BaseXException: Database 'tmp' was not found. > at org.basex.core.cmd.Open.open(Open.java:92) > at org.basex.query.QueryResources.open(QueryResources.java:357) > at org.basex.query.QueryResources.doc(QueryResources.java:173) > at org.basex.query.func.fn.Docs.doc(Docs.java:54) > at org.basex.query.func.fn.FnDoc.item(FnDoc.java:16) > at org.basex.query.func.StandardFunc.optimize(StandardFunc.java:81) > at org.basex.query.expr.Arr.inline(Arr.java:64) > at org.basex.query.expr.gflwor.GFLWOR.inline(GFLWOR.java:727) > at org.basex.query.expr.gflwor.GFLWOR.inlineLets(GFLWOR.java:379) > at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:148) > at org.basex.query.func.StaticFunc.inlineExpr(StaticFunc.java:283) > at org.basex.query.func.StaticFuncCall.compile(StaticFuncCall.java:71) > at org.basex.query.MainModule.compile(MainModule.java:74) > at org.basex.query.QueryCompiler.compile(QueryCompiler.java:113) > at org.basex.query.QueryCompiler.compile(QueryCompiler.java:104) > at org.basex.query.QueryContext.analyze(QueryContext.java:330) > at org.basex.query.QueryContext.compile(QueryContext.java:319) > at org.basex.query.QueryContext.iter(QueryContext.java:345) > at org.basex.http.restxq.RestXqResponse.create(RestXqResponse.java:55) > at org.basex.http.restxq.RestXqModule.process(RestXqModule.java:101) > at org.basex.http.restxq.RestXqFunction.process(RestXqFunction.java:109) > at org.basex.http.restxq.RestXqServlet.run(RestXqServlet.java:44) > at org.basex.http.BaseXServlet.service(BaseXServlet.java:64) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) > at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684) > at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503) > at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) > at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557) > at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) > at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086) > at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429) > at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) > at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020) > at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) > at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) > at org.eclipse.jetty.server.Server.handle(Server.java:370) > at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494) > at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971) > at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033) > at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644) > at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) > at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) > at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696) > at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53) > 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(Thread.java:745) > > > > ________________________________________ > From: Christian Grün <christian.gruen at gmail.com> > Sent: Tuesday, July 14, 2015 9:25 AM > To: Marco Lettere > Cc: BaseX > Subject: Re: [basex-talk] Behaviour of doc() changed? > > Hi Marco, > >> when using doc() we used to pass into it a relative (to the static base uri) >> filesystem path to an xml file. This was parsed without any problems. >> Now (basex 8.2.2) the parsing works but we get on the standard output >> stating that the database (named as the first path element) does not exist. > > Could you write down the single steps for reproducing this? What I did was.. > > * creating a folder 'dir' on my desktop, > * creating a well-formed xml file 'file.xml' in the 'dir' folder, and > * running the following query from the desktop: > > basex "doc('dir/file.xml') > > I got the contents of file.xml as result without any error message. > >> I understand that the doc function first looks up the database server and then accesses the filesystem. Is it like that? > > Exactly. It's described somewhere in the last paragraph of [1] in the > documentation (...not easy to find). > > Cheers, > Christian > > [1] http://docs.basex.org/wiki/Databases#XML_Documents

⚡Generated with XQuery