Issues with setting up short URLs on a Debian XWiki installation with Nginx & Jetty

Hi everyone!

I am trying to set up XWiki as installed via the Debian package, with short URLs. Jetty is used and Nginx is used as reverse-proxy. I followed the Short URL Guide and the Jetty information when used with a Debian package.

This means I did the following:

  • Add the Nginx rewrite rules and ensured they are as described in the wiki
  • Modified /etc/xwiki/xwiki.cfg so these values are now in effect:
xwiki.webapppath=
xwiki.defaultservletpath=
  • Modified /etc/xwiki/web.xml and included this snippet at the very end in the web-app block:
<servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>/*</url-pattern>
</servlet-mapping>
  • Modified /etc/xwiki/xjetty-web.xml to include this XML in the Configure block at the very end:
<Set name="contextPath">/</Set>

If I now navigate to the website, https://mydomain.tld, it redirects to https://mydomain.tld/xwiki/ and I am greeted with an error 500:

## HTTP ERROR 500 jakarta.servlet.ServletException: Failed to extract the Entity Action from URL [https://mydomain.tld/xwiki/]

Caused by:

org.xwiki.resource.CreateResourceTypeException: Invalid standard scheme URL type. The URL is missing a path segment and should be of the format [/<type>/something/...]
	at org.xwiki.url.internal.standard.StandardStringResourceTypeResolver.resolve(StandardStringResourceTypeResolver.java:56)
	at org.xwiki.url.internal.standard.StandardStringResourceTypeResolver.resolve(StandardStringResourceTypeResolver.java:43)
	at org.xwiki.url.internal.DefaultStringResourceTypeResolver.resolve(DefaultStringResourceTypeResolver.java:81)
	at org.xwiki.url.internal.DefaultStringResourceTypeResolver.resolve(DefaultStringResourceTypeResolver.java:45)
	at org.xwiki.url.internal.AbstractExtendedURLResourceTypeResolver.resolve(AbstractExtendedURLResourceTypeResolver.java:89)
	at org.xwiki.url.internal.standard.StandardExtendedURLResourceTypeResolver.resolve(StandardExtendedURLResourceTypeResolver.java:100)
	at org.xwiki.url.internal.standard.StandardExtendedURLResourceTypeResolver.resolve(StandardExtendedURLResourceTypeResolver.java:57)

How am I supposed to fix this? Please note that I skipped over these instructions in the Wiki page:

In Jetty, with the default configuration, all it takes is to deploy the XWiki web application in webapps, in a sub directory named root. Note that if you’re using the Standalone distribution (which packages Jetty and HSQLDB) then you’ll also need to:

Remove the existing webapps/root directory which contains a redirect Servlet that automatically redirects root URLs to the xwiki context. You won't need that anymore.
Rename the existing webapps/xwiki directory into webapps/root.
Remove the jetty/contexts/xwiki.xml file and thus keep only the jetty/contexts/root.xml file. Otherwise you'll get a warning in the console.

These did not look relevant to the Debian-package-based installation and I read elsewhere that the Debian package already has the necessary prerequisites. If I am however supposed to actually do as the Wiki says, I will have to perform these changes in /usr/lib/xwiki-jetty/. That path being in /usr/lib means that every Debian package update will delete the change I did or cause worse issues (since there will be symlinks invoolved), so I am very hesitant to make changes there and delete the /usr/lib/xwiki-jetty/webapps/xwiki symlink and the /usr/lib/xwiki-jetty/webapps/root/ folder and replace the latter with a symlink to /usr/lib/xwiki.

So, what is the correct way to fix this and get XWiki+Jetty+Nginx working on a Debian-package based installation? Or is this even a bug?
Thank you for your help! :slight_smile:

I meanwhile tried all possible combinations and I’m relatively sure now that this has to be a bug, or that at the very least there is some magic that I don’t understand and that would have to be documented (but I am leaning more towards bug). Therefore, I filed this bug report: Loading...

What is the structure of your webapps directory? Does it contain a root directory, a ROOT directory, an xwiki directory, or something else?

This is how it looks like:

ls -lh /usr/lib/xwiki-jetty/webapps/
total 4.0K
drwxr-xr-x 4 root root 4.0K Feb 13 15:24 root
lrwxrwxrwx 1 root root   14 Jan 28 10:27 xwiki -> /usr/lib/xwiki

Deleting the root directory and renaming the xwiki link to root does not solve the issue at all though (as the Wiki entry suggests). It would also be overridden by a package update (but I tried this anyway, just to check). What happens is that Jetty still tries to go to the xwiki app for some reason (which it then doesn’t find). Either that, or I get a selection dialog to select root (which doesn’t exist anymore) or xwiki (which doesn’t work with “Failed to extract the Entity Action from URL”).

You restarted after making those changes, right ?

Yes, of course, both xwiki via the systemd unit as well as Nginx, for good measure.