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

VelocityUtil.getRenderedTemplate doesn't load plugin Velocity templates in OSGi plugins

XMLWordPrintable

      VelocityUtils uses the Confluence ClassLoader, so Velocity templates inside the plugin aren't visible to it.

      We need to document a workaround for this. One possible one is loading the resource manually:

      public void execute(Map params, String body, RenderContext renderContext) {
          // ... create context
          InputStream template = getClass().getClassLoader().getResourceAsStream("path/to/template.vm");
          return VelocityUtils.getRenderedContent(IOUtils.toString(template), context);
      }
      

      We should probably wrap this in some kind of helper for plugins though.

              matt@atlassian.com Matt Ryall
              matt@atlassian.com Matt Ryall
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: