Experimenting a bit with the RESTXQ interface yesterday, using basexhttp I found that the default web.xml file shipped with BaseX 7.9 has an unfortunate property. The first servlet mapping listed is
<servlet-mapping> <servlet-name>RESTXQ</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
and the last servlet mapping is the default servlet, used for static data:
<servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/static/*</url-pattern> </servlet-mapping>
If I understand the Servlet specification correctly, this pattern of mappings ensures that a request for (say) a static resource will invariably be passed to the RESTXQ interface and not to RESTXQ.
Note that there is some doubt as to whether I do understand the spec correctly: on my reading, a request for /rest/ should also be passed to RESTXQ, and it's clearly not. But I was unable to get Jetty to serve any static content with the default web.xml. I began to succeed when I moved the servlet mappings and changed their patterns, along the lines of the web.xml file I found with Andy Bunce's GraphXQ example, so the first and last are:
<servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> <!--* <url-pattern>/static/*</url-pattern> *--> </servlet-mapping>
<servlet-mapping> <servlet-name>RESTXQ</servlet-name> <url-pattern>/restxq/*</url-pattern> <!--* <url-pattern>/*</url-pattern> *--> </servlet-mapping>
There may be other ways to set the web.xml file up so that static resources are served (in particular, I don't think it's required to change "/static/*" to "/" -- but I have not experimented systematically with all options, because I'm interested in making my web application work, not in figuring out what relationship holds between the Servlet spec and Jetty's behavior.
Is this a problem others have run into? Is there a better solution?
And a related question -- before I changed the web.xml file (and after several unsuccessful changes), requests for any of
/test.xhtml /mydirectory/test.xhtml /static/test.xhtml /static/mydirectory/test.xhtml
elicited the response "Not found" (or sometimes "no function found"), but I found no entries for these requests in the BaseX logs. (And I was unsuccessful in attempting to turn Jetty's stderr or request logging on.)
Are failures of this kind not written to the BaseX logs?
If they aren't written to the BaseX logs, but would be written to Jetty logs, then I wonder if it would be helpful to have a few hints on turning Jetty logging on (and finding out where the log files get written) either in the BaseX documentation wiki or in comments in the default jetty.xml and web.xml. Since Jetty's documentation mostly assumes that its readers are Java programmers actively developing Java web apps, I for one found it unhelpful when trying to solve my problem.