Issues in Groovy Script.

mehala n
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2013

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()

Script is

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 }

6 answers

1 accepted

0 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2013

Try userManager.getUserByKey("appcriticality")

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2013

Nothing works out because the API has changed, so your code needs to change. For the full story see https://developer.atlassian.com/display/JIRADEV/Renamable+Users+in+JIRA+6.0

0 votes
mehala n
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 23, 2013

you mean to say ,the plugin has nothing to do with this kind of exception?

I really dont get any errors in atlassia-jira.log file.

Also I routed down and found that ClassClassException is from OSWorkFlowManager.java

public void validateIssue(String remoteUserName, Map fields) throws WorkflowException {
77 try {
78 // Determine the workflow for the issue to use
79 Issue issue = (Issue) fields.get("issue");
80 final Workflow workflow = makeWorkflow(remoteUserName); 81 final ActionDescriptor actionDescriptor = getEditActionDescriptor(issue);
82 if (actionDescriptor != null) {
83 long wfId = issue.getLong("workflowId").longValue();
84 workflow.doAction(wfId, actionDescriptor.getId(), fields);
85 }
86 // return ManagerFactory.getIssueManager().getIssueByWorkflow(new Long(wfId));
87 } catch (InvalidRoleException e) {
88 log.error("Error occurred while creating issue.", e);
89 throw new WorkflowException(e);
90 } catch (InvalidInputException e) {
91 log.error("Error occurred while creating issue.", e);
92 throw new WorkflowException(e);
93 } catch (InvalidEntryStateException e) {
94 log.error("Error occurred while creating issue.", e);
95 throw new WorkflowException(e);
96 } catch (com.opensymphony.workflow.WorkflowException e) {
97 log.error("Error occured while creating issue.", e);
98 throw new WorkflowException(e);
99 } catch (ClassCastException e) {
100 String message = "Error occurred while creating issue. This could be due to a plugin being incompatible with this version of JIRA. For more details please consult the logs, and see: "
101 + http://confluence.atlassian.com/x/3McB;
}

Got stuck up and not sure how to proceed.. Please help

0 votes
mehala n
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 22, 2013

I couldnt see any errors/exceptions in log. May be is it bcoz of the jira-misc-workflow-extensions-3.0.0.jar ? The latest I see as 3.0.1 in Market Place?My JIRA version is 5.2.10.

I am working with my team to add this plugin since it requires admin rights.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 23, 2013

Don't see why that plugin has anything to do with it.

0 votes
mehala n
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 22, 2013

Using userPropertyManager.getPropertySet works and there is no exceptions now.

String usera= userPropertyManager.getPropertySet( userManager .getUser("appcriticality")).getString("jira.meta." + compKey )

But Getting Error: "Error creating issue. Error occurred while creating issue. This could be due to a plugin being incompatible with this version of JIRA. For more details please consult the logs, and see http://confluence.atlassian.com/x/3McB"

Note :using latest groovy plugins fom market place(groovy-all-1.8.5.jar,groovyrunner-2.1.3.jar)

No exceptions were seen in log

Kindly help

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 22, 2013

There will be something in the log.

0 votes
mehala n
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2013

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.user.UserPropertyManager

import com.atlassian.crowd.embedded.api.User


UserPropertyManager userManager=ComponentAccessor.getComponent(UserPropertyManager.class)
String compKey = ""
String appCriticality = ""


appCriticality = ComponentAccessor.getUserPropertyManager().getPropertySet(userManager.getUser("appcriticality")).getString.("jira.meta." + compKey )

I tried what ever I know..just removed all other logics and trying to get thru this line alone.. Nothing works out.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2013

Come on, play the game, at least reference the other issue where I told you to use com.atlassian.jira.user.UserPropertyManager#getPropertySet.

You can get UserPropertyManager from ComponentAccessor.

Suggest an answer

Log in or Sign up to answer