Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Jira Plugin development | Servlet issue

I am a student working on developing a plugin for JIRA, and have been having trouble getting my servlet to read my html file. So now I wonder which annotations are right to use ?, and what dependencies?. I don't get any error messages, I just can't open the index.vm page.

Would really appreciate if anyone could take a look at my code in the link that i  attach below, or just help me find the right person who is knowledgeable in this area.

Thanks for help :)

https://stackoverflow.com/questions/66554458/jira-plugin-development-servlet-issue

1 answer

1 accepted

0 votes
Answer accepted

Hi @Rickard Forslund , welcome on the community :)

When developing with Atlassian SDK, you need to add servlet description to atlassian-plugin.xml as described in this "how to" article

https://developer.atlassian.com/server/jira/platform/servlet/

I don't know if it is what you need, but eventually get back to me so we can fix it :)

i Martin, first of all I want to thank you for taking your time to look at my problem, appreciated! I double checked my atlassian-plugin.xml file and it seems that I already have a description in my servlet.

<description key="sumalizer-servlet.description">The Sumalizer Servlet Plugin</description>

 

what could it be besides that?, any thoughts?

HI @Rickard Forslund , ok, I didn't check it precisely, I thought link leads to some "old" stackoverflow issue... sorry :).

I would adjust "variables" and "constructor" part to this:

    private final VelocityManager velocityManager;
    private final PageBuilderService pageBuilderService;
    private final IssueManager im;
    private final TemplateRenderer tr;


    private static final Logger log = LoggerFactory.getLogger(
            SumalizerServlet.class
    );

    @Autowired
    public SumalizerServlet(@ComponentImport VelocityManager velocityManager, 
@ComponentImport PageBuilderService pageBuilderService,
@ComponentImport IssueManager im,
@ComponentImport TemplateRenderer tr)
{ this.velocityManager = velocityManager; this.pageBuilderService = pageBuilderService; this.im = im; this.tr = tr; }

where Autowired is from package 

org.springframework.beans.factory.annotation

I would also add some logging to doGet method. It is weird there are no errors in your atlassian-jira.log log file. 

Ye okay, I changed what you said, I already had dependency from all 100 attempts I already made hehe,  and now I actually get error messages again, saying.

 

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.i3tex.plugin.servlet.SumalizerServlet': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.velocity.VelocityManager]: No qualifying bean of type [com.atlassian.velocity.VelocityManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.velocity.VelocityManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:342)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.osgi.spring.DefaultSpringContainerAccessor.createBean(DefaultSpringContainerAccessor.java:97)
at com.atlassian.plugin.module.ClassPrefixModuleFactory.createModule(ClassPrefixModuleFactory.java:35)
at com.atlassian.plugin.module.PrefixDelegatingModuleFactory.createModule(PrefixDelegatingModuleFactory.java:88)
at com.atlassian.plugin.servlet.descriptors.ServletModuleDescriptor.getModule(ServletModuleDescriptor.java:43)
at com.atlassian.plugin.servlet.DelegatingPluginServlet.<init>(DelegatingPluginServlet.java:30)
at com.atlassian.plugin.servlet.DefaultServletModuleManager$LazyLoadedServletReference.create(DefaultServletModuleManager.java:545)
at com.atlassian.plugin.servlet.DefaultServletModuleManager$LazyLoadedServletReference.create(DefaultServletModuleManager.java:529)
at com.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:325)
at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:143)
... 233 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.velocity.VelocityManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)  

ye okay, i changed what you said, i already had the dependency from all the 100 attempts i already made hehe, and now i actualy getting some errors

And should the Class realy be annotated with @Component?

 

errors.png

Hi @Rickard Forslund , yes, @Component and @Autowired annotations are correct... the question is why VelocityManager is not loaded... I will try to check it, but will need some time.

Okay sure, getin touch if you manage to solve anything Martin :)

I found one snippet of code we have and it uses 

com.atlassian.jira.template.VelocityTemplatingEngine

Could you give it a try? You just need to replace VelocityManager with VelocityTemplatingEngine in constructor and class properties.

Snippet of code we use is:



private void addContextToParams(final Map<String, Object> templateParams) {
templateParams.put("baseUrl", applicationPropertiesFacade.getBaseUrl());
templateParams.put("runDate", LocalDate.now().format(DATE_FORMATTER));
}
private String constructEmailBody(final String templatePath, final Map<String, Object> templateParams) {
addContextToParams(templateParams);

return velocityTemplatingEngine.render(TemplateSources.fragment(getTemplateContent(templatePath)))
.applying(templateParams)
.asHtml();
}

private String getTemplateContent(final String resourceName) {
try {
return IOUtils.toString(this.getClass().getResourceAsStream(resourceName), Charset.defaultCharset());
} catch (IOException e) {
// handle exception
}
}

 and resourceName is path to your template, in your case it should be

"/templates/index.vm"

Hi again @Martin Bayer _MoroSystems_ s_r_o__ , I have been busy so haven't got time to answer you, I tried with your solution to the problem but didn't manage to get it to work , but got another tip that I could use webwork instead and that it would basicly work the same way, so i tried it out and  finally  got it to work! Now I try to make an api call to: jira/rest/api/2/search. but don't really know how to proceed, do you have some awesome tips or good approach to me? :), i also want to be able to pass in a jql string and get the information to a table on my webwork page,  Thanks for all your help

Hi @Rickard Forslund could you please create new topic and mention me eventually? We must try to have the Community portal as clean as possible.

But one small hint can be... In Java code, I would use SearchService (https://docs.atlassian.com/software/jira/docs/api/7.6.1/index.html?com/atlassian/jira/bc/issue/search/SearchService.html) instead of REST API, if there is no reason to use REST API.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

167 views 6 7
Read article

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