Hi @ll,
Re-sending from different address due to original message disappearing.
When running BaseX as a server and connecting to it my update statements are successful but when using BaseX from a jar inside the JVM - Database creation works fine - the update statements don't get committed - not visible to other clients or after restart - to the database.
Select queries work fine.
Code that - no exception - fails is:
final String xQueryUpdate = String.format("for $tab in doc('db')//tabs/tab[@id='%s'] return replace node $tab/content with %s", tabId, value); //$NON-NLS-1$ try { synchronized (SESSION) { new ClientQuery(xQueryUpdate, SESSION, SESSION.getOutputStream()).close(); // System.out.println(new XQuery(xQueryUpdate).execute(CONTEXT)); SESSION.notify(); } } catch (final IOException ioex) { ioex.printStackTrace(); }
When trying to use XQuery - In comment - I get:
org.basex.core.BaseXException: Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk@mailman.uni-konstanz.demailto:basex-talk@mailman.uni-konstanz.de
Version: BaseX 7.6
Java: Oracle Corporation, 1.7.0_10-ea
OS: Mac OS X, x86_64
Stack Trace:
java.nio.channels.OverlappingFileLockException
sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255)
sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152)
What might be the issue or have I misunderstood something?
/ Chris
Hi Chris,
this *definitely* shouldn't happen.
Could you try two things please:
1. Try with [BaseX 7.7 Beta] (close to release anyway) - we changed quite a bit with the logging, so chances are good that bug is gone anyway. As you're using BaseX as a jar, it should be a drop-in replacement. 2. Send me a complete example of the bug which I can execute (eg., including the `SESSION` declaration), so I can see what the problem was, anyway (and if it somehow could persist to the new version).
Regards, Jens
[BaseX 7.7 Beta]: http://files.basex.org/releases/latest/
Hi Jens,
I'll try the 7.6 version later today.
This is a vaadin https://vaadin.com project which might be complex to set up
Following are the BaseX specifics that are used to initialize the DB and session.
public static final DocumentBuilder BUILDER;
public static final Context CONTEXT = new Context(); public static ClientSession SESSION = null; private static BaseXServer SERVER = null;
static { try { BUILDER = DocumentBuilderFactory.newInstance().newDocumentBuilder(); if (SESSION == null) { SERVER = new BaseXServer(); SESSION = new ClientSession("localhost", 1985, "admin", "admin"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { SESSION.execute(new Open("db")); //$NON-NLS-1$ } catch (final BaseXException bxexNoDBCreatedYet) { final File emptyDB = getDB(new File(System.getProperty("catalina.base"))); //$NON-NLS-1$ SESSION.execute(new CreateDB("db", emptyDB.getPath())); //$NON-NLS-1$ SESSION.execute(new Open("db")); //$NON-NLS-1$ } } } catch (final IOException ioex) { throw new RuntimeException("Failed to initialize the BaseX server and a session to it.", ioex); //$NON-NLS-1$ } catch (final ParserConfigurationException pcex) { throw new RuntimeException("Failed to initialize the document builder.", pcex); //$NON-NLS-1$ } }
I'll let you know how the new version tests go.
What i forgot to mention is that the same statement executed from the BaseX UI work as expected.
/ Chris
On 06/08/2013 12:05, "Jens Erat" jens.erat@uni-konstanz.de wrote:
Hi Chris,
this *definitely* shouldn't happen.
Could you try two things please:
- Try with [BaseX 7.7 Beta] (close to release anyway) - we changed quite
a bit with the logging, so chances are good that bug is gone anyway. As you're using BaseX as a jar, it should be a drop-in replacement. 2. Send me a complete example of the bug which I can execute (eg., including the `SESSION` declaration), so I can see what the problem was, anyway (and if it somehow could persist to the new version).
Regards, Jens
-- Jens Erat
PGP: 350E D9B6 9ADC 2DED F5F2 8549 CBC2 613C D745 722B
Am 06.08.2013 um 10:36 schrieb ext-christopher.harper@nokia.com:
Hi @ll,
Re-sending from different address due to original message disappearing.
When running BaseX as a server and connecting to it my update statements are successful but when using BaseX from a jar inside the JVM Database creation works fine the update statements don't get committed not visible to other clients or after restart to the database.
Select queries work fine.
Code that no exception fails is:
final String xQueryUpdate = String.format("for $tab in doc('db')//tabs/tab[@id='%s'] return replace node $tab/content with %s", tabId, value); //$NON-NLS-1$ try { synchronized (SESSION) { new ClientQuery(xQueryUpdate, SESSION, SESSION.getOutputStream()).close(); // System.out.println(new XQuery(xQueryUpdate).execute(CONTEXT)); SESSION.notify(); } } catch (final IOException ioex) { ioex.printStackTrace(); }
When trying to use XQuery - In comment I get:
org.basex.core.BaseXException: Improper use? Potential bug? Your feedback is welcome: Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 7.6 Java: Oracle Corporation, 1.7.0_10-ea OS: Mac OS X, x86_64 Stack Trace: java.nio.channels.OverlappingFileLockException sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255) sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152)
What might be the issue or have I misunderstood something?
/ Chris _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Christoph,
two little observations that might help you to improve your queries:
new ClientQuery(xQueryUpdate, SESSION,
SESSION.getOutputStream()).close();
You need to execute your query, otherwise, this will be a no-op operation:
ClientQuery cq = SESSION.query(xQueryUpdate); cq.execute(); cq.close();
// System.out.println(new
XQuery(xQueryUpdate).execute(CONTEXT));
In this line, you are a circumventing the client/server context, which could lead to your error message.
If you manage to create a minimized example, that’d be helpful.
Best, Christian
Hi Christian,
Thanks, that sorted the issue!
What threw me was that queries that do a select don't need the execute call in order to work:
final String xQuery = String.format("for $tab in doc('db')//tabs/tab[@id='%s'] return data($tab/content/h3)", //$NON-NLS-1$ this.tabId); final ClientQuery checkQuery = new ClientQuery(xQuery, SSCCE.SESSION, SSCCE.SESSION.getOutputStream()); try { if (checkQuery.more()) { System.out.println(checkQuery.next()); } } finally { checkQuery.close(); }
So likely more calls execute...
I sent a SSCCE to Jens yesterday.
/ Chris
On 07/08/2013 01:05, "Christian Grün" christian.gruen@gmail.com wrote:
Hi Christoph,
two little observations that might help you to improve your queries:
new ClientQuery(xQueryUpdate, SESSION,
SESSION.getOutputStream()).close();
You need to execute your query, otherwise, this will be a no-op operation:
ClientQuery cq = SESSION.query(xQueryUpdate); cq.execute(); cq.close();
// System.out.println(new
XQuery(xQueryUpdate).execute(CONTEXT));
In this line, you are a circumventing the client/server context, which could lead to your error message.
If you manage to create a minimized example, that¹d be helpful.
Best, Christian
basex-talk@mailman.uni-konstanz.de