Internal Server Error: Unable to compile Soy templates exception is thrown when starting Bitbucket with Java 17
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The Bitbucket web UI is not accessible after startup and shows the following exception:

Text version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Type
Exception Report
Message
Request processing failed; nested exception is com.atlassian.soy.renderer.SoyException: Unable to compile Soy templates at: com.atlassian.bitbucket.server.bitbucket-web:server-soy-templates
Description
The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.atlassian.soy.renderer.SoyException: Unable to compile Soy templates at: com.atlassian.bitbucket.server.bitbucket-web:server-soy-templates
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
javax.servlet.http.HttpServlet.service(HttpServlet.java:529)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
com.atlassian.johnson.spring.lifecycle.LifecycleDispatcherServlet.service(LifecycleDispatcherServlet.java:131)
javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
<trimmed>
Root Cause
java.lang.ExceptionInInitializerError: Exception com.google.inject.internal.cglib.core.$CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @1c362bb2 [in thread "spring-startup
Environment
Bitbucket instances using Java 17
ℹ️ Java 17 is supported starting from Bitbucket version 8.8
Diagnosis
The atlassian-bitbucket.log
shows the following error:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2024-06-18 23:07:48,882 ERROR [http-nio-28190-exec-4] @XXD2J1x1387x4x0 1v7c1ui 127.0.0.1 "GET /mvc/error500 HTTP/1.1" c.a.s.i.web.ErrorPageController There was an unhandled exception loading [/mvc/projects]
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.atlassian.soy.renderer.SoyException: Unable to compile Soy templates at: com.atlassian.bitbucket.server.bitbucket-web:server-soy-templates
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
...
Caused by: com.atlassian.soy.renderer.SoyException: Unable to compile Soy templates at: com.atlassian.bitbucket.server.bitbucket-web:server-soy-templates
...
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalStateException: Unable to load cache item
...
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.google.inject.internal.cglib.core.$MethodWrapper
...
Caused by: java.lang.ExceptionInInitializerError: Exception com.google.inject.internal.cglib.core.$CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @ea796f1 [in thread "spring-startup"]
Cause
Bitbucket was started on Java 17 without the required JVM argument: --add-opens=java.base/java.lang=ALL-UNNAMED
See this link for more info on this flag: --add-opens
Solution
Check the JVM arguments for starting Bitbucket in the <BITBUCKET_INSTALL_DIR>/bin/_start-webapp.sh
file and ensure that --add-opens=java.base/java.lang=ALL-UNNAMED
is included.
By default, this argument should already be included in the _start-webapp.sh
file on this line:
1
JVM_JAVA_ARGS="-Djava.io.tmpdir=$BITBUCKET_HOME/tmp -Djava.library.path=$JVM_LIBRARY_PATH -XX:+IgnoreUnrecognizedVMOptions --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.naming/com.sun.jndi.ldap=ALL-UNNAMED"
However, the flag may have been removed if you have modified the _start-webapp.sh
file, or copied the file from an older Bitbucket installation directory.
The solution would be to restore the original _start-webapp.sh
file and then add any of your required customizations on top of it, ensuring that the existing JVM arguments in the script are not removed.
Was this helpful?