It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to use TemplateRenderer in JIRA7 Plugin

Tuncay Senturk Community Leader Oct 20, 2015

Hi,

 

I am not sure if I am doing something wrong but I am getting errors while trying to use TemplateRenderer in JIRA7 plugin development.

Here is the exception

Unable to create new reference 
LazyLoadedServletReference{descriptor=com.mycompany.helloworld:
my-servlet (null), 
servletContext=org.apache.catalina.core.ApplicationContextFacade@21bedb6d}
[INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference$InitializationException: 
java.lang.NoClassDefFoundError: com/atlassian/templaterenderer/TemplateRenderer
Caused by: java.lang.ClassNotFoundException: com.atlassian.templaterenderer.TemplateRenderer not found by com.mycompany.helloworld [204]

 

Here is the dependency I defined to pom.xml

<dependency>
   <groupId>com.atlassian.templaterenderer</groupId>
   <artifactId>atlassian-template-renderer-api</artifactId>
   <version>1.5.9</version>
   <scope>provided</scope>
</dependency>

 

Component import in atlassian-plugin.xml

<component-import key="templateRenderer" 
    interface="com.atlassian.templaterenderer.TemplateRenderer" />

 

And the servlet's get method

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
	final Map<String, Object> context = initVelocityContext(resp);
	renderer.render(TEMPLATE_PATH, context, resp.getWriter());
}

 

Any comment would be much appreciated.

 

Tuncay

3 answers

1 accepted

1 vote
Answer accepted
Tuncay Senturk Community Leader Oct 24, 2015

Mystery is gone,

I faced all problems again just after switching to a PostgreSql database from H2. So, everything worked because I did not try it with Postgre.

Here was the first error

jira Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.of([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet

 

Then I remembered that in JIRA 7, guava version changed to 18.0

This is the problem. PostgreSql driver's dependency guava overrides JIRA's guava.

I added an exclusion as below

<dependency>
	<groupId>postgresql</groupId>
	<artifactId>postgresql</artifactId>
	<version>${postgre.version}</version>
	<scope>test</scope>
	<exclusions>
		<exclusion>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
		</exclusion>
	</exclusions>
</dependency>

 

Now, I have running JIRA 7 with my running add-ons.

 

Thanks for anyone tried to help.

jacob delddd Jul 05, 2018

Thanks! Seems to work! Where did you find this info?

Tuncay Senturk Community Leader Jul 05, 2018

Almost three years passed, I do not remember :)

What I remember is, it was a very bad headache

2 votes
Filip Rogaczewski Oct 22, 2015

Hey, 

What you have in atlassian-plugin.xml seems fine. I am doing this in more less the same way and it works. As usual, the devil is in the details. Do you have an Import-Package for com.atlassian.templaterenderer.* package in your maven-jira-plugin configuration? 

You can also see how this is used in the class WebHookAdminServlet from this repository https://bitbucket.org/atlassian/atlassian-webhooks-plugin

Tuncay Senturk Community Leader Oct 22, 2015

Thanks for your kind response Filip, pom.xml does not have com.atlassian.templaterenderer.* in Import-Package element. Does it have to? Actually, there was nothing wrong before I tried to add JIRA 7 support. I am not sure but I think Spring bean scanner does not run for my add-on.

Filip Rogaczewski Oct 22, 2015

This is relatively easy to configure sprint bean scanner badly :) It didn't work for me for the first time. Can you show me your MANIFEST or at least ensure that in MANIFEST.MF there is an import for com.atlassian.templaterenderer.* There should be in my opinion, using <component-import> doesn't make this Import appear automatically.

Tuncay Senturk Community Leader Oct 22, 2015

I can share whole MANIFEST.MF but shortly I can say there is one templaterenderer. ",com.at lassian.sal.api.transaction;resolution:=optional;version="[3.0,4)",co m.atlassian.sal.api.user;resolution:=optional;version="[3.0,4)",com.a tlassian.templaterenderer;resolution:=optional;version="[1.0,2)",com. atlassian.upm.api.license;resolution:=optional In the meantime I am trying to do something and now I get following exception. Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.mycompany.helloworld [178]: Unable to resolve 178.0: missing requirement [178.0] osgi.wiring.package; (&(osgi.wiring.package=com.atlassian.templaterenderer)(version>=1.0.0)(!(version>=2.0.0)))

0 votes
Tuncay Senturk Community Leader Oct 23, 2015

Hi again,

I think I finally succeeded on injecting services. I really did many many things but as far as I remember

  • I gave up using atlassian-spring-scanner-annotation and atlassian-spring-scanner-runner
  • Added spring libraries to dependencies (spring-osgi-core, spring-beans)
  • Added guava 18.0 to dependencies
  • Import-Package = *;version="0";resolution:=optional

I am not sure which had the affect but I am scared to rollback all I did and understand which is the right step.

However, now I have the exact same problem as this (https://answers.atlassian.com/questions/14213177/uniforminterfaceexception-failed-to-disable-onboarding-in-jira-6.4.1)

Creating issue within integration test fails. Actually I ran into this problem before (while migrating to 6.4.x) and I switched back to 6.3.x Now I have 7.0.0-1 and the same problem rises.

At the moment I can not run my tests which have create/update issue cases. Are you aware of this problem? Is that a bug or am I missing something?

Thanks for your interest

Looking forward to your response

Tuncay

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in United States

Topic Tuesday: Agile

Another week, another Topic Tuesday!  Agile has been on my mind a lot lately because I've seen good implementations and bad implementations, but now as a Jira admin it matters more to me whether...

36 views 0 0
View post

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you