title: Injecting SoyTemplateRenderer in custom Atlassian JIRA plugin
body: <p>I'm currently trying to develop a custom Jira plugin, which also uses a servlet to render a Soy template.</p>
  
  <p>This is the code of my servlet:</p>
  
  <pre><code>    /*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
  package at.fraiss.plugins.custommenuitem.servlets;
  
  import javax.servlet.*;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import java.io.IOException;
  import com.atlassian.soy.renderer.SoyTemplateRenderer;
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   *
   * @author Mario
   */
  public class SoyTemplateServlet extends HttpServlet {
  
      private SoyTemplateRenderer soyTemplateRenderer;
  
      public SoyTemplateServlet(SoyTemplateRenderer soyTemplateRenderer)
      {
          this.soyTemplateRenderer = soyTemplateRenderer;
      }
  
      @Override
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
      {
          response.setContentType("text/html");
          response.getWriter().write(getHtml());
      }
  
      public String getHtml()
      {
          Map&lt;String, Object&gt; data = new HashMap&lt;String,Object&gt;();
          data.put("isLocal", true);
          data.put("url", "http://www.example.com");
          data.put("title", "example");
          return this.soyTemplateRenderer.render("jira.webresources:soy-templates", "JIRA.Templates.Links.helpLink", data);
      }
  }
  </code></pre>
  
  <p>This is how I defined the soy template files inside the atlassian-plugin.xml descriptor:</p>
  
  <pre><code>&lt;web-resource key="soy-templates"&gt;
      &lt;dependency&gt;com.atlassian.soy.soy-template-plugin:soy-deps&lt;/dependency&gt;
  
  
      &lt;!-- Available to the server-side only --&gt;
      &lt;resource type="soy" name="links" location="links.soy"/&gt;
   
      &lt;!-- Make available to the client-side in JS as well... --&gt;
      &lt;transformation extension="soy"&gt;
          &lt;transformer key="soyTransformer"/&gt;
      &lt;/transformation&gt;
      &lt;resource type="download" name="Links.soy.js" location="links.soy"/&gt;
  &lt;/web-resource&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have added the following section to my pom.xml:</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;com.atlassian.soy&lt;/groupId&gt;
          &lt;artifactId&gt;soy-template-renderer-api&lt;/artifactId&gt;
          &lt;version&gt;4.0.4&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>and always get this error when try to acces the servlet</p>
  
  <p><code>[INFO] [talledLocalContainer] Caused by: org.springframework.beans.factory.Unsat isfiedDependencyException: Error creating bean with name 'at.fraiss.plugins.cust ommenuitem.servlets.SoyTemplateServlet': Unsatisfied dependency expressed throug h constructor argument with index 0 of type [com.atlassian.soy.renderer.SoyTempl ateRenderer]: : No qualifying bean of type [com.atlassian.soy.renderer.SoyTempla teRenderer] found for dependency: expected at least 1 bean which qualifies as au towire candidate for this dependency. Dependency annotations: {}; nested excepti on is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualif ying bean of type [com.atlassian.soy.renderer.SoyTemplateRenderer] found for dep endency: expected at least 1 bean which qualifies as autowire candidate for this  dependency. Dependency annotations: {} [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.Con structorResolver.createArgumentArray(ConstructorResolver.java:749) [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.Con structorResolver.autowireConstructor(ConstructorResolver.java:185) [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.Abs tractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanF actory.java:1139) [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.Abs tractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFa ctory.java:1042) [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.Abs tractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory. java:504) [INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.Abs tractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.ja va:342) [INFO] [talledLocalContainer]   ... 2 filtered [INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:4 97) [INFO] [talledLocalContainer]   at com.atlassian.plugin.osgi.spring.DefaultSprin gContainerAccessor.createBean(DefaultSpringContainerAccessor.java:112) [INFO] [talledLocalContainer]   at com.atlassian.plugin.module.ClassPrefixModule Factory.createModule(ClassPrefixModuleFactory.java:39) [INFO] [talledLocalContainer]   at com.atlassian.plugin.module.PrefixDelegatingM oduleFactory.createModule(PrefixDelegatingModuleFactory.java:100) [INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.descriptors.Serv letModuleDescriptor.getModule(ServletModuleDescriptor.java:48) [INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.DelegatingPlugin Servlet.&lt;init&gt;(DelegatingPluginServlet.java:33) [INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.DefaultServletMo duleManager$LazyLoadedServletReference.create(DefaultServletModuleManager.java:5 41) [INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.DefaultServletMo duleManager$LazyLoadedServletReference.create(DefaultServletModuleManager.java:5 21) [INFO] [talledLocalContainer]   at com.atlassian.util.concurrent.LazyReference$S ync.run(LazyReference.java:325) [INFO] [talledLocalContainer]   at com.atlassian.util.concurrent.LazyReference.g ...</code></p>