Error while creating issue in Groovy Script to update a User Custom Field - Inplace upgrade to 5.2

The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.crowd.embedded.ofbiz.OfBizUser.getPropertySet() is applicable for argument types: () values: []
Possible solutions: getProperties()
2013-07-16 07:46:12,495 http-6443-2 ERROR wb391456 466x18x1 6s8xt0 10.185.5.137,10.185.160.15 /secure/QuickCreateIssue.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.crowd.embedded.ofbiz.OfBizUser.getPropertySet() is applicable for argument types: () values: []
Possible solutions: getProperties()
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:103)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:195)
at com.onresolve.jira.groovy.GroovyRunner.runFile(GroovyRunner.java:97)
at com.onresolve.jira.groovy.GroovyRunner.run(GroovyRunner.java:57)
at com.onresolve.jira.groovy.GroovyFunctionPlugin.execute(GroovyFunctionPlugin.java:35)
at com.opensymphony.workflow.AbstractWorkflow.executeFunction(AbstractWorkflow.java:1050)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1446)
at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:615)
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:807)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:488)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:426)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:182)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.atlassian.multitenant.impl.MultiTenantComponentFactoryImpl$AbstractMultiTenantAwareInvocationHandler.invokeInternal(MultiTenantComponentFactoryImpl.java:181)
at com.atlassian.multitenant.impl.MultiTenantComponentFactoryImpl$MultiTenantAwareInvocationHandler.invoke(MultiTenantComponentFactoryImpl.java:211)
at $Proxy261.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultCo

7 answers

1 accepted

This widget could not be displayed.


This question is for the same issue.This is not the full script.I just pasted the line of code which gives exception as per the log.

Below is the exception I get.I grepped for getPropertySet() and found it in

businessLead = userManager.getUser(userManager.getUser("appowner").getPropertySet().getString("jira.meta." + compKey )

The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.crowd.embedded.ofbiz.OfBizUser.getPropertySet() is applicable for argument types: () values: []
Possible solutions: getProperties()
2013-07-16 07:46:12,495 http-6443-2 ERROR wb391456 466x18x1 6s8xt0 10.185.5.137,10.185.160.15 /secure/QuickCreateIssue.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.crowd.embedded.ofbiz.OfBizUser.getPropertySet() is applicable for argument types: () values: []
Possible solutions: getProperties()
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)

Looks like you should be using com.atlassian.jira.user.UserPropertyManager#getPropertySet.

This widget could not be displayed.

I have upgraded the groovy plugin to the latest version. groovyrunner-2.1.3.jar ,groovy-all-1.8.5.jar

But the scripts are older.I copied them from 4.2 .Should I change the scripts

Depends if any of your APIs are deprecated / removed. Test.

This widget could not be displayed.

Try disabling/removing it, upgrade, then put it back.

This widget could not be displayed.

Thank you.

This is my line of code in my groovy script .Can u please suggest me the suitable API here?

import com.atlassian.jira.user.util.UserManager

def businessLead

businessLead = userManager.getUser(userManager.getUser("appowner").getPropertySet().getString("jira.meta." + compKey )

If that's the full script it wouldn't have worked in previous versions. What error are you getting?

Also you should ask a new question for this.

Sorry, I see the error, the problem is the question doesn't match with the question text above.

I guess you need to find another way of getting the property set for a user. Bit busy at the moment, might have a look tonight if someone else doesn't help.

This widget could not be displayed.

Thanks Much Jamie for very quick response.

Will try out your suggestion and post you the result.

This widget could not be displayed.

Tried as you suggested and getting exception at some other line

] The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassi
an.jira.user.DefaultUserPropertyManager.getUser() is applicable for argument types: (java.lang.String) values: [appcriticality]

I have pasted my complete script.FYI Iam using groovyrunner-2.1.3.jar ,groovy-all-1.8.5.jar.

Iam new to JIRA as well as groovy.Kindly help to make this script as successful one.

/**************************************/

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.project.Project
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.util.UserManager
import org.apache.log4j.Category

log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")

MutableIssue myIssue = issue

ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
ProjectRoleManager projectRoleManager = (ProjectRoleManager) ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class)
UserManager userManager = (UserManager) ComponentManager.getComponentInstanceOfType(UserManager.class)

Project myProject = myIssue.getProjectObject()
def techLead = myIssue.getProjectObject().getLead()
String projectKey = myIssue.getProjectObject().getKey()
String compKey = ""
String appCriticality = ""
def componentLeads = myIssue.getComponentObjects()
def businessLead

myIssue.getComponentObjects().each{ c ->
if (c.getLead()) {
techLead = userManager.getUser(c.getLead())
}
}

myIssue.getComponentObjects().each{ c ->
if ( c.getDescription() != null && c.getDescription().indexOf('{') != null) {
compKey = c.getDescription()
compKey = compKey.substring(compKey.indexOf('{') + 1,compKey.indexOf('}') )
}
}

compKey = compKey?:projectKey
//Get the first business lead

ProjectRole projectRole = projectRoleManager.getProjectRole('Business Lead')
Collection businessLeads = new ArrayList()
ProjectRoleActors projectRoleActors = projectRoleManager.getProjectRoleActors(projectRole , myProject)
projectRoleActors.getRoleActors().each {
businessLeads.add(it.getUsers())
}
61
62 try {
63 businessLead = businessLeads[0]
64 } catch(Throwable e){}
65 try {
66 if ( userManager.getUser("appowner").getPropertySet().getString("jira.meta." + compKey) != null ) {
67 businessLead = userManager.getUser(userManager.getUser("appowner").getPropertySet().getString("jira.meta." + compKey ))
68 }
69 } catch(Throwable e) {}
70
71 CustomField cfTechLead = customFieldManager.getCustomFieldObjectByName( "Technical Lead" )
72 CustomField cfBusLead = customFieldManager.getCustomFieldObjectByName( "Business Lead" )
73 CustomField cfAppCriticality = customFieldManager.getCustomFieldObjectByName( "Criticality of the App" )
74 CustomField cfIssueSubType = customFieldManager.getCustomFieldObjectByName( "Issue sub-type" )
75
76 myIssue.setCustomFieldValue(cfTechLead, techLead)
77 myIssue.setCustomFieldValue(cfBusLead, businessLead)
78 if( myIssue.issueType.name == "xxx")
79 {
80 appCriticality = userManager.getUser("appcriticality").getPropertySet().getString("jira.meta." + compKey )
81 try {
82 myIssue.setCustomFieldValue(cfAppCriticality , appCriticality.substring( 0,appCriticality.indexOf(':') ))
83 }catch(Throwable e){}
84 }
85 else {
86 myIssue.setCustomFieldValue(cfIssueSubType , myIssue.issueType.name )
87 }

/************************************/

Where in your script have you tried my suggestion of com.atlassian.jira.user.UserPropertyManager#getPropertySet?

Do you just want someone to write it for you? If so I'm happy to, you can find my rates here: https://jamieechlin.atlassian.net/wiki/display/GRV/Getting%20Help

This widget could not be displayed.

Hi Jamie,

Can u pls look into the script and tell me the changes required to avoid the above mentioned exceptions.As Iam new to groovy,I couldnt get the solutions

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

526 views 3 19
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