It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

1 vote
Answer accepted

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!!!

I am new to python scripting. When i run, i am getting following import error.

ImportError: No module named com.atlassian.jira.component

How can i fix this? where can i download com.atlassian.jira.component module and install.

Any suggestions much appriciated.

Regards

Jey

hi jey,

you need to paste this into your script to import.

from com.atlassian.jira.component import ComponentAccessor

depending on your action you want to execute you will need other packages.

 

best

toni

Hi @Antonio D-Errico

I pasted in script

#!/usr/bin/python2.7
from jira import JIRA
from com.atlassian.jira.component import ComponentAccessor

and when I run, I get same error

File "./component.py", line 3, in <module>
from com.atlassian.jira.component import ComponentAccessor
ImportError: No module named com.atlassian.jira.component

 

Should I install any packages?. I have only installed jira using pip install.

pip install jira

 

Regards

Jey

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

1,085 views 7 0
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you