Can I create/update an Issue wirh a Jira Service?

I have next Custom Service:

import com.atlassian.configurable.ObjectConfiguration;
import com.atlassian.configurable.ObjectConfigurationException;
import com.atlassian.jira.exception.CreateException;
import com.atlassian.jira.service.AbstractService;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.user.EntityNotFoundException;
import com.vanderlande.jira.writer.action.CreateIssue;


public class WriterService extends AbstractService{

	public static final String SERVICECONF = "WriterService";

	private String serviceConf;
    
    String ipAddr= " [ip:?]";
  
    CreateIssue createIssue;
    
    public WriterService() {
        
    }
    
	@Override
	public void init(PropertySet props) throws ObjectConfigurationException {
		super.init(props);
		try {
			
			 createIssue = new CreateIssue();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (hasProperty(SERVICECONF)) {
			serviceConf = getProperty(SERVICECONF);
		} else {
			serviceConf = "WRITER HAS NO PROPERTY!";
		}

	}

	@Override
	public void run() {
		System.out.println("Running the Jira Writer service!!" + serviceConf);
		try {
			createIssue.createNewIssue();
		} catch (CreateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (EntityNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("MESSEGA IS SENDED");
	}
	
	@Override
	public void destroy() {
		System.out.println("Let me do this before destory!");
		super.destroy();
	}

	public ObjectConfiguration getObjectConfiguration() throws ObjectConfigurationException {
		return getObjectConfiguration("MYNEWSERVICE", "com/vanderlande/jira/writer/service/JIRAWriterService.xml", null);
	}

AND MY CREATE ISSUE CLASS

public class CreateIssue {
	
	public CreateIssue(){
		
	}
	
	public void createNewIssue() throws EntityNotFoundException, CreateException{
		
		IssueFactory issueFactory = ComponentManager.getInstance().getIssueFactory();
		MutableIssue issueObject = issueFactory.getIssue(); 
		IssueManager issueManager = ComponentManager.getInstance().getIssueManager();
		ProjectManager projectManager = ComponentManager.getInstance().getProjectManager();
		
		ConstantsManager constantsManager =  ComponentManager.getInstance().getConstantsManager();
		VersionManager versionManager =  ComponentManager.getInstance().getVersionManager();
		ProjectComponentManager projectComponentManager= ComponentManager.getInstance().getProjectComponentManager();
		
		// Regular Fields
		issueObject.setProjectId(new Long(10000));
		issueObject.setIssueTypeId("1");
		issueObject.setSummary("Test Issue");
		issueObject.setReporter(UserUtils.getUser("admin"));
		issueObject.setAssignee(UserUtils.getUser("admin"));
		issueObject.setPriority((GenericValue) constantsManager.getPriorityObject("1"));
		issueObject.setDescription("Test description");
		//issueObject.setAffectedVersions(EasyList.build(versionManager.getVersion(new Long(10000)), versionManager.getVersion(new Long(10001))));
		//issueObject.setFixVersions(EasyList.build(versionManager.getVersion(new Long(10002))));
		//issueObject.setComponents(EasyList.build(projectComponentManager.find(new Long(10000)), projectComponentManager.find(new Long(10000))));
		
		Map params = new HashMap();
		params.put("issue", issueObject);
		
		GenericValue issue = issueManager.createIssue( ComponentManager.getInstance().getJiraAuthenticationContext().getUser(), params); 

		
		/* Long l = event.issue.getProjectObject().getId();
		 log.debug ("project id: ${s} and ${l}");
		 ProjectComponentManager pcm = ComponentAccessor.getProjectComponentManager();
		 ProjectComponent projectComponent = pcm.findByComponentName (l, s)*/;
	}

WHEN I NSTALL PLUGIN AS SERVICE, I GET NEXT ERROR:

com/opensymphony/user/EntityNotFoundException

Could not find what you were looking for. Maybe you should raise an issue

java.lang.NoClassDefFoundError: com/opensymphony/user/EntityNotFoundException

1 answer

0 vote

Which version of JIRA is it? OpenSymphony classes are not available in the later JIRA versions. Start by removing the EntityNotFoundException from throws clause.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

106 views 0 5
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