Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-22390

Plugin's velocity module is disabled by Confluence

XMLWordPrintable

      • If a plugin module is installed while the system is receiving HTTP traffic, and if the module contains a Velocity helper component, Confluence will sometimes disable the Velocity module of the newly-loaded plugin.

      Symptoms of this problem can be seen in the following KB articles:

      Because of the way the plugin system handles dependencies, this issue sometimes also occurs when other plugins in the system are enabled or disabled, since Confluence will disable and reenable dependent plugins when other plugin actions are performed. This inadvertent reinstall can occur even when other, unrelated plugins are installed in Confluence <3.5.3 (see CONF-22341). Unfortunately, this means that performing an action such as 'enabling plugin A' can cause a result of 'the Velocity template module in plugin B got disabled', and all of this is done without the user's knowledge.

      This occurs due to a race condition during plugin installation, when the plugin is only partially loaded and Confluence is asked to render Velocity content. In com.atlassian.confluence.setup.velocity.PluginContextItemProvider:

                  try 
                  { 
                      velocityContextModuleMap.put(descriptor.getContextKey(), descriptor.getModule()); 
                  } 
                  catch (final RuntimeException ex) 
                  { 
                      // TODO: Fire an event here? this coupling is quite crude 
                      pluginController.disablePluginModule(descriptor.getCompleteKey()); 
                  } 
      

      I attached a debugger to Confluence and found that the exception (which is silently eaten in the above RuntimeException block) is thrown by descriptor.getModule(); the inner exception for "RuntimeException ex" has the following stack trace:

      java.lang.IllegalStateException: Cannot retrieve plugin module before it is enabled: PluginModuleHolder[(unknown; not enabled)] 
      com.atlassian.confluence.plugin.module.PluginModuleHolder.getModule(PluginModuleHolder.java:97) 
      com.atlassian.confluence.plugin.descriptor.VelocityContextItemModuleDescriptor.getModule(VelocityContextItemModuleDescriptor.java:36) 
      com.atlassian.confluence.setup.velocity.PluginContextItemProvider.getContextMap(PluginContextItemProvider.java:35) 
      (...)
      

      We didn't try to reproduce this issue with the Office Connector or Doc Theme plugins directly, but we have reproduced it with two separate custom plugins with Velocity context modules, and we believe that the issue is identical. We are able to make this happen consistently by using the UPM to load a plugin with one of the impacted module types while running a script to generate traffic, such as the following:

      #!/bin/bash
      while [ true ]
      do
      	wget http://127.0.0.1:8080/display/Overview/Home
      	sleep 0.5
      done
      

      Notes

      We have recently seen this bug affecting newer versions of Confluence. The major side effect is having velocity modules related to the top navbar being disabled, so it does not load properly. The modules are:

      soyTemplateRendererHelperContext
      velocity.helper
      siteLogoHelperContext
      

      If you see this problem, proceed with the workaround below to re-enable them by removing entries for those modules from the bandana plugin map column:

      For Data Center instances, we need to shutdown all nodes to apply the workaround. Performing a rolling restart may set the modules to disabled again, even after running the query to change them.

      Workaround using UPM REST API

      The following workaround is available so you can identify if you are affected by this bug and it also describes how to fix it (for the moment) without requiring a restart.
      It makes use of UPM REST API calls through a Linux command line.

      Using the UPM REST API to identify if you are affected by this problem

      1. Get UPM token to be used on the next steps – it will be saved as an environment variable.
        CONFLUENCE_BASE_URL=<Confluence Base URL>
        ADMIN_USRNAME=<local admin account username>
        ADMIN_PWD=<local admin account password>
        
        UPM_TOKEN=$(curl -I --user $ADMIN_USRNAME:$ADMIN_PWD -H 'Accept: application/vnd.atl.plugins.installed+json' ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/?os_authType=basic' 2>/dev/null | grep 'upm-token' | cut -d " " -f 2 | tr -d '\r')
        
      2. Get the current status of soyTemplateRendererHelperContext module. If you get a JSON response from that, it means this module is disabled and you are affected by this bug.
        curl --user $ADMIN_USRNAME:$ADMIN_PWD ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.soy-key/modules/soyTemplateRendererHelperContext-key?token='${UPM_TOKEN} 2>/dev/null | grep '"enabled":false'
        
      3. Get the current status of velocity.helper module. If you get a JSON response from that, it means this module is disabled and you are affected by this bug.
        curl --user $ADMIN_USRNAME:$ADMIN_PWD ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.extra.officeconnector-key/modules/velocity.helper-key?token='${UPM_TOKEN} 2>/dev/null | grep '"enabled":false'
        
      4. Get the current status of siteLogoHelperContext module. If you get a JSON response from that, it means this module is disabled and you are affected by this bug.
        curl --user $ADMIN_USRNAME:$ADMIN_PWD ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-lookandfeel-key/modules/siteLogoHelperContext-key?token='${UPM_TOKEN} 2>/dev/null | grep '"enabled":false'
        

      Using the UPM REST API to re-enable the affected module

      1. Get UPM token to be used on the next steps – it will be saved as an environment variable.
        CONFLUENCE_BASE_URL=<Confluence Base URL>
        ADMIN_USRNAME=<local admin account username>
        ADMIN_PWD=<local admin account password>
        
        UPM_TOKEN=$(curl -I --user ${ADMIN_USRNAME}:${ADMIN_PWD} -H 'Accept: application/vnd.atl.plugins.installed+json' ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/?os_authType=basic' 2>/dev/null | grep 'upm-token' | cut -d " " -f 2 | tr -d '\r')
        
      2. Get the current status of the soyTemplateRendererHelperContext module and save it in an environment variable, using sed to change the status to enabled ("enabled":false).
        MODIFIED_JSON_OUTPUT=$(curl --user ${ADMIN_USRNAME}:${ADMIN_PWD} ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.soy-key/modules/soyTemplateRendererHelperContext-key?token='${UPM_TOKEN} 2>/dev/null | sed 's/"enabled":false/"enabled":true/')
        echo ${MODIFIED_JSON_OUTPUT}
        
      3. Update the soyTemplateRendererHelperContext module status.
        curl --user ${ADMIN_USRNAME}:${ADMIN_PWD} -H 'Content-Type: application/vnd.atl.plugins.plugin.module+json' -X PUT ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.soy-key/modules/soyTemplateRendererHelperContext-key?token='${UPM_TOKEN} --data '<manual output from ${MODIFIED_JSON_OUTPUT}>'
        
      4. Get the current status of the velocity.helper module and save it in an environment variable, using sed to change the status to enabled ("enabled":false).
        MODIFIED_JSON_OUTPUT=$(curl --user ${ADMIN_USRNAME}:${ADMIN_PWD} ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.extra.officeconnector-key/modules/velocity.helper-key?token='${UPM_TOKEN} 2>/dev/null | sed 's/"enabled":false/"enabled":true/')
        echo ${MODIFIED_JSON_OUTPUT}
        
      5. Update the velocity.helper module status.
        curl --user ${ADMIN_USRNAME}:${ADMIN_PWD} -H 'Content-Type: application/vnd.atl.plugins.plugin.module+json' -X PUT ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.extra.officeconnector-key/modules/velocity.helper-key?token='${UPM_TOKEN} --data '<manual output from ${MODIFIED_JSON_OUTPUT}>'
        
      6. Get the current status of the siteLogoHelperContext module and save it in an environment variable, using sed to change the status to enabled ("enabled":false).
        MODIFIED_JSON_OUTPUT=$(curl --user ${ADMIN_USRNAME}:${ADMIN_PWD} ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-lookandfeel-key/modules/siteLogoHelperContext-key?token='${UPM_TOKEN} 2>/dev/null | sed 's/"enabled":false/"enabled":true/')
        echo ${MODIFIED_JSON_OUTPUT}
        
      7. Update the siteLogoHelperContext module status.
        curl --user ${ADMIN_USRNAME}:${ADMIN_PWD} -H 'Content-Type: application/vnd.atl.plugins.plugin.module+json' -X PUT ${CONFLUENCE_BASE_URL}'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-lookandfeel-key/modules/siteLogoHelperContext-key?token='${UPM_TOKEN} --data '<manual output from ${MODIFIED_JSON_OUTPUT}>'
        
      8. Refresh the Confluence page and confirm the top bar is now accessible.


      If you were unable to run this workaround, don't hesitate to open a support request.

              richatkins Richard Atkins
              7c60ab039b09 Scott Dudley [Inactive]
              Votes:
              24 Vote for this issue
              Watchers:
              69 Start watching this issue

                Created:
                Updated:
                Resolved: