Working with ProjectComponent in 5.0.6

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
Accepted answer

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,126 views 0 8
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