Jython-Script-Problem after Update

Hello everyone,

after the update of JIRA to 7.1.9 the following script does not work anymore:

from com.atlassian.jira import ComponentManager
from com.atlassian.jira.security.roles import ProjectRoleManager

result = True

project = issue.getProjectObject()
projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager)
authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext()
userIsInRoleCustomers = projectRoleManager.isUserInProjectRole(authenticationContext.getUser(), projectRoleManager.getProjectRole("Customers"), project)
userIsInRoleDevelopers = projectRoleManager.isUserInProjectRole(authenticationContext.getUser(), projectRoleManager.getProjectRole("Developers"), project)
issueTypeIsNotSR = issue.getIssueTypeObject().getName() != "Service Request"                
if userIsInRoleCustomers:
	if not userIsInRoleDevelopers:
		if issueTypeIsNotSR:
			result = False
description = "You do not have enough permissions to create this Issue Type! Please select - Service Request -"

i'm not good in scripting so i need some help for this.

 

this is the error which occurs:

2016-09-02 12:13:25,408 http-nio-9001-exec-23 ERROR ad 733x2990x1 c7g46g 172.16.177.197,10.0.0.63 /secure/QuickCreateIssue.jspa [c.q.j.plugin.workflow.JythonValidator] Unrecognized exception while executing Jyphon script: null
Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: 'com.atlassian.jira.ComponentManager' object has no attribute 'getJiraAuthenticationContext'

at org.python.core.Py.AttributeError(Py.java:166)
at org.python.core.PyObject.noAttributeError(PyObject.java:930)
at org.python.core.PyObject.__getattr__(PyObject.java:925)
at org.python.pycode._pyx16.f$0(<string>:20)
at org.python.pycode._pyx16.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at org.python.core.Py.exec(Py.java:1305)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)
at com.quisapps.jira.plugin.workflow.JythonValidator.validate(JythonValidator.java:51)
at com.atlassian.jira.workflow.SkippableValidator.validate(SkippableValidator.java:45)
at com.opensymphony.workflow.AbstractWorkflow.verifyInputs(AbstractWorkflow.java:1512)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1203)
at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:615)
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:741)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:580)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:494)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:230)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:199)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
at com.sun.proxy.$Proxy375.create(Unknown Source)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)
at com.sun.proxy.$Proxy375.create(Unknown Source)
at com.atlassian.jira.quickedit.action.QuickCreateIssue.doExecute(QuickCreateIssue.java:308)
... 1 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
... 50 filtered
at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59)
... 62 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
... 89 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
2016-09-02 12:13:25,412 http-nio-9001-exec-23 ERROR ad 733x2990x1 c7g46g 172.16.177.197,10.0.0.63 /secure/QuickCreateIssue.jspa [c.a.j.bc.issue.DefaultIssueService] Error creating issue:
com.atlassian.jira.exception.CreateException: root cause: Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: 'com.atlassian.jira.ComponentManager' object has no attribute 'getJiraAuthenticationContext'

at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:588)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:494)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:230)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:199)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
at com.sun.proxy.$Proxy375.create(Unknown Source)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)
at com.sun.proxy.$Proxy375.create(Unknown Source)
at com.atlassian.jira.quickedit.action.QuickCreateIssue.doExecute(QuickCreateIssue.java:308)
... 1 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
... 50 filtered
at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59)
... 62 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
... 89 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.atlassian.jira.workflow.WorkflowException: root cause: Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: 'com.atlassian.jira.ComponentManager' object has no attribute 'getJiraAuthenticationContext'

at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:760)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:580)
Caused by: com.opensymphony.workflow.WorkflowException: root cause: Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: 'com.atlassian.jira.ComponentManager' object has no attribute 'getJiraAuthenticationContext'

at com.quisapps.jira.plugin.workflow.JythonValidator.validate(JythonValidator.java:89)
at com.atlassian.jira.workflow.SkippableValidator.validate(SkippableValidator.java:45)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1203)
at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:615)
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:741)
... 232 more
Caused by: Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: 'com.atlassian.jira.ComponentManager' object has no attribute 'getJiraAuthenticationContext'

at org.python.core.Py.AttributeError(Py.java:166)
at org.python.core.PyObject.noAttributeError(PyObject.java:930)
at org.python.pycode._pyx16.f$0(<string>:20)
at org.python.pycode._pyx16.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at org.python.core.Py.exec(Py.java:1305)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)
at com.quisapps.jira.plugin.workflow.JythonValidator.validate(JythonValidator.java:51)
... 237 more

 

so what i need to change?

 

best regards

toni

1 answer

1 accepted

This widget could not be displayed.

Swap ComponentManager with ComponentAccessor everywhere. Instead of ComponentManager.getInstanceOfType() use ComponentAccessor.getComponent().

ComponentAccessor is in the com.atlassian.jira.component package.

ok now this error occurs:

 

2016-09-02 15:24:36,511 http-nio-9001-exec-20 ERROR ad 924x3322x1 1p0lww1 172.16.177.197,10.0.0.63 /secure/QuickCreateIssue.jspa [c.q.j.plugin.workflow.JythonValidator] Unrecognized exception while executing Jyphon script: null
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name ComponentAccessor

at org.python.core.Py.ImportError(Py.java:290)
at org.python.core.imp.importFromAs(imp.java:984)
at org.python.core.imp.importFrom(imp.java:954)
at org.python.pycode._pyx20.f$0(<string>:16)
at org.python.pycode._pyx20.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at org.python.core.Py.exec(Py.java:1305)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)
at com.quisapps.jira.plugin.workflow.JythonValidator.validate(JythonValidator.java:51)
at com.atlassian.jira.workflow.SkippableValidator.validate(SkippableValidator.java:45)
at com.opensymphony.workflow.AbstractWorkflow.verifyInputs(AbstractWorkflow.java:1512)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1203)
at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:615)
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:741)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:580)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:494)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:230)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:199)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
at com.sun.proxy.$Proxy375.create(Unknown Source)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)
at com.sun.proxy.$Proxy375.create(Unknown Source)
at com.atlassian.jira.quickedit.action.QuickCreateIssue.doExecute(QuickCreateIssue.java:308)
... 1 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
... 50 filtered
at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59)
... 62 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
... 89 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
2016-09-02 15:24:36,517 http-nio-9001-exec-20 ERROR ad 924x3322x1 1p0lww1 172.16.177.197,10.0.0.63 /secure/QuickCreateIssue.jspa [c.a.j.bc.issue.DefaultIssueService] Error creating issue:
com.atlassian.jira.exception.CreateException: root cause: Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name ComponentAccessor

at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:588)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:494)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:230)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:199)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
at com.sun.proxy.$Proxy375.create(Unknown Source)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)
at com.sun.proxy.$Proxy375.create(Unknown Source)
at com.atlassian.jira.quickedit.action.QuickCreateIssue.doExecute(QuickCreateIssue.java:308)
... 1 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
... 50 filtered
at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59)
... 62 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
... 89 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.atlassian.jira.workflow.WorkflowException: root cause: Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name ComponentAccessor

at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:760)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:580)
Caused by: com.opensymphony.workflow.WorkflowException: root cause: Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name ComponentAccessor

at com.quisapps.jira.plugin.workflow.JythonValidator.validate(JythonValidator.java:89)
at com.atlassian.jira.workflow.SkippableValidator.validate(SkippableValidator.java:45)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1203)
at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:615)
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:741)
... 232 more
Caused by: Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name ComponentAccessor

at org.python.core.Py.ImportError(Py.java:290)
at org.python.core.imp.importFromAs(imp.java:984)
at org.python.pycode._pyx20.f$0(<string>:16)
at org.python.pycode._pyx20.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at org.python.core.Py.exec(Py.java:1305)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)
at com.quisapps.jira.plugin.workflow.JythonValidator.validate(JythonValidator.java:51)
... 237 more

Did you put the right package for the ComponentAccessor import at the beginning of the script?

ok i miss that. but now:

 

2016-09-02 15:30:47,983 http-nio-9001-exec-6 ERROR ad 930x3453x1 1p0lww1 172.16.177.197,10.0.0.63 /secure/QuickCreateIssue.jspa [c.q.j.plugin.workflow.JythonValidator] Unrecognized exception while executing Jyphon script: null
Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: type object 'com.atlassian.jira.component.ComponentAccessor' has no attribute 'getInstance'

at org.python.core.Py.AttributeError(Py.java:166)
at org.python.core.PyType.noAttributeError(PyType.java:1715)
at org.python.core.PyObject.__getattr__(PyObject.java:925)
at org.python.pycode._pyx24.f$0(<string>:16)
at org.python.pycode._pyx24.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at org.python.core.Py.exec(Py.java:1305)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)
at com.quisapps.jira.plugin.workflow.JythonValidator.validate(JythonValidator.java:51)
at com.atlassian.jira.workflow.SkippableValidator.validate(SkippableValidator.java:45)
at com.opensymphony.workflow.AbstractWorkflow.verifyInputs(AbstractWorkflow.java:1512)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1203)
at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:615)
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:741)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:580)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:494)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:230)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:199)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
at com.sun.proxy.$Proxy375.create(Unknown Source)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)
at com.sun.proxy.$Proxy375.create(Unknown Source)
at com.atlassian.jira.quickedit.action.QuickCreateIssue.doExecute(QuickCreateIssue.java:308)
... 1 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
... 50 filtered
at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59)
... 62 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
... 89 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
2016-09-02 15:30:47,989 http-nio-9001-exec-6 ERROR ad 930x3453x1 1p0lww1 172.16.177.197,10.0.0.63 /secure/QuickCreateIssue.jspa [c.a.j.bc.issue.DefaultIssueService] Error creating issue:
com.atlassian.jira.exception.CreateException: root cause: Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: type object 'com.atlassian.jira.component.ComponentAccessor' has no attribute 'getInstance'

at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:588)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:494)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:230)
at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:199)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
at com.sun.proxy.$Proxy375.create(Unknown Source)
... 2 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)
at com.sun.proxy.$Proxy375.create(Unknown Source)
at com.atlassian.jira.quickedit.action.QuickCreateIssue.doExecute(QuickCreateIssue.java:308)
... 1 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
... 50 filtered
at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59)
... 62 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
... 89 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.atlassian.jira.workflow.WorkflowException: root cause: Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: type object 'com.atlassian.jira.component.ComponentAccessor' has no attribute 'getInstance'

at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:760)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:580)
Caused by: com.opensymphony.workflow.WorkflowException: root cause: Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: type object 'com.atlassian.jira.component.ComponentAccessor' has no attribute 'getInstance'

at com.quisapps.jira.plugin.workflow.JythonValidator.validate(JythonValidator.java:89)
at com.atlassian.jira.workflow.SkippableValidator.validate(SkippableValidator.java:45)
at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1203)
at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:615)
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:741)
... 232 more
Caused by: Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: type object 'com.atlassian.jira.component.ComponentAccessor' has no attribute 'getInstance'

at org.python.core.Py.AttributeError(Py.java:166)
at org.python.core.PyType.noAttributeError(PyType.java:1715)
at org.python.pycode._pyx24.f$0(<string>:16)
at org.python.pycode._pyx24.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at org.python.core.Py.exec(Py.java:1305)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)
at com.quisapps.jira.plugin.workflow.JythonValidator.validate(JythonValidator.java:51)
... 237 more

updated script

from com.atlassian.jira.component import ComponentAccessor
from com.atlassian.jira.security.roles import ProjectRoleManager
 
result = True
 
project = issue.getProjectObject()
projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
authenticationContext = ComponentAccessor.getInstance().getJiraAuthenticationContext()
userIsInRoleCustomers = projectRoleManager.isUserInProjectRole(authenticationContext.getUser(), projectRoleManager.getProjectRole("Customers"), project)
userIsInRoleDevelopers = projectRoleManager.isUserInProjectRole(authenticationContext.getUser(), projectRoleManager.getProjectRole("Developers"), project)
issueTypeIsNotSR = issue.getIssueTypeObject().getName() != "Service Request"               
if userIsInRoleCustomers:
    if not userIsInRoleDevelopers:
        if issueTypeIsNotSR:
            result = False
description = "You do not have enough permissions to create this Issue Type! Please select - Service Request -"

Use:

ComponentAccessor.getJiraAuthenticationContext()

instead of:

ComponentAccessor.getInstance().getJiraAuthenticationContext()

Read the error messages - they give you important pointers about what goes wrong.

thanks a lot it works!!!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published yesterday in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

130 views 0 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