How to properly depend on Atlassian Wiki Renderer

I have a servlet and a REST module that needs to render markup. It injects the RendererManager in the typical way and gets an instance of jiraRendererPlugin:

    private final JiraRendererPlugin jiraRendererPlugin;
    private static final IssueRenderContext NULL_ISSUE_RENDER_CONTEXT = new IssueRenderContext(null);

    @Inject
    public SearchEndpoint(JiraAuthenticationContext authenticationContext, ProjectPortalHelper projectPortalHelper, @ComponentImport RendererManager rendererManager) {
        this.authenticationContext = authenticationContext;
        this.projectPortalHelper = projectPortalHelper;
        this.jiraRendererPlugin = rendererManager.getRendererForType(AtlassianWikiRenderer.RENDERER_TYPE);
    }

This works fine when installed at runtime. However during application node startup, the plugin fails to start.

   ___ FAILED PLUGIN REPORT _____________________
    
    1 plugin failed to load during Jira startup.
    
    	'com.spacex.jira.custom-portal' - 'Custom Portals for Jira Service Desk'  failed to load.
    		Error creating bean with name 'searchEndpoint': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.spacex.jira.SearchEndpoint]: Constructor threw exception; nested exception is java.lang.IllegalStateException: The default text renderer for Jira has been disabled, please re-enable the text renderer for correct funtioning to resume.
    			Failed to instantiate [com.spacex.jira.SearchEndpoint]: Constructor threw exception; nested exception is java.lang.IllegalStateException: The default text renderer for Jira has been disabled, please re-enable the text renderer for correct funtioning to resume.
    				The default text renderer for Jira has been disabled, please re-enable the text renderer for correct funtioning to resume.
    
    		It was loaded from /var/atlassian/application-data/jira/shared/plugins/installed-plugins/custom-portal-1.0.5.jar

How do I properly require this dependency so that the plugin will wait for Atlassian markup renderer to be there? This exception appears to be thrown when there are NO renderers available.

Any help here would be greatly appreciated. I’m kinda stumped on this.

Why don’t you just store the reference to the RendererManager in the constructor and call rendererManager.getRendererForType(AtlassianWikiRenderer.RENDERER_TYPE) only when you actually use it.

1 Like

Oh well now I feel a bit silly LOL. Of course… I’ll report back.

Yes indeed, that works perfectly. I don’t need a actual instance of the rendererType until runtime so waiting until runtime for that solves my issue. Thank you again! :slight_smile: