Hello!
I have BaseX 8.11 running on Tomcat and need to execute some commands or XQuery for deploying xml files from elsewhere. I allready have a XQuery function for this and can do it on my local setup using for example the basexclient.
My problem is that the Tomcat is available only through HTTP and I wouldn't like to open up the function for the outside world using RESTXQ. Is there a way to "talk" with the BaseX in the Tomcat? I have full access to the machine via SSH. Another way I thought of would be to just upload the data folder from my local setup, but it doesn't feel the right way to do it.
Best regards Kristian K
Hi Kristian,
My problem is that the Tomcat is available only through HTTP and I wouldn't like to open up the function for the outside world using RESTXQ. Is there a way to "talk" with the BaseX in the Tomcat?
Have you already thought about adding the DBA interface [1]? It might be extended with new functionality to store and invoke server-side code, and you can already use it to run arbitrary XQuery expressions.
Another choice is our classical REST interface, which can also be used to run server-side queries or command scripts.
Just remember that these interfaces can potentially be accessed by other people as well, even those who are not supposed to access it, so you should e.g. change the default admin password, etc.
Best, Christian
[1] http://docs.basex.org/wiki/DBA
I have full access to the
machine via SSH. Another way I thought of would be to just upload the data folder from my local setup, but it doesn't feel the right way to do it.
Best regards Kristian K
I now got it working using the DBA. I tried it earlier, but I had problems understanding imported module file paths and file paths in general.
Since I have total control of the whole machine, I ended up in simply using absolute paths. I wonder though what would be a straightforward way to use relative paths instead, since not all users can afford knowing the absolute paths. Do you have any pointers on this?
Kristian
30.04.2015 11:47, Christian Grün kirjutas:
Hi Kristian,
My problem is that the Tomcat is available only through HTTP and I wouldn't like to open up the function for the outside world using RESTXQ. Is there a way to "talk" with the BaseX in the Tomcat?
Have you already thought about adding the DBA interface [1]? It might be extended with new functionality to store and invoke server-side code, and you can already use it to run arbitrary XQuery expressions.
Another choice is our classical REST interface, which can also be used to run server-side queries or command scripts.
Just remember that these interfaces can potentially be accessed by other people as well, even those who are not supposed to access it, so you should e.g. change the default admin password, etc.
Best, Christian
[1] http://docs.basex.org/wiki/DBA
I have full access to the
machine via SSH. Another way I thought of would be to just upload the data folder from my local setup, but it doesn't feel the right way to do it.
Best regards Kristian K
Hi Kristian,
I wonder though what would be a straightforward way to use relative paths instead, since not all users can afford knowing the absolute paths. Do you have any pointers on this?
In our ZIP distribution and with Jetty, the DBA code runs out of the box. Could you please give us more hints what you needed to do to get DBA running in your environment?
Tänan, Christian
30.04.2015 11:47, Christian Grün kirjutas:
Hi Kristian,
My problem is that the Tomcat is available only through HTTP and I wouldn't like to open up the function for the outside world using RESTXQ. Is there a way to "talk" with the BaseX in the Tomcat?
Have you already thought about adding the DBA interface [1]? It might be extended with new functionality to store and invoke server-side code, and you can already use it to run arbitrary XQuery expressions.
Another choice is our classical REST interface, which can also be used to run server-side queries or command scripts.
Just remember that these interfaces can potentially be accessed by other people as well, even those who are not supposed to access it, so you should e.g. change the default admin password, etc.
Best, Christian
[1] http://docs.basex.org/wiki/DBA
I have full access to the
machine via SSH. Another way I thought of would be to just upload the data folder from my local setup, but it doesn't feel the right way to do it.
Best regards Kristian K
There are two problems as I see it (the first one is minor and the second one is the answer to what you asked): 1) web:redirect() doesn't work with absolute paths, they instead strip off the Tomcat webapp name from the url. For example, my BaseX lives in a webapp called BaseX811, so the base-url I have, is ```http://something:port/BaseX811%60%60%60. But doing ```web:redirect('/dba')``` redirects to a url with the webapp name and port chopped off, e.g http://something/dba
2) The file module behaves strangely: ```file:current-dir()``` returns on my development setup (fedora) "/usr/share/tomcat/" which is a symbolic link on my system to the Tomcat webapps folder. In my production setup (a Bitnami virtual server with only Tomcat) it returns "/opt/bitnami/apache-tomcat/logs/" -- not the BaseX webapp folder which I would expect
```file:base-dir()``` returns on my development box the BaseX webapp folder e.g "/usr/share/tomcat/webapps/BaseX811/" (hurray!) but on my production setup it returns the empty string!
This is why I have to use absolute paths in my "deployment" code that I run from the DBA.
Vielen dank! Kristian
05.05.2015 02:24, Christian Grün kirjutas:
Hi Kristian,
I wonder though what would be a straightforward way to use relative paths instead, since not all users can afford knowing the absolute paths. Do you have any pointers on this?
In our ZIP distribution and with Jetty, the DBA code runs out of the box. Could you please give us more hints what you needed to do to get DBA running in your environment?
Tänan, Christian
30.04.2015 11:47, Christian Grün kirjutas:
Hi Kristian,
My problem is that the Tomcat is available only through HTTP and I wouldn't like to open up the function for the outside world using RESTXQ. Is there a way to "talk" with the BaseX in the Tomcat?
Have you already thought about adding the DBA interface [1]? It might be extended with new functionality to store and invoke server-side code, and you can already use it to run arbitrary XQuery expressions.
Another choice is our classical REST interface, which can also be used to run server-side queries or command scripts.
Just remember that these interfaces can potentially be accessed by other people as well, even those who are not supposed to access it, so you should e.g. change the default admin password, etc.
Best, Christian
[1] http://docs.basex.org/wiki/DBA
I have full access to the
machine via SSH. Another way I thought of would be to just upload the data folder from my local setup, but it doesn't feel the right way to do it.
Best regards Kristian K
Thanks for the hints. Once again it seems we would need to spend more time on the deployment with Tomcat. I have reopened an old issue for that [1]. Feedback from other users is welcome, too.
- web:redirect() doesn't work with absolute paths, they instead strip off
the Tomcat webapp name from the url. For example, my BaseX lives in a webapp called BaseX811, so the base-url I have, is ```http://something:port/BaseX811%60%60%60. But doing ```web:redirect('/dba')``` redirects to a url with the webapp name and port chopped off, e.g http://something/dba
I'll see if the webapp name can be embedded if the specified URL is not relative..
- The file module behaves strangely:
```file:current-dir()``` returns on my development setup (fedora) "/usr/share/tomcat/" which is a symbolic link on my system to the Tomcat webapps folder.
This is in some way correct, because the "current directory" is always defined by the application (usually the JVM) that is starting BaseX. In other words, it's advisable not to use current-dir() in web applications.
```file:base-dir()``` returns on my development box the BaseX webapp folder e.g "/usr/share/tomcat/webapps/BaseX811/" (hurray!) but on my production setup it returns the empty string!
Hm, so it seems that the base URI cannot be resolved to a local file system directory. Could you please check (e.g. in the Queries panel of the DBA) what is returned by "static-base-uri()" ?
Please keep us informed if you should encounter some more irregularities when using Tomcat.
Best, Christian
static-base-uri() returns nothing in the Queries panel in the DBA.
Kristian
05.05.2015 12:20, Christian Grün kirjutas:
Thanks for the hints. Once again it seems we would need to spend more time on the deployment with Tomcat. I have reopened an old issue for that [1]. Feedback from other users is welcome, too.
- web:redirect() doesn't work with absolute paths, they instead strip off
the Tomcat webapp name from the url. For example, my BaseX lives in a webapp called BaseX811, so the base-url I have, is ```http://something:port/BaseX811%60%60%60. But doing ```web:redirect('/dba')``` redirects to a url with the webapp name and port chopped off, e.g http://something/dba
I'll see if the webapp name can be embedded if the specified URL is not relative..
- The file module behaves strangely:
```file:current-dir()``` returns on my development setup (fedora) "/usr/share/tomcat/" which is a symbolic link on my system to the Tomcat webapps folder.
This is in some way correct, because the "current directory" is always defined by the application (usually the JVM) that is starting BaseX. In other words, it's advisable not to use current-dir() in web applications.
```file:base-dir()``` returns on my development box the BaseX webapp folder e.g "/usr/share/tomcat/webapps/BaseX811/" (hurray!) but on my production setup it returns the empty string!
Hm, so it seems that the base URI cannot be resolved to a local file system directory. Could you please check (e.g. in the Queries panel of the DBA) what is returned by "static-base-uri()" ?
Please keep us informed if you should encounter some more irregularities when using Tomcat.
Best, Christian
static-base-uri() returns nothing in the Queries panel in the DBA.
I guess I was too quick: You'll probably have to include this function in your RESTXQ code. The function returns the URI of the currently evaluated XQuery module. As queries in the Queries panel will be evaluated via xquery:eval, there is no base uri attached to them..
Kristian
05.05.2015 12:20, Christian Grün kirjutas:
Thanks for the hints. Once again it seems we would need to spend more time on the deployment with Tomcat. I have reopened an old issue for that [1]. Feedback from other users is welcome, too.
- web:redirect() doesn't work with absolute paths, they instead strip
off the Tomcat webapp name from the url. For example, my BaseX lives in a webapp called BaseX811, so the base-url I have, is ```http://something:port/BaseX811%60%60%60. But doing ```web:redirect('/dba')``` redirects to a url with the webapp name and port chopped off, e.g http://something/dba
I'll see if the webapp name can be embedded if the specified URL is not relative..
- The file module behaves strangely:
```file:current-dir()``` returns on my development setup (fedora) "/usr/share/tomcat/" which is a symbolic link on my system to the Tomcat webapps folder.
This is in some way correct, because the "current directory" is always defined by the application (usually the JVM) that is starting BaseX. In other words, it's advisable not to use current-dir() in web applications.
```file:base-dir()``` returns on my development box the BaseX webapp folder e.g "/usr/share/tomcat/webapps/BaseX811/" (hurray!) but on my production setup it returns the empty string!
Hm, so it seems that the base URI cannot be resolved to a local file system directory. Could you please check (e.g. in the Queries panel of the DBA) what is returned by "static-base-uri()" ?
Please keep us informed if you should encounter some more irregularities when using Tomcat.
Best, Christian
Some of the path issues should be resolved with the latest snapshot [1,2]:
* web:redirect will now resolve absolute paths against the name of a web app (if there is one) * root requests without trailing slash will be redirected to the same address with trailing slash
I still need your help with fn:static-base-uri, though; I couldn't reproduce it on our machines so far..
Christian
[1] http://files.basex.org/releases/latest [2] https://github.com/BaseXdb/basex/issues/1026
On Tue, May 5, 2015 at 11:20 AM, Christian Grün christian.gruen@gmail.com wrote:
Thanks for the hints. Once again it seems we would need to spend more time on the deployment with Tomcat. I have reopened an old issue for that [1]. Feedback from other users is welcome, too.
- web:redirect() doesn't work with absolute paths, they instead strip off
the Tomcat webapp name from the url. For example, my BaseX lives in a webapp called BaseX811, so the base-url I have, is ```http://something:port/BaseX811%60%60%60. But doing ```web:redirect('/dba')``` redirects to a url with the webapp name and port chopped off, e.g http://something/dba
I'll see if the webapp name can be embedded if the specified URL is not relative..
- The file module behaves strangely:
```file:current-dir()``` returns on my development setup (fedora) "/usr/share/tomcat/" which is a symbolic link on my system to the Tomcat webapps folder.
This is in some way correct, because the "current directory" is always defined by the application (usually the JVM) that is starting BaseX. In other words, it's advisable not to use current-dir() in web applications.
```file:base-dir()``` returns on my development box the BaseX webapp folder e.g "/usr/share/tomcat/webapps/BaseX811/" (hurray!) but on my production setup it returns the empty string!
Hm, so it seems that the base URI cannot be resolved to a local file system directory. Could you please check (e.g. in the Queries panel of the DBA) what is returned by "static-base-uri()" ?
Please keep us informed if you should encounter some more irregularities when using Tomcat.
Best, Christian
Hi!
I got this result ```static-base-uri() = file:/opt/bitnami/apache-tomcat/webapps/BaseX811/hans.xq```
which is the name of the file I included this temporary function for you
``` (:~ : Temporary test for debugging BaseX on Tomcat for CG on the list. : @deprecated :) declare updating function eelex:path-test() { db:output("static-base-uri() = " || static-base-uri()) }; ```
Which I summon from the DBA using this ``` xquery version "3.0" encoding "UTF-8";
import module namespace eelex = 'some-eelex' at '/opt/bitnami/apache-tomcat/webapps/BaseX811/hans.xq';
return eelex:path-test() ```
Did I do it correctly? kristian
05.05.2015 17:16, Christian Grün kirjutas:
Some of the path issues should be resolved with the latest snapshot [1,2]:
- web:redirect will now resolve absolute paths against the name of a
web app (if there is one)
- root requests without trailing slash will be redirected to the same
address with trailing slash
I still need your help with fn:static-base-uri, though; I couldn't reproduce it on our machines so far..
Christian
[1] http://files.basex.org/releases/latest [2] https://github.com/BaseXdb/basex/issues/1026
On Tue, May 5, 2015 at 11:20 AM, Christian Grün christian.gruen@gmail.com wrote:
Thanks for the hints. Once again it seems we would need to spend more time on the deployment with Tomcat. I have reopened an old issue for that [1]. Feedback from other users is welcome, too.
- web:redirect() doesn't work with absolute paths, they instead strip off
the Tomcat webapp name from the url. For example, my BaseX lives in a webapp called BaseX811, so the base-url I have, is ```http://something:port/BaseX811%60%60%60. But doing ```web:redirect('/dba')``` redirects to a url with the webapp name and port chopped off, e.g http://something/dba
I'll see if the webapp name can be embedded if the specified URL is not relative..
- The file module behaves strangely:
```file:current-dir()``` returns on my development setup (fedora) "/usr/share/tomcat/" which is a symbolic link on my system to the Tomcat webapps folder.
This is in some way correct, because the "current directory" is always defined by the application (usually the JVM) that is starting BaseX. In other words, it's advisable not to use current-dir() in web applications.
```file:base-dir()``` returns on my development box the BaseX webapp folder e.g "/usr/share/tomcat/webapps/BaseX811/" (hurray!) but on my production setup it returns the empty string!
Hm, so it seems that the base URI cannot be resolved to a local file system directory. Could you please check (e.g. in the Queries panel of the DBA) what is returned by "static-base-uri()" ?
Please keep us informed if you should encounter some more irregularities when using Tomcat.
Best, Christian
Did I do it correctly?
Absolutely!
file:/opt/bitnami/apache-tomcat/webapps/BaseX811/hans.xq```
It seems that the "file" scheme provided by Bitnami is followed by only only slash. The correct representation should be:
file://opt/bitnami/...
This could be the reason why the URI cannot be correctly resolved.
I will check out if I can make our URL resolver more tolerant without breaking general standard compliance.
Thanks, Christian
which is the name of the file I included this temporary function for you
(:~ : Temporary test for debugging BaseX on Tomcat for CG on the list. : @deprecated :) declare updating function eelex:path-test() { db:output("static-base-uri() = " || static-base-uri()) };
Which I summon from the DBA using this
xquery version "3.0" encoding "UTF-8"; import module namespace eelex = 'some-eelex' at '/opt/bitnami/apache-tomcat/webapps/BaseX811/hans.xq'; return eelex:path-test()
Did I do it correctly? kristian
basex-talk@mailman.uni-konstanz.de