"The origin server did not find a current representation for the target resource or is not willing to disclose that one exists" upgrading to 12.7

This issue is similar to https://forum.xwiki.org/t/the-origin-server-did-not-find-a-current-representation-for-the-target-resource-or-is-not-willing-to-disclose-that-one-exists/6965 but:

  • I’m upgrading to XWiki 12.7 (Ubuntu server)
  • In the logs I found: 07-Sep-2020 19:45:01.248 SEVERE [main] org.apache.tomcat.util.descriptor.web.WebXmlParser.parseWebXml Parse error in application web.xml file at [file:/var/lib/tomcat9/conf/web.xml] java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.org.apache.tomcat.util.buf")

So, I added to etc/tomcat9/policy.d/04webapps.policy the line:
permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.util.*";

in the first grand, so the issue desapeared but now I get:

SEVERE [main] org.apache.catalina.startup.HostConfig.deployDirectory The web application with context path [] was not deployed because it contained a deployment descriptor [/var/lib/tomcat9/webapps/ROOT/META-INF/context.xml] which may include configuration necessary for the secure deployment of the application but processing of deployment descriptors is prevented by the deployXML setting of this host. An appropriate descriptor should be created at [/etc/tomcat9/Catalina/localhost/ROOT.xml] to deploy this application.
07-Sep-2020 19:47:25.886 SEVERE [main] org.apache.catalina.startup.HostConfig.deployDirectory Error deploying web application directory [/var/lib/tomcat9/webapps/ROOT]
	java.lang.IllegalStateException: Error starting child
		at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:720)
		at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:129)
		at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:150)
		at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:140)
		at java.security.AccessController.doPrivileged(Native Method)
		at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:688)
		at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
		at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1133)
		at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1867)
		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
		at java.util.concurrent.FutureTask.run(FutureTask.java:266)

Seems you have the Java security manager turned on for Tomcat. Maybe see https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/InstallationWAR/InstallationTomcat/#HPolicyconfiguration and https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/InstallationWAR/InstallationTomcat/#HJavaSecurityManager