Working with ProjectComponent in 5.0.6

Tanner Wortham
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.
November 6, 2012

Maybe someone can help me identify why this method isn't playing now. Below is the top section of the code in question. Below it is the stack trace. It seems to me that it's telling me that I'm not providing the findByComponentName the correct parameters, but I think you'll see why that can't be. Any help will be appreciated. The code in question starts at the 'else' in the code snippet below.

package com.custom

import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import org.apache.log4j.Category
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager
import com.atlassian.jira.issue.changehistory.ChangeHistoryItem
import com.atlassian.jira.bc.project.component.ProjectComponentManager

class ComponentListener extends AbstractIssueEventListener {
    Category log = Category.getInstance(ComponentListener.class)
 
    @Override
    void issueCreated (IssueEvent event) {
    	log.setLevel(org.apache.log4j.Level.DEBUG)

	if (event.issue.isSubTask()) { makeUpdate (event, "add") }
	else {  
		String s = "Other"
		Long l = event.issue.getProjectObject().getId()
		log.debug ("project id: ${s} and ${l}")
		ProjectComponent projectComponent = ProjectComponentManager.findByComponentName (l, s)
	}

Stack trace:

2012-11-07 08:46:56,687 http-8080-3 DEBUG worthar 526x89125x1 1cnekzi 10.21.101.35 /secure/QuickCreateIssue.jspa [com.custom.ComponentListener] project id: Other and 10201

2012-11-07 08:46:56,687 http-8080-3 ERROR worthar 526x89125x1 1cnekzi 10.21.101.35 /secure/QuickCreateIssue.jspa [atlassian.event.internal.EventPublisherImpl] There was an exception thrown trying to dispatch event 'com.atlassian.jira.event.issue.IssueEvent@7f86e78d[issue=SAND-377,comment=<null>,worklog=<null>,changelog=<null>,eventTypeId=1,sendMail=true,params={eventsource=workflow, baseurl=http://rnod-jira01.is.ad.igt.com:8080},subtasksUpdated=false]' from the invoker 'com.atlassian.event.internal.SingleParameterMethodListenerInvoker@ff60750'.

java.lang.RuntimeException: No signature of method: static com.atlassian.jira.bc.project.component.ProjectComponentManager.findByComponentName() is applicable for argument types: (java.lang.Long, java.lang.String) values: [10201, Other]

1 answer

1 accepted

1 vote
Answer accepted
Tanner Wortham
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.
November 6, 2012

I found my problem. Corrected code:

if (event.issue.isSubTask()) { makeUpdate (event, "add") }
	else {  
		String s = "Other"
		Long l = event.issue.getProjectObject().getId()
		log.debug ("project id: ${s} and ${l}")
		ProjectComponentManager pcm = ComponentAccessor.getProjectComponentManager()
		ProjectComponent projectComponent = pcm.findByComponentName (l, s)
	}

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.
November 6, 2012

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events