Bitbucket Server Docker Image Not Working
Asked by William Perkins:

Hello! I'm trying to run the Bitbucket docker image located here: <https://hub.docker.com/r/atlassian/bitbucket-server>

However, upon first run I encounter an error about the java version being incompatible:
>
> A fatal error has occurred {#toc-hId--1322918543}
> -------------------------------------------------
>
> The following problem occurred, which prevents Atlassian Bitbucket from starting:

*
  > The operating system or Java runtime is outdated or unsupported. To see which operating systems and JREs are supported, check our [Supported platforms](https://docs.atlassian.com/bitbucketserver/docs-076/Supported+platforms?utm_campaign=in-app-help&utm_medium=in-app-help&utm_source=stash) page.

Inside of the image that's running, the Java version reported seems to be a supported version:

```
root@bitbucket:/var/atlassian/application-data/bitbucket# java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.262-b10, mixed mode)
```

As far as I know, this image is supposed to be self-contained. I didn't see any updates for java pending through apt, either. My standard searches have come up short and I was curious if anyone else has run into this issue?

**EDIT:**

Curiosity got the best of me and I figured I would try using a higher version of Java. I edited the Dockerfile in the repo located here <https://bitbucket.org/atlassian-docker/docker-atlassian-bitbucket-server/src/master/> and after incrementing the version of adoptjdk to 11, the issue persists. The Java version displays a supported version of Java.

```
root@bitbucket:/var/atlassian/application-data/bitbucket# java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)
```

Is Bitbucket not recognizing Java correctly? I'm sortof at a loss here, I'm looking to migrate my current Atlassian architecture and Docker is an attractive option.

**Edit 2:**

I figured the log from the process would be a good idea, it looks like it's failing on initializing NIO

```
2020-09-24 23:33:35,327 INFO [main] c.a.b.i.b.BitbucketServerApplication Starting BitbucketServerApplication on bitbucket.local with PID 130 (/opt/atlassian/bitbucket/app/WEB-INF/classes started by bitbucket in /var/atlassian/application-data/bitbucket)
2020-09-24 23:33:35,329 INFO [main] c.a.b.i.b.BitbucketServerApplication No active profile set, falling back to default profiles: default
2020-09-24 23:33:36,486 INFO [main] c.a.b.i.boot.log.BuildInfoLogger Starting Bitbucket 7.5.1 (4940c58 built on Tue Aug 25 03:45:20 GMT 2020)
2020-09-24 23:33:36,486 INFO [main] c.a.b.i.boot.log.BuildInfoLogger JVM: AdoptOpenJDK OpenJDK 64-Bit Server VM 1.8.0_262-b10
2020-09-24 23:33:38,985 INFO [main] c.a.b.i.b.BitbucketServerApplication Started BitbucketServerApplication in 6.209 seconds (JVM running for 8.135)
2020-09-24 23:33:44,001 INFO [spring-startup] c.a.s.internal.home.HomeLockAcquirer Successfully acquired lock on home directory /var/atlassian/application-data/bitbucket
2020-09-24 23:33:50,698 INFO [spring-startup] c.a.s.internal.home.HomeLockAcquirer Successfully acquired lock on home directory /var/atlassian/application-data/bitbucket/shared
2020-09-24 23:33:54,393 WARN [spring-startup] com.hazelcast.instance.Node [10.88.0.4]:5701 [bitbucket] [3.12.6] No join method is enabled! Starting standalone.
2020-09-24 23:33:58,054 INFO [spring-startup] c.a.s.i.l.SetHierarchyIdsChange No repositories exist; no hierarchy IDs need to be set
2020-09-24 23:34:18,653 WARN [spring-startup] o.s.w.c.s.XmlWebApplicationContext Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'packObjectsHookHandler' defined in URL [jar:file:/opt/atlassian/bitbucket/app/WEB-INF/lib/bitbucket-git-7.5.1.jar!/com/atlassian/stash/internal/scm/git/hook/handler/CachingPackObjectsHookHandler.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gitCommandBuilderFactory' defined in com.atlassian.stash.internal.scm.git.GitWiring: Unsatisfied dependency expressed through method 'gitCommandBuilderFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gitCommandCreator' defined in com.atlassian.stash.internal.scm.git.GitWiring$NioWiring: Unsatisfied dependency expressed through method 'gitCommandCreator' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nioProcessHelper' defined in class path resource [stash-context.xml]: Invocation of init method failed; nested exception is com.atlassian.bitbucket.internal.process.NioUnsupportedException: Failed to initialize NIO
2020-09-24 23:34:18,741 INFO [spring-startup] c.a.s.internal.home.HomeLockAcquirer Releasing lock on /var/atlassian/application-data/bitbucket/shared
2020-09-24 23:34:18,935 INFO [spring-startup] c.a.s.internal.home.HomeLockAcquirer Releasing lock on /var/atlassian/application-data/bitbucket
2020-09-24 23:34:18,942 ERROR [spring-startup] c.a.j.s.w.s.JohnsonDispatcherServlet SpringMVC dispatcher [springMvc] could not be started
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'packObjectsHookHandler' defined in URL [jar:file:/opt/atlassian/bitbucket/app/WEB-INF/lib/bitbucket-git-7.5.1.jar!/com/atlassian/stash/internal/scm/git/hook/handler/CachingPackObjectsHookHandler.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gitCommandBuilderFactory' defined in com.atlassian.stash.internal.scm.git.GitWiring: Unsatisfied dependency expressed through method 'gitCommandBuilderFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gitCommandCreator' defined in com.atlassian.stash.internal.scm.git.GitWiring$NioWiring: Unsatisfied dependency expressed through method 'gitCommandCreator' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nioProcessHelper' defined in class path resource [stash-context.xml]: Invocation of init method failed; nested exception is com.atlassian.bitbucket.internal.process.NioUnsupportedException: Failed to initialize NIO
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at java.lang.Thread.run(Thread.java:748)
... 18 frames trimmed
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gitCommandBuilderFactory' defined in com.atlassian.stash.internal.scm.git.GitWiring: Unsatisfied dependency expressed through method 'gitCommandBuilderFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gitCommandCreator' defined in com.atlassian.stash.internal.scm.git.GitWiring$NioWiring: Unsatisfied dependency expressed through method 'gitCommandCreator' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nioProcessHelper' defined in class path resource [stash-context.xml]: Invocation of init method failed; nested exception is com.atlassian.bitbucket.internal.process.NioUnsupportedException: Failed to initialize NIO
... 6 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gitCommandCreator' defined in com.atlassian.stash.internal.scm.git.GitWiring$NioWiring: Unsatisfied dependency expressed through method 'gitCommandCreator' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'nioProcessHelper' defined in class path resource [stash-context.xml]: Invocation of init method failed; nested exception is com.atlassian.bitbucket.internal.process.NioUnsupportedException: Failed to initialize NIO
... 6 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nioProcessHelper' defined in class path resource [stash-context.xml]: Invocation of init method failed; nested exception is com.atlassian.bitbucket.internal.process.NioUnsupportedException: Failed to initialize NIO
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
... 5 common frames omitted
Caused by: com.atlassian.bitbucket.internal.process.NioUnsupportedException: Failed to initialize NIO
at com.atlassian.bitbucket.internal.process.nu.NuNioProcessHelper.validate(NuNioProcessHelper.java:143)
... 5 common frames omitted
Caused by: java.lang.UnsatisfiedLinkError: /var/atlassian/application-data/bitbucket/tmp/jna1746284956365791299.tmp: /var/atlassian/application-data/bitbucket/tmp/jna1746284956365791299.tmp: failed to map segment from shared object
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.Runtime.load0(Runtime.java:810)
at java.lang.System.load(System.java:1088)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
at com.sun.jna.Native.<clinit>(Native.java:195)
at com.zaxxer.nuprocess.linux.LibEpoll.<clinit>(LibEpoll.java:29)
at com.zaxxer.nuprocess.linux.LinuxProcess.<clinit>(LinuxProcess.java:40)
at com.zaxxer.nuprocess.linux.LinProcessFactory.runProcess(LinProcessFactory.java:49)
at com.zaxxer.nuprocess.NuProcessBuilder.run(NuProcessBuilder.java:273)
at com.atlassian.bitbucket.internal.process.nu.NuNioProcessHelper.validate(NuNioProcessHelper.java:138)
... 5 common frames omitted
```

A google search shows nothing of note in what causes this error, and I've ruled out SELinux being a problem as I turned it to permissive for this test.


Answers:
author: William Perkins
body: So, having a little knowledge in the Linux filesystem I did some poking around in the live container, and did the following within the container:

```
rm -rfv /var/atlassian/application-data/bitbucket/tmp
ln -sv /tmp /var/atlassian/application-data/bitbucket/tmp
```

After this, I restarted the container and Bitbucket started properly. This seems to indicate that the default tmp directory in the Bitbucket home directory isn't being created in the way to allow the files in there to be mapped into memory as far as I've been able to tell.


Tags: bitbucket-server

docker

java

server