"Required plugin com.atlassian.stash.ssh-plugin has failed to start" is displayed when accessing the Bitbucket Server web interface

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

Problem

Bitbucket Server seemingly starts without errors, but when trying to access the Bitbucket Server web interface the following (or a similar) error message is displayed:

Required plugin com.atlassian.stash.ssh-plugin has failed to start.

The log files may show one of the following messages, depending on the specific situation. Use the information below to identify which situation you're facing and the steps to resolve the problem further below.

Situation 1:

The following appears in the atlassian-bitbucket.log:

2015-03-15 21:47:23,040 ERROR [spring-startup]  o.s.o.e.i.u.c.RunnableTimedExecution Closing runnable for context NonValidatingOsgiBundleXmlApplicationContext(bundle=com.atlassian.bitbucket.ssh, config=osgibundle:/META-INF/spring/*.xml) did not finish in 10000ms; consider taking a snapshot and then shutdown the VM in case the thread still hangs
2015-03-15 21:47:23,063 ERROR [spring-startup]  c.a.plugin.manager.PluginEnabler Unable to start the following plugins due to timeout while waiting for plugin to enable: com.atlassian.bitbucket.ssh-plugin
[...]
2015-03-15 21:47:26,966 ERROR [ThreadPoolAsyncTaskExecutor::Thread 12]  o.s.b.f.s.DefaultListableBeanFactory Destroy method on bean with name 'sshScmProtocol_osgiService' threw an exception
java.lang.IllegalStateException: Invalid BundleContext.
	at org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:457) ~[org.apache.felix.framework-3.2.2.jar:na]
	at com.atlassian.bitbucket.plugin.util.EventListenerBeanRegistrar.postProcessBeforeDestruction(EventListenerBeanRegistrar.java:50) ~[bitbucket-plugin-util-3.7.1.jar:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_17]
	at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]
	... 30 frames trimmed
2015-03-15 21:47:26,971 ERROR [ThreadPoolAsyncTaskExecutor::Thread 12]  o.s.b.f.s.DefaultListableBeanFactory Destroy method on bean with name 'sshScmProtocol' threw an exception
java.lang.IllegalStateException: Invalid BundleContext.
	at org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:457) ~[org.apache.felix.framework-3.2.2.jar:na]
	at com.atlassian.bitbucket.plugin.util.EventListenerBeanRegistrar.postProcessBeforeDestruction(EventListenerBeanRegistrar.java:50) ~[bitbucket-plugin-util-3.7.1.jar:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_17]
	at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]
	... 30 frames trimmed
2015-03-15 21:47:26,973 ERROR [ThreadPoolAsyncTaskExecutor::Thread 12]  o.s.b.f.s.DefaultListableBeanFactory Destroy method on bean with name 'sshKeyService_osgiService' threw an exception
java.lang.IllegalStateException: Invalid BundleContext.
	at org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:457) ~[org.apache.felix.framework-3.2.2.jar:na]
	at com.atlassian.bitbucket.plugin.util.EventListenerBeanRegistrar.postProcessBeforeDestruction(EventListenerBeanRegistrar.java:50) ~[bitbucket-plugin-util-3.7.1.jar:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_17]
	at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]
	... 30 frames trimmed
2015-03-15 21:47:26,976 ERROR [ThreadPoolAsyncTaskExecutor::Thread 12]  o.s.b.f.s.DefaultListableBeanFactory Destroy method on bean with name 'sshConfigurationService_osgiService' threw an exception
java.lang.IllegalStateException: Invalid BundleContext.
	at org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:457) ~[org.apache.felix.framework-3.2.2.jar:na]
	at com.atlassian.bitbucket.plugin.util.EventListenerBeanRegistrar.postProcessBeforeDestruction(EventListenerBeanRegistrar.java:50) ~[bitbucket-plugin-util-3.7.1.jar:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_17]
	at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]
	... 30 frames trimmed

 

At the same time the following appears in the catalina.out log file:

15-Mar-2015 21:13:08.554 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [65,569] milliseconds.

(warning) Note: As of Bitbucket Server 5.x+, no logs are written to the BITBUCKET_INSTALL directory. The contents of catalina.out will be written to BITBUCKET_HOME/log/atlassian-bitbucket.log file.

Situation 2:

The following message appears in the atlassian-bitbucket.log file:

2014-05-01 09:27:21,749 ERROR [localhost-startStop-1]  c.a.plugin.manager.PluginEnabler Unable to start the following plugins due to timeout while waiting for plugin to enable: com.atlassian.bitbucket.
ssh-plugin

(warning) Note: This message is also found in the atlassian-bitbucket.log file for situation 1 above, however in situation 2 there are no messages in catalina.out indicating that it took a long time to generate a SecureRandom instance.


Situation 3:

The following appears in the atlassian-bitbucket.log

2015-06-10 00:26:21,021 ERROR [ThreadPoolAsyncTaskExecutor::Thread 22]  c.a.plugin.osgi.factory.OsgiPlugin Unable to start the plugin container for plugin 'com.atlassian.bitbucket.ssh-plugin'
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sshServer' defined in URL [bundle://49.0:0/META-INF/spring/atlassian-plugins-components.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.atlassian.bitbucket.internal.ssh.server.SshServer]: Constructor threw exception; nested exception is java.lang.IllegalStateException: BouncyCastle is not registered as expected
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:254) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
	at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_40]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_40]
	at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_40]
	... 17 frames trimmed
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.atlassian.bitbucket.internal.ssh.server.SshServer]: Constructor threw exception; nested exception is java.lang.IllegalStateException: BouncyCastle is not registered as expected
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
	... 5 common frames omitted
Caused by: java.lang.IllegalStateException: BouncyCastle is not registered as expected
	at com.google.common.base.Preconditions.checkState(Preconditions.java:145) ~[guava-11.0.2-atlassian-02.jar:na]
	at com.atlassian.bitbucket.internal.ssh.server.SshServer.<init>(SshServer.java:61) ~[na:na]
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
	... 5 common frames omitted

Cause

There are different causes of the problem, dependent on the specific situation as described above.

Situation 1:

The output in catalina.out shows that it takes a long time to create a secure random number, which is required for cryptographic purposes in SSH.

This is typically caused by the /dev/random device having insufficient entropy when Bitbucket Server is started. Because this device blocks until sufficient entropy is attained in the system, it blocks the SSH plugin start-up.

(info) We have seen instances of this problem occurring with Bitbucket Server installed on Google Compute Engine instances.

Situation 2:

One or more of the plugins used by Bitbucket Server have become corrupted.

Situation 3:

This issue is known to occur if the following Java option is set:

-Dsun.net.spi.nameservice.provider.1=dns,sun

Resolution

The steps to resolve the problem depend on the specific situation you've determined above.

Situation 1:

The best workaround is to specify the /dev/urandom device as the preferred entropy gathering daemon. To do this, follow these steps:

  1. Bitbucket Server 5.0+ ...

    Open <Bitbucket_Installation_Directory>/bin/_start-webapp.sh in an editor, where <Bitbucket_Installation_Directory> refers to the directory where Bitbucket Server is installed, for instance /opt/atlassian/bitbucket/5.0.0

    Up to Bitbucket Server 4.14 ...

    Open <Bitbucket_Installation_Directory>/bin/setenv.sh in an editor, where <Bitbucket_Installation_Directory> refers to the directory where Bitbucket Server is installed, for instance /opt/atlassian/bitbucket/4.6.0

  2. Locate the line starting with JVM_SUPPORT_RECOMMENDED_ARGS
  3. Within the double quotes on that line add the following value: -Djava.security.egd=file:/dev/./urandom
    After this the line should look similar to this:

    #
    # Occasionally Atlassian Support may recommend that you set some specific JVM arguments.  You can use this variable
    # below to do that.
    #
    JVM_SUPPORT_RECOMMENDED_ARGS="-Djava.security.egd=file:/dev/./urandom"

    setenv and environment variable changes in Bitbucket Server 5.0+

    Starting with Bitbucket Server 5.0, setenv.sh and setenv.bat have been removed. The options that were set in this file can now be set via environment variables. Where to set the environment variable depends on which Operating System you're running on.

    Linux

    When using the atlbitbucket service on Linux, the environment variables are ignored. You must set the parameters in _start-webapp.sh (or start-bitbucket.sh). These values will be read when the service starts.

    As an example, to set JVM_SUPPORT_RECOMMENDED_ARGS, you would add this line to the file:

    Example
    JVM_SUPPORT_RECOMMENDED_ARGS=-XX:+HeapDumpOnOutOfMemoryError

    Windows

    Set the parameter as an environment variable for the user running Bitbucket Server. For example, if you want to set JVM_SUPPORT_RECOMMENDED_ARGS, create it as an environment variable and assign the appropriate value to it. When Bitbucket Server starts using the startup scripts or service, it will pick up and apply this value.

  4. Save the file and close it
  5. Restart Bitbucket Server

If running Bitbucket Server on a virtual machine which lacks entropy, you may consider installing haveged to generate more entropy for your system.

This is a workaround. For a permanent solution you should try to determine why your system has insufficient entropy when Bitbucket Server is launched.

Situation 2:

To resolve this problem you should clear the Bitbucket Server plugin cache, which will cause Bitbucket Server to rebuild plugin cache from scratch next time it starts. Here's how to clean the plugin cache:

  1. Stop Bitbucket Server
  2. Delete the following directories (where <Bitbucket_Home_Directory> refers to the Bitbucket home directory, for instance /var/atlassian/application-data/bitbucket:
    1. <Bitbucket_Home_Directory>/plugins/.bundled-plugins
    2. <Bitbucket_Home_Directory>/plugins/.osgi-cache
  3. Start Bitbucket Server

Situation 3:

Remove the offending Java option and restart the Bitbucket Server service.

 

Last modified on May 4, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.