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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

823 views 2 9
Read article

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