WebItemProvider and sd-custom-queues

Alexander Auer March 16, 2018

Dear fellow Atlassians,

I currently encountering following problem. I want to generate WebItems with a WebItemProvider at the location sd-queues-custom. When I do that with an normal <web-item>, it works like a charm, but with an web-item-provider, I get a null reference error. The web-item-provider also works for example in other places like browse_link/project_view_all. 

Hopefully someone encountered the problem already

 

<!-- Works />
<web-item
key="my-queue" section="sd-queues-custom"><label key="my.queue.label" />
<link> $baseurl/projects/$projectKey/queues/addon/my-queue</link>
<param name="count" value="5" />
</web-item>

<!-- Not Working /> 
<web-item-provider key="queues-wu" name="user-queues" section="sd-queues-custom" class="com.foo.bar.webitemproviders.QueueProvider" />

And the WebItemProovider itself

package com.foo.bar.webitemproviders;


import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.web.api.WebItem;
import com.atlassian.plugin.web.api.model.WebFragmentBuilder;
import com.atlassian.plugin.web.api.provider.WebItemProvider;
import com.google.common.collect.Lists;

import java.util.List;
import java.util.Map;

public class QueueProvider implements WebItemProvider {

@Override
public Iterable<WebItem> getItems(Map<String, Object> context) {
final List<WebItem> links = Lists.newArrayList();

links.add(new WebFragmentBuilder(10).styleClass(""
.addParam("count","1")
.addParam("pageId","custom")
.addParam("entityId","6")
.id("issue_lnk_id1").label("Favourites 1").title("My Favourite One").webItem("sd-queues-custom").url("http://www.google.com").build());

return links;
}



}

The following log is outputted:

http-nio-2990-exec-5 ERROR admin 878x1645x1 13umv33 0:0:0:0:0:0:0:1 /rest/servicedesk/1/FOO/webfragments/sections/sd-queues-nav,servicedesk.agent.queues,servicedesk.agent.queues.ungrouped [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: null
java.lang.NullPointerException
at com.atlassian.servicedesk.internal.webfragments.WebInterfaceBeanServiceImpl.getNestedWebItemKey(WebInterfaceBeanServiceImpl.java:63)
at com.atlassian.servicedesk.internal.webfragments.WebInterfaceBeanServiceImpl.getWebItems(WebInterfaceBeanServiceImpl.java:53)
at com.atlassian.servicedesk.internal.webfragments.WebInterfaceBeanServiceImpl.getWebSections(WebInterfaceBeanServiceImpl.java:34)
at com.atlassian.servicedesk.internal.rest.webfragments.WebFragmentResource.getWebSections(WebFragmentResource.java:43)
at sun.reflect.GeneratedMethodAccessor854.invoke(Unknown Source)
... 1 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
... 19 filtered
at com.atlassian.plugins.rest.module.RestDelegatingServletFilter$JerseyOsgiServletContainer.doFilter(RestDelegatingServletFilter.java:154)
... 1 filtered
at com.atlassian.plugins.rest.module.RestDelegatingServletFilter.doFilter(RestDelegatingServletFilter.java:68)
... 32 filtered
at com.atlassian.servicedesk.internal.web.ExternalCustomerLockoutFilter.doFilter(ExternalCustomerLockoutFilter.java:56)
... 4 filtered
at com.atlassian.servicedesk.internal.web.UrlOperationalStatusCheckFilter.doFilterWhenLicensed(UrlOperationalStatusCheckFilter.java:38)
at com.atlassian.servicedesk.internal.web.OperationalStatusAwareHttpFilter.doFilter(OperationalStatusAwareHttpFilter.java:27)
... 4 filtered
at com.atlassian.servicedesk.internal.web.PopulateEyeballForRestFilter.doFilterWhenLicensed(PopulateEyeballForRestFilter.java:36)
at com.atlassian.servicedesk.internal.web.OperationalStatusAwareHttpFilter.doFilter(OperationalStatusAwareHttpFilter.java:27)
... 13 filtered
at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
... 24 filtered
at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59)
... 32 filtered
at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66)
... 1 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64)
... 16 filtered
at com.atlassian.plugins.rest.module.servlet.RestSeraphFilter.doFilter(RestSeraphFilter.java:37)
... 19 filtered
at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
... 5 filtered
at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.lambda$invokeFilterChain$0(CustomerContextSettingFilter.java:181)
at com.atlassian.servicedesk.internal.api.util.context.ReentrantThreadLocalBasedCodeContext.rteInvoke(ReentrantThreadLocalBasedCodeContext.java:137)
at com.atlassian.servicedesk.internal.api.util.context.ReentrantThreadLocalBasedCodeContext.runOutOfContext(ReentrantThreadLocalBasedCodeContext.java:90)
at com.atlassian.servicedesk.internal.utils.context.CustomerContextServiceImpl.runOutOfCustomerContext(CustomerContextServiceImpl.java:47)
at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.outOfCustomerContext(CustomerContextSettingFilter.java:174)
at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilterImpl(CustomerContextSettingFilter.java:130)
at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilter(CustomerContextSettingFilter.java:121)
... 4 filtered
at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:32)
... 8 filtered
at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
... 4 filtered
at com.atlassian.web.servlet.plugin.LocationCleanerFilter.doFilter(LocationCleanerFilter.java:36)
... 26 filtered
at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
... 23 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748) 

Thanks a lot 

1 answer

0 votes
Felipe
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 19, 2018

Hi Alexander!

 

The error is being thrown because you are not passing the required "key" property to the WebItem that is being created inside your WebItemProvider.

Try using the version of "WebFragmentBuilder" constructor that takes the key as the first parameter:

links.add(new WebFragmentBuilder("my-plugin-key:my-web-item-key", 10).styleClass("")
.addParam("count","1")
.addParam("pageId","custom")
.addParam("entityId","6")
.id("issue_lnk_id1").label("Favourites 1").title("My Favourite One").webItem("sd-queues-custom").url("http://www.google.com").build());  

 

Cheers!

Felipe.

Suggest an answer

Log in or Sign up to answer