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
Community moderators have prevented the ability to post new answers.
Which version of JIRA is it? OpenSymphony classes are not available in the later JIRA versions. Start by removing the EntityNotFoundException from throws clause.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.