Errors when importing in a groovy script using JMWE

I am on JIRA 7.5.0 and JMWE 5.0.6.

I cannot import the Project Role Service class (I have also had the same issue with GroupRoleActorFactory.GroupRoleActor) when using JMWE, but when using the native JIRA groovy script runner, the exact same code that JMWE says does not work has no problem importing the classes I need.

Example script that causes the error when I paste it into JMWE (the first import statement):

 

import com.atlassian.jira.bc.projectroles.ProjectRoleService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleActor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.util.SimpleErrorCollection

def projectManager = ComponentAccessor.getProjectManager()
def projectRoleService = ComponentAccessor.getComponent(ProjectRoleService)
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def errorCollection = new SimpleErrorCollection()

def project = projectManager.getProjectObjByKey("PROJKEY")
def projectRole = projectRoleManager.getProjectRole("Service Desk Customers")
def actors = ['actor1Key', 'actor2Key']
projectRoleService.addActorsToProjectRole(actors,
        projectRole,
        project,
        ProjectRoleActor.USER_ROLE_ACTOR_TYPE,
        errorCollection)

1 answer

1 accepted

Accepted Answer
1 vote

Received an answer from JMWE support:

This is related to https://innovalog.atlassian.net/browse/JMWE-224 and is because JMWE does not support all packages in Groovy scripts.

 

Their suggested workaround, until the fix is released:

def projectRoleService = ComponentAccessor.getComponent(ComponentAccessor.getClassLoader().findClass("com.atlassian.jira.bc.projectroles.ProjectRoleService"))
Instead of using this:
def projectRoleService = ComponentAccessor.getComponent(ProjectRoleService)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 11, 2018 in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

3,549 views 6 6
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you