Hi,
we use BaseX in a Tomcat server on Linux.
We run multiple instances of our application as different web applications in that server. A problem we encountered is that BaseX refers to the 'user.home' property when identifying the location of its .basex configuration file. This property is related to which (Linux) user started the Tomcat server, which is unrelated to the web application that needs to start a BaseX instance.
We are now using a very awkward work-around: temporarily setting 'user.home' to the desired value, then touching a class in org.basex.core to force its initialization:
oldUserHome = System.getProperty("user.home"); System.setProperty("user.home", basexdir); if (!org.basex.core.Prop.HOME.startsWith(basexdir)) throw new java.lang.Error("BaseX property initialization failed"); System.setProperty("user.home", oldUserHome);
Could a programmatic way to initialize BaseX be provided that does depend on system properties? I understand that it will require a small amount of refactoring (given how deep this assumption is wired into the code), but it is absolutely necessary to facilitate the use of BaseX in shared environments such as Tomcat.
Thanks.
- Godmar
Dear Godmar,
as you mentioned already, the "user.home"-Property is mainly used to locate the BaseX default database settings (see .basex, .basexwin and .basexperm in your home directory). We have discussed some ideas how to make this location dynamic, e..g, move them to the directory in which a potential BaseX installation resides. For now, you could manually set the required settings (presumably the database path, DBPATH?) after initializing BaseX. This can be done e.g. via…
The BaseX API:
Context ctx = new Context(); new Set("dbpath", "/the/path/you/like").execute(ctx);
..using the c/s architecture (in which the specified database path is actually irrelevant)...
ClientSession cs = new ClientSession(...); cs.execute("set dbpath /the/path/you/like");
…or, using XQJ…
XQConnection conn = connect... conn.createExpression().executeCommand("set dbpath /...");
For any unknown, the database commands in XQJ were bound expressions and not the static context/the connection; a single call will be valid for all subsequent database calls, however.
Hope this helps, Christian
PS: reg. the location of the BaseX settings: what would be your most favorite approach?
On Sun, Jul 11, 2010 at 4:51 PM, Godmar Back godmar@gmail.com wrote:
Hi, we use BaseX in a Tomcat server on Linux. We run multiple instances of our application as different web applications in that server. A problem we encountered is that BaseX refers to the 'user.home' property when identifying the location of its .basex configuration file. This property is related to which (Linux) user started the Tomcat server, which is unrelated to the web application that needs to start a BaseX instance. We are now using a very awkward work-around: temporarily setting 'user.home' to the desired value, then touching a class in org.basex.core to force its initialization: oldUserHome = System.getProperty("user.home"); System.setProperty("user.home", basexdir); if (!org.basex.core.Prop.HOME.startsWith(basexdir)) throw new java.lang.Error("BaseX property initialization failed"); System.setProperty("user.home", oldUserHome); Could a programmatic way to initialize BaseX be provided that does depend on system properties? I understand that it will require a small amount of refactoring (given how deep this assumption is wired into the code), but it is absolutely necessary to facilitate the use of BaseX in shared environments such as Tomcat. Thanks. - Godmar
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
On Sun, Jul 11, 2010 at 11:21 AM, Christian Grün christian.gruen@gmail.comwrote:
PS: reg. the location of the BaseX settings: what would be your most favorite approach?
It needs to be something that is compatible with the BaseX command-line client. I don't think your proposed approach currently is.
In other words, I'd like to be able to prepare, inspect, backup, and restore a database from the command line.
Currently, this:
java -Duser.home=../../../../WEB-INF -cp ../../../../WEB-INF/lib/BaseX61.jar org.basex.BaseX <command here>
works because everything is tied to user.home
Also, I don't want to have to learn the meaning of individual parameters in .basex, so perhaps specifying the location of this file in an initialization call might be good?
Related to .basex, the file says it's "overwritten every time" - but it's not clear which point in time "every time" refers to.
- Godmar
It needs to be something that is compatible with the BaseX command-line client. I don't think your proposed approach currently is.
Just to let you know: this is how you can change the db path on the command-line (the other options should be irrelevant in your context unless you use the GUI or the client/server architecture):
java BaseX62.jar org.basex.BaseX -c "set dbpath /....; create ..."
Also, I don't want to have to learn the meaning of individual parameters in .basex, so perhaps specifying the location of this file in an initialization call might be good?
Yes, I got your point… Let's see what we'll go for.
Related to .basex, the file says it's "overwritten every time" - but it's not clear which point in time "every time" refers to.
This note is obsolete and will be changed in the upcoming version; you shouldn't encounter any problems changing the options.
Christian
basex-talk@mailman.uni-konstanz.de