REST calls return 404 after upgrade to 16.2 with short URL's

Hi there!
Today I upgraded my XWiki from 15.7 to 16.2.0+2 (via apt on Debian 11) and everything went very smooth [edited may 5], except for the fact that I noticed that the livedata application does not work as it is supposed to.

[edited may 5] I now remember there was an issue during the upgrade but I am not sure about the specifics. To my best memory there was an issue about not being able to locate require.js.

Errors:

  • http-nio-8080-exec-5 - https://www.homeoworld.org/authenticate/wiki/xwiki/retrieveusername] ERROR .x.i.t.InternalTemplateManager - Error while rendering template [registerinline.vm]
  • org.xwiki.rendering.RenderingException: Failed to execute renderer

Issues:

  • I cannot upload attachments.
  • Translation rendering does not work properly.
  • The requests for files that are supposed to be fetched by REST return with 404.

Screenshot:
screendump

With the previous version I made some adjustments so to achieve short url’s. What can I say, I like my url’s short :slight_smile:
So I had my URL’s nice and short for almost a year, everything worked fine in the previous version, did the upgrade to 16.2 and the mentioned issue ensued. Could the adjustments for the short URL’s be the cause of the problem? If so, what can I do to correct this?

The files I adjusted for this are:

  • xwiki.cfg: xwiki.webapppath= (left empty)
  • xwiki.cfg: xwiki.defaultservletpath= (left empty)
  • xwiki.cfg: xwiki.showviewaction=0
  • /etc/xwiki/web.xml: under RESTful API mapping, changed the url-pattern from “/bin/*” to “/*”, like so:
    <servlet-mapping>
      <servlet-name>action</servlet-name>
      <url-pattern>/*</url-pattern>
    </servlet-mapping>
  • /etc/tomcat9/web.xml: under Built In Servlet Mappings, changed the url-pattern from “/bin/*” to “/*”, like above.
  • etc/nginx/sites-available/default: Commented out everything
  • etc/nginx/sites-available/[domain.tld]: Created all neccessary rules in this file, like so:
server {
  listen       80;
  server_name  [domain.tld];
  return 301 $scheme://www.[domain.tld]$request_uri;
}

server {
  listen       80;
  server_name  www.[domain.tld];

  charset utf-8;

  # Configuration to avoid Request Entity too large error 413
  client_max_body_size 0;
  
  location /skins {
    alias /usr/lib/xwiki/skins;  
  }

  location /resources/uicomponents {
    alias /usr/lib/xwiki/resources/uicomponents;
  }

  location /resources/js {
    alias /usr/lib/xwiki/resources/js;
  }

  location /resources/css {
    alias /usr/lib/xwiki/resources/css;
  }

  location /resources/icons {
    alias /usr/lib/xwiki/resources/icons;
  }

  location /bin {
    rewrite ^/bin/(.*)$ /$1 permanent;
  }

  location = / {
    return 301 $scheme://$server_name/Main;
  }

  location / {
    # Redirect root and beyond to backend.
    proxy_pass http://localhost:8080/;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        Host $http_host;
    proxy_set_header        X-Forwarded-Proto $scheme;
  }
}

Any help is welcome, thanks in advance for any time spent on this silly issue :wink:

PS.
For some odd reason I seemed to have posted this in the wrong rubric. I corrected this today by placing it in ‘Help’. Sorry for the inconvenience.

I made a screen grab of the catalina log file.
catalina

And the full text of the tomcat9 log since today (rename from .log to .json and open in browser for easier reading):
jp-xwiki-tomcat-json-log.log (607.1 KB)

I have tried reenabling the normal URL format but this does not change the issue.

I came across an answer by @tmortagne in the post Upgrade from 16.1 to 16.2 or 16.3 failing which set me on the right way to the solution of my issue.

It appears that the web.xml in the xwiki folder of this new version has incorporated in itself some slight changes since my previous version. The important changes are:

  <filter-mapping>
    <filter-name>XWikiRESTContextInitializationFilter</filter-name>
    <servlet-name>RestletServlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

Has been changed into

  <filter-mapping>
    <filter-name>XWikiRESTContextInitializationFilter</filter-name>
    <servlet-name>RESTServlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

Please note the term RestletServlet that has changed to RESTServlet.

Another change further in the document:

  <!-- RESTful API Restlet servlet -->
  <servlet>
    <servlet-name>RestletServlet</servlet-name>
    <servlet-class>
      org.xwiki.rest.internal.XWikiRestletServlet
    </servlet-class>
  </servlet>

Has been changed into

  <!-- REST Service -->
  <servlet>
    <servlet-name>RESTServlet</servlet-name>
    <servlet-class>
      org.xwiki.rest.jersey.internal.XWikiRESTServlet
    </servlet-class>
    <multipart-config/>
  </servlet>

When I incorporated these changes in the web.xml on my XWiki and restarted Tomcat the issue was solved.

I hope that this information can be of help for anyone that faces the same kind of issues I had.

Onwards and upwards! :slight_smile:

@tmortagne could it be that we forgot to specifically document this in the RN? I know that we have generic doc that says that users need to merge these files but it could be good to mention it specifically.

@Jan-Paul-Kleijn see https://www.xwiki.org/xwiki/bin/view/ReleaseNotes/Data/XWiki/16.2.0/#HGeneralNotes as an example of the generic notice in each release.

Well, that’s embarrassing :flushed:

I must admit I did not read the release notes. I upgraded and when I saw something was not quite right I immediately thought this was caused by the short URL’s I had made.

Good point, read release notes. :laughing: