JavaScript minify problem after upgrade from 11.10.5 LTS to 12.10.6 LTS

Dear XWiki-Team,

we have substantial trouble upgrading XWiki 11.10.5 LTS to 12.10.6 LTS.

Our environment: Windows 10, Java 1.8.0 271, Tomcat 9.0.44 as Servlet Container, XWiki WAR installed, MySQL 5.7 DB

We tried with different database dumps (from parallel running wikis) to ensure that there is no database problem. We tried a blank installation with empty database.

We tried a local installation on a different server. We tried XWiki 13.2 and 12.10.5 instead of 12.10.6, but the following problem remains:

After upgrading, the wiki is dysfunctional, because all of the Javascript files with URL xwiki/bin/jsx are not delivered from the server to the requesting client and return error 500.
If we load the page with ?minify=false or configure in xwiki.properties debug.minify = false, it works.

The minified version throws the following error (see stack trace):

Stacktrace from Tomcat stdout-log:

2021-04-19 14:10:44,141 [http-nio-8080-exec-7 - https://localhost:8080/xwiki/bin/jsx/Main/WebHome?language=en&docVersion=1.1] WARN  c.x.x.w.XWikiAction            - Uncaught exception: Error number 0 in 11: Uncaught exception 
com.xpn.xwiki.XWikiException: Error number 0 in 11: Uncaught exception
	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:616)
	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:283)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:122)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.xwiki.wysiwyg.filter.ConversionFilter.doFilter(ConversionFilter.java:109)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:132)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: unable to create new native thread
	at java.lang.Thread.start0(Native Method)
	at java.lang.Thread.start(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.addWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.execute(Unknown Source)
	at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
	at java.util.concurrent.Executors$DelegatedExecutorService.submit(Unknown Source)
	at com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread(CompilerExecutor.java:116)
	at com.google.javascript.jscomp.Compiler.runInCompilerThread(Compiler.java:833)
	at com.google.javascript.jscomp.Compiler.performPostCompilationTasks(Compiler.java:857)
	at com.google.javascript.jscomp.Compiler.compile(Compiler.java:696)
	at com.xpn.xwiki.web.sx.JsExtension$JsCompressor.compress(JsExtension.java:118)
	at com.xpn.xwiki.web.sx.AbstractSxAction.compress(AbstractSxAction.java:123)
	at com.xpn.xwiki.web.JsxAction.compress(JsxAction.java:120)
	at com.xpn.xwiki.web.sx.AbstractSxAction.renderExtension(AbstractSxAction.java:110)
	at com.xpn.xwiki.web.JsxAction.renderExtension(JsxAction.java:113)
	at com.xpn.xwiki.web.sx.AbstractSxAction.render(AbstractSxAction.java:142)
	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:589)
	... 44 common frames omitted

Seems you need more memory. See https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/#HMemory

Not really sure if this is directly related to minification. It seems something is taking a lot of memory, and if you did not changed the memory setup during the upgrade it would be interesting to look at a memory dump to find the root cause.

If we set debug.minify = false in xwiki.properties, there is no out of memory error. The error only occurs when minify is enabled. Version 11.10.4 did not run into out of memory with the exact same wiki content and configuration. Adding memory didn’t solve the problem.

Still hard to suggest something without more details since debug.minify = false works fine for me with the standard jetty+hsqldb package (which allocates 1024m).

Have you tried with a very simple (even empty) JavaScript extension object? Like this:

  • turn debug.minify = false in xwiki.properties and restart
  • create a new page
  • edit that page with the object editor and add a new JavaScript extension object, leaving the content empty
  • save and access that page using the /xwiki/bin/jsx/That/Page
  • access then the page with /xwiki/bin/jsx/That/Page?minify=true → do you get OutOfMemoryError?
  • now edit the page again with the object editor and set the content of the JavaScript extension object to something like var test = true; and save
  • access the page using the /xwiki/bin/jsx/That/Page (reload using force clear cache), you should see the JavaScript code as you typed it
  • access the page using /xwiki/bin/jsx/That/Page?minify=true (again reload using force clear cache) → do you get the minified JavaScript? (it should be different than the unminified one). Do you get the OutOfMemoryError error?

Yes, we tried this before and now once again, exactly according to your list. Results:

No matter whether empty JSX object or JSX with some code, if we call the relevant pages with ?minify=true, we get the OutOfMemoryError in bothe cases.
Without ?minify=true, we see blank page resp. JavaScript code lines from JSX object.

OK, that’s very strange then…

It happens also with JSX from XWiki Core like Viewers page etc.

Solution: 64bit JVM. Obviously, XWiki 12.10.6 LTS is no longer compatible with 32bit JVM.
Please note: upgrade of servlet container might be necessary (in our case, it was).