Jira ScriptConsole ServiceDesk QueueService Class Cast Exception

Hi,

when i try to get an QueueService Object in the Scriptrunner Script Console i get an error:

ScriptConsole - Input

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.queue.QueueService

def queueService = ComponentAccessor.getOSGiComponentInstanceOfType(QueueService.class)

Java Error

java.lang.IllegalStateException: Unable to resolve component: interface com.atlassian.servicedesk.api.queue.QueueService
	at com.atlassian.jira.component.ComponentAccessorWorker.getOSGiComponentInstanceOfType(ComponentAccessorWorker.java:68)
	at com.atlassian.jira.component.ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.java:279)
	at com.atlassian.jira.component.ComponentAccessor$getOSGiComponentInstanceOfType$32.call(Unknown Source)
	at Script500.run(Script500.groovy:4)
Caused by: java.lang.ClassCastException: Cannot cast com.atlassian.servicedesk.internal.feature.queue.QueueServiceImpl to com.atlassian.servicedesk.api.queue.QueueService
	at com.atlassian.jira.plugin.OsgiServiceTrackerCacheImpl.getOsgiComponentOfType(OsgiServiceTrackerCacheImpl.java:65)
	at com.atlassian.jira.component.pico.ComponentManager.getOSGiComponentInstanceOfType(ComponentManager.java:506)
	at com.atlassian.jira.component.ComponentAccessorWorker.getOSGiComponentInstanceOfType(ComponentAccessorWorker.java:66)
	... 3 more

Other objects from the ServiceDesk java api i can create like the example above eg. the
RequestTypeService without problems.

import com.atlassian.servicedesk.api.requesttype.RequestTypeService

def requestTypeService = ComponentAccessor.getOSGiComponentInstanceOfType(RequestTypeService.class)

Hi there,

Did you sovle the issue? I have the same with calling my custom plugin from scriptrunner in jire server

Regards,
Eugene

Hi Eugene,

unfortunately not. It seems to be bug.

Best Regards

Jörg

Hi @joewe74,

I’ve tried this piece of code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.queue.QueueService
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.atlassian.servicedesk")
            
def queueService = ComponentAccessor.getOSGiComponentInstanceOfType(QueueService.class)

on Console Script in Jira SD 3.16.0 and 4.5.1, and it works properly.

So then, you can use it as:

queueService.newQueueQueryBuilder().serviceDeskId(1).build()

I hope it helps, if you haven’t found this solution by your own :wink:

Regards,
Miguel.

Hi @mgarcia,

unfortunately the same error with your piece of code. We use Jira Software 8.5.1 with ServiceDesk 4.5.1 installed later/afterwards over admin applications menu.

Scriptrunner is in version 5.7.1.1-p5 installed.

:frowning:

Best regards
Jörg

Hi @joewe74,

I’ve checked with these versions:

  • SR: 5.7.1.1-p5
  • Jira Software: 8.6.0
  • Jira Service Desk: 4.6.0

And it works properly :confused:

Maybe you can raise a bug in Atlassian portal.

Regards,
Miguel.