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.

              Assignee:
              Matt Ryall
              Reporter:
              Matt Ryall
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: