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

**URL:** <https://forum.xwiki.org/t/rest-calls-return-404-after-upgrade-to-16-2-with-short-urls/14580>\
**Category:** Help / Discuss\
**Tags:** rest, upgrade, url-short-friendly\
**Created:** [May 8, 2024, 6:35pm UTC](https://forum.xwiki.org/t/rest-calls-return-404-after-upgrade-to-16-2-with-short-urls/14580 "2024-05-08T18:35:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jan-Paul-Kleijn](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jan-paul-kleijn/32/7060_2.png) [@Jan-Paul-Kleijn](https://forum.xwiki.org/u/Jan-Paul-Kleijn)\
**Post date:** [May 8, 2024, 6:35pm UTC](https://forum.xwiki.org/t/rest-calls-return-404-after-upgrade-to-16-2-with-short-urls/14580/1 "2024-05-08T18:35:23Z")

</div>

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](https://forum.xwiki.org/uploads/default/original/2X/0/04102b942dd433dd93c244435f764302c707a1ad.png)

With the previous version I made some adjustments so to achieve short url’s. What can I say, I like my url’s short 🙂  
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:

```auto
    <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:

```auto
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 😉

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.

---

<div class="post-metadata">

**Author:** ![Jan-Paul-Kleijn](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jan-paul-kleijn/32/7060_2.png) [@Jan-Paul-Kleijn](https://forum.xwiki.org/u/Jan-Paul-Kleijn)\
**Post date:** [May 9, 2024, 9:39am UTC](https://forum.xwiki.org/t/rest-calls-return-404-after-upgrade-to-16-2-with-short-urls/14580/2 "2024-05-09T09:39:52Z")

</div>

I made a screen grab of the catalina log file.  
 ![catalina](https://forum.xwiki.org/uploads/default/original/2X/2/26e37ae04beac49e4d90054396412d4e629802b5.png)

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](https://forum.xwiki.org/uploads/short-url/s56uB6EPT2pukRDJh39riaE9gB3.log) (607.1 KB)

---

<div class="post-metadata">

**Author:** ![Jan-Paul-Kleijn](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jan-paul-kleijn/32/7060_2.png) [@Jan-Paul-Kleijn](https://forum.xwiki.org/u/Jan-Paul-Kleijn)\
**Post date:** [May 25, 2024, 7:27am UTC](https://forum.xwiki.org/t/rest-calls-return-404-after-upgrade-to-16-2-with-short-urls/14580/3 "2024-05-25T07:27:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jan-Paul-Kleijn](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jan-paul-kleijn/32/7060_2.png) [@Jan-Paul-Kleijn](https://forum.xwiki.org/u/Jan-Paul-Kleijn)\
**Post date:** [May 28, 2024, 3:29pm UTC](https://forum.xwiki.org/t/rest-calls-return-404-after-upgrade-to-16-2-with-short-urls/14580/4 "2024-05-28T15:29:24Z")

</div>

I came across an answer by @tmortagne in the post [Upgrade from 16.1 to 16.2 or 16.3 failing](https://forum.xwiki.org/t/upgrade-from-16-1-to-16-2-or-16-3-failing/14662) 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:

```auto
  <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

```auto
  <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:

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

```

Has been changed into

```auto
  <!-- 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! 🙂

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [May 28, 2024, 3:36pm UTC](https://forum.xwiki.org/t/rest-calls-return-404-after-upgrade-to-16-2-with-short-urls/14580/5 "2024-05-28T15:36:01Z")

</div>

@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](https://www.xwiki.org/xwiki/bin/view/ReleaseNotes/Data/XWiki/16.2.0/#HGeneralNotes) as an example of the generic notice in each release.

---

<div class="post-metadata">

**Author:** ![Jan-Paul-Kleijn](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jan-paul-kleijn/32/7060_2.png) [@Jan-Paul-Kleijn](https://forum.xwiki.org/u/Jan-Paul-Kleijn)\
**Post date:** [May 28, 2024, 3:47pm UTC](https://forum.xwiki.org/t/rest-calls-return-404-after-upgrade-to-16-2-with-short-urls/14580/6 "2024-05-28T15:47:13Z")

</div>

Well, that’s embarrassing 😳

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. 😆
