Hello,
I try to use the Java REST API with Jira 6.2.3 but maybe it's more difficult than I thought... Or I'm missing something...
I'm using the Atlassian SDK which is a great tool, but I have some trouble finding all the needed dependencies to develop with the REST API.
I've found this link: http://scottizu.wordpress.com/tag/java-jira-api/
the guy use that kind of dependencies in pom.xml : http://scottizu.wordpress.com/2014/02/25/using-the-atlassian-jira-rest-client/
This is only when including jersey... Even with newer/older version (m10, m24, m26 : the newest one) I always have the following error on startup :
2014-04-28 17:18:25,774 localhost-startStop-1 INFO [atlassian.plugin.manager.DefaultPluginManager] Initialising the plugin system 2014-04-28 17:18:59,426 ThreadPoolAsyncTaskExecutor::Thread 11 WARN [org.springframework.beans.TypeConverterDelegate] PropertyEditor [com.sun.beans.editors.EnumEditor] found through deprecated global PropertyEditorManager fallback - consider using a more isolated form of registration, e.g. on the BeanWrapper/BeanFactory! 2014-04-28 17:19:03,770 ThreadPoolAsyncTaskExecutor::Thread 1 ERROR [plugin.osgi.factory.OsgiPlugin] Unable to start the plugin container for plugin com.atlassian.plugins.rest.atlassian-rest-module org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activator' defined in URL [bundle://118.0:0/META-INF/spring/atlassian-plugins-components.xml]: Invocation of init method failed; nested exception is com.sun.jersey.spi.service.ServiceConfigurationError: com.sun.jersey.spi.HeaderDelegateProvider: The class com.sun.jersey.core.impl.provider.header.LocaleProvider implementing provider interface com.sun.jersey.spi.HeaderDelegateProvider could not be instantiated: Cannot cast com.sun.jersey.core.impl.provider.header.LocaleProvider to com.sun.jersey.spi.HeaderDelegateProvider at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355) at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320) at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: com.sun.jersey.spi.service.ServiceConfigurationError: com.sun.jersey.spi.HeaderDelegateProvider: The class com.sun.jersey.core.impl.provider.header.LocaleProvider implementing provider interface com.sun.jersey.spi.HeaderDelegateProvider could not be instantiated: Cannot cast com.sun.jersey.core.impl.provider.header.LocaleProvider to com.sun.jersey.spi.HeaderDelegateProvider at com.sun.jersey.core.osgi.Activator$OsgiServiceFinder$1.next(Activator.java:80) at com.sun.jersey.core.spi.factory.AbstractRuntimeDelegate.<init>(AbstractRuntimeDelegate.java:76) at com.sun.jersey.server.impl.provider.RuntimeDelegateImpl.<init>(RuntimeDelegateImpl.java:54) at com.sun.jersey.server.osgi.Activator.start(Activator.java:63) at com.atlassian.plugins.rest.module.Activator.afterPropertiesSet(Activator.java:22) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) ... 19 more Caused by: java.lang.ClassCastException: Cannot cast com.sun.jersey.core.impl.provider.header.LocaleProvider to com.sun.jersey.spi.HeaderDelegateProvider at java.lang.Class.cast(Unknown Source) at com.sun.jersey.core.osgi.Activator$OsgiServiceFinder$1.next(Activator.java:78) ... 25 more
1 day of search at google... and atlassian forums but nothing useful...
Thanks for you help :)
Community moderators have prevented the ability to post new answers.
Hello,
according to https://developer.atlassian.com/display/DOCS/REST+Plugin+Module#RESTPluginModule-JAX-RSandJersey, JIRA uses Jersey internally already. If you override Jersey by your plugin, JIRA system plugins stop working.
The solution is easy, pom.xml should be:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.8-atlassian-15</version>
<scope>provided</scope>
</dependency>
AND two command after:
atlas-clean :: get rid from cashed jars in your target
atlas-run :: build and re-run JIRA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This does not help me :(
Here is written that you can call an url to edit issues, but not how to include that in a service.
That's what I do with curl.
Maybe I'm not fully understand the capabilities of a REST service and how to use it...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A possible solution is to create a custom REST service that receives JSON data.
On the service you can load the issue, by ID for example, using the jira-api (IssueManager) and after you can invoke setters to update issue attributes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gautier,
Do you have created a new REST service right?
Can you access to it?
Best,
RMRodrigues
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I do, I've follow the tutorial from atlassian website, but I have absolutly no Idea how to get my Jira issue and how to update it. Do I have to use the Jira API like ComponentAccessor? Why? Because as I understand things, all this would be possible with REST, no need to use other tool?
I don't want to use Jersey as I have some incompability with it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think that is simple to do.
You only need to create a REST service that receives JSON data (your example) and process the data.
I think that it's what you want.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, let's go for a try :-)
Thanks again, I will post some feeback about this...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately I cannot manage to do what I want with a REST service, I don't find any solution as simple as curl do it, so I call them by Java with HttpURLConnection...
Too bad that there is not so much documentation about REST, Jira and Java because I think it's a nice coding solution.
Thanks again Rui for your time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's right, I'm using Jira 6.2.3 and I'm developing plugins for menus, issue listener and some other tools to communicate with external applications like Lotus Notes and Sugar CRM.
My predecessor have done this with servlet but It was with Jira 4 and I want to upgrade theses tools, maybe by using REST? I'm open with the solution, I just need to offer services as I describe.
Here is 2 examples I need to do but not with curl.
1. curl -D- -H "Authorization: Basic xxx" -X PUT --data '{ "update": { "customfield_11200": [{"add": "12345"}] } }' -H "Content-Type: application/json" http://192.168.111.216:8080/rest/api/2/issue/21705
2. { "globalid":"http://192.168.111.216:8080/plugins/servlet/app/browseJiraID/21705", "relationship":"Shortcut", "object": { "url":"http://192.168.111.216:8080/plugins/servlet/app/browseJiraID/21705", "title":"J-21705 : summary":"SUMMARY" } }
Thank you for your help Rui :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gautier,
Just to confirm.You have an application that will communicate with JIRA via RESTful services, right? Are you developing a plugin or are you developing an application client only?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Rui,
I'm a bit lost...
I want to take full advantage of the REST API, like adding value to a label custom field, or adding a defined remote link to an issue (on a third party application or on a issue listener). It's quite easy with curl but harder to include in a java plugin.
It seems like Jersey is not compatible with the latest version of Jira, am I wrong?
The solution you are proposing is using Jersey too, but I can't include it in my project. If I do, I immediatly encounter the crash I've describe.
I can't find someone who gives me a solution, only old solution from 2008 to 2010... But we are in 2014 with Jira 6 and nobody seems to do that kind of things :(
Is anybody have already updated some issue with the rest API with other tool than curl?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Rui,
I'm a bit lost...
I want to take full advantage of the REST API, like adding value to a label custom field, or adding a defined remote link to an issue (on a third party application or on a issue listener). It's quite easy with curl but harder to include in a java plugin.
It seems like Jersey is not compatible with the latest version of Jira, am I wrong?
The solution you are proposing is using Jersey too, but I can't include it in my project. If I do, I immediatly encounter the crash I've describe.
I can't find someone who gives me a solution, only old solution from 2008 to 2010... But we are in 2014 with Jira 6 and nobody seems to do that kind of things :(
Is anybody have already updated some issue with the rest API with other tool than curl?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please see that: https://developer.atlassian.com/display/DOCS/REST+Plugin+Module
It can help you.
Best,
RMRodrigues
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.