Unable to create jira custom service

xavier jir February 29, 2012

Hi

i would like to create jira custom service. I'm using atlassian sdk 3.8.

so i imported some packages of atlassian api in my program. when i run atlas-package it shows the following error in command prompt window.

[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

F:\services\module\src\main\java\com\first\module\MyPlugin.java:[9,25] cannot find symbo

could not parse error message: symbol: class ComponentManager
location: package com.atlassian.jira
F:\services\module\src\main\java\com\first\module\MyPlugin.java:20: cannot find symbol
ProjectManager pm = ComponentManager.getInstance().getProjectCategories();
^


[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30 seconds
[INFO] Finished at: Thu Mar 01 10:31:26 GMT+05:30 2012
[INFO] Final Memory: 53M/128M
[INFO] ------------------------------------------------------------------------
'cmd' is not recognized as an internal or external command,
operable program or batch file.

Please tell me the solutions.

7 answers

3 votes
Brad Chase March 4, 2012

Looks like ComponentManager is part of jira-core, (see https://developer.atlassian.com/display/JIRADEV/Java+API+Policy+for+JIRA)

Add the following to your pom.xml after the jira-api dependency.

<dependency>
   <groupId>com.atlassian.jira</groupId>
   <artifactId>jira-core</artifactId>
   <version>${jira.version}</version>
   <scope>provided</scope>
</dependency>

xavier jir March 4, 2012

hi i get solution for this.. thanks for your timing help..

now i get all the projects by getProjects() method from project manager..

Next i would like to get issues for that project. so i need to use iterator.

That i dont know how to use and implement that..Pls guide me...

xavier jir March 4, 2012

hi please guide me how to get the due date for the issue. Please post the code bcz i'm the learner.. So i didnt knw many things.. Please post brief example...

Bahar Çağlar October 8, 2012

I added the dependency but it does not work. What is the problem?

Jobin Kuruvilla [Adaptavist]
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.
October 8, 2012

Make sure you rebuild the Eclipse project.

alas-mvn eclipse:clean eclipse:eclipse

Shaikh Moiz February 7, 2013

that really worked thanks :)

0 votes
Andrzej Warycha June 20, 2013

Atlassian in documentation https://docs.atlassian.com/jira/latest/com/atlassian/jira/ComponentManager.html wrote:

This component manager uses PicoContainer to resolve all the dependencies between components.
It is responsible for initialising a large number of components in JIRA. Any components defined here may be injected via a constructor.
The ComponentManager also has various static accessor methods for non-Pico-managed objects, eg. ComponentManager.getInstance().getProjectManager(). Plugins developers should no longer use these - please use ComponentAccessor instead.

so your code should loks like below (then dependency is not needed)

ComponentAccessor.getProjectManager().getAllProjectCategories();

0 votes
Andrew Pechnikov
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.
December 17, 2012

You don't initialize your ProjectManager instance correctly. Try
ProjectManager pm = ComponentManager.getComponentInstanceOfType(ProjectManager.class);
Import all required libraries and uncomment jira-core dependency in your POM file.

0 votes
Brad Chase March 4, 2012

I have a similar problem with the sdk on os x 10.6 with eclipse as I'm developing a CustomField JIRA pluging. Eclipse can't seem to resolve the import for com.atlassian.jira.ComponentManager, but has no trouble with other JIRA classes (e.g. jira.Issue, jira.MockComponentManager).

0 votes
xavier jir February 29, 2012

Actually i try to get all the project categories from the JIRA. So I import these two lines..

import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.ComponentManager;

Then i retrive the projectcategories by getProjectCategories()method..

So i Used this line

ProjectManager pm = ComponentManager.getInstance().getProjectCategories();


After i do this i run the atlas-package command in command window.. That time it shows the error as i said above...

Is this the correct way to retrive all the project categories from JIRA or anyother ways are available?

If u know please make me clear...

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.
February 29, 2012

I don't see any getProjectCategies method here: http://docs.atlassian.com/jira/4.4/com/atlassian/jira/ComponentManager.html

ComponentManager.getInstance().getProjectManager().getProjectCategories() should do what you want.

xavier jir March 1, 2012

Yes you are correct... But just importing these two packages in my program it shows error..

package com.first.module;

import java.io.*;
import java.lang.*;
import com.atlassian.configurable.ObjectConfiguration;
import com.atlassian.configurable.ObjectConfigurationException;
import com.atlassian.jira.service.AbstractService;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.ComponentManager;
public class MyPlugin extends AbstractService
{
public void run()
{
System.out.println("Hi------Done");
}
public ObjectConfiguration getObjectConfiguration() throws ObjectConfigurationException
{
return getObjectConfiguration("MYSERVICE", "com/first/module/myservice.xml", null);
}
}

See i just import that 2 packages in my program. but for atlas-package it shows the same error "cant find the symbol" What to do?

xavier jir March 1, 2012

Actually what my full work is to retrive all the project categories from JIRA and from that project categories i've to get projects and get issues and due date for that issue...

Pls Guide me...

0 votes
xavier jir February 29, 2012

This is my program which i'm trying to run.. if i add


import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.ComponentManager;

Without these 2 import statements it runs.

But if i add just these 2 packages means it shows the error which i mentioned above.. Please kindly tel me the solutions what are all the things i've to do. and what i necesarry to run this code perfectly...

package com.first.module;

import java.io.*;
import java.lang.*;
import com.atlassian.configurable.ObjectConfiguration;
import com.atlassian.configurable.ObjectConfigurationException;
import com.atlassian.jira.service.AbstractService;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.ComponentManager;

//import com.atlassian.jira.issue.Issue;
public class MyPlugin extends AbstractService
{

public void run()
{
//ProjectManager pm = ComponentManager.getInstance().getProjectCategories();
System.out.println("Hi------Done");
}
public ObjectConfiguration getObjectConfiguration() throws
ObjectConfigurationException
{
return getObjectConfiguration("MYSERVICE", "com/first/module/myservice.xml", null);
}


}


Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 29, 2012

Sorry, I don't understand. The code you've given has a couple of imports, but the line is commented out, so I'd expect that to be fine, and just do nothing.

Could you explain this again - what are you compiling and running?

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 29, 2012

Your code is missing an import, or is referring to something you haven't defined. You'll need to fix your code.

I'd recommend using a java-aware IDE to develop your code, because that will tell you about missing reference before you get to the compilation stage.

Suggest an answer

Log in or Sign up to answer