Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Jersey with JIRA

Hamish Dickson March 24, 2014

Hi there

I am attempting to write an event listener plugin that will call a rest server my company has when an issue is created. There are some good tutorials knocking about so creating the actual bare bones plugin wasn't too hard - however, when I attempt to add in this dependency

<dependency>
			<groupId>com.sun.jersey</groupId>
			<artifactId>jersey-client</artifactId>
			<version>1.9</version>
		</dependency>

the world ends and I get this when starting up my server with atlas-run...

2014-03-25 09:03:51,534 ThreadPoolAsyncTaskExecutor::Thread 19 ERROR      [extender.internal.activator.ContextLoaderListener] Application context refresh failed (NonValidatingOsgiBundleXmlApplicationContext(bundle=com.atlassian.plugins.rest.atlassian-rest-module, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activator' defined in URL [bundle://125.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: null
	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$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
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: null
	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.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
	... 19 more
Caused by: java.lang.ClassCastException
	at java.lang.Class.cast(Class.java:2990)
	at com.sun.jersey.core.osgi.Activator$OsgiServiceFinder$1.next(Activator.java:78)
	... 25 more

And then all my plugins fail, my jira server "locks" and it's basically the end of the world

Does anyone know what's causing this? I am 99.999% sure I only have one version of Activator, so this Casting exception is really puzzling me ..

Cheers!

Hamish

6 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
IgorYastrebov October 15, 2014

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

1 vote
Daniel Wester
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.
March 24, 2014

Take a look at using https://developer.atlassian.com/static/javadoc/sal/2.6/reference/com/atlassian/sal/api/net/RequestFactory.htmlinstead.

If you still want to use Jersey to make the http calls - you'll need to start going through the dependency tree in maven and figure out where the bad dependency is being introduced...

0 votes
Terry Jeske July 7, 2014
I think you need to leverage atlassian's version of the jersey libraries. I use these and it works.

&lt;dependency&gt;
			&lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
			&lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
			&lt;version&gt;1.8-atlassian-14&lt;/version&gt;
			&lt;scope&gt;provided&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
			&lt;artifactId&gt;jersey-core&lt;/artifactId&gt;
			&lt;version&gt;1.8-atlassian-14&lt;/version&gt;
			&lt;scope&gt;provided&lt;/scope&gt;
		&lt;/dependency&gt;

0 votes
Philipp Steinwender
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.
July 7, 2014

same for me in a confluence plugin.

0 votes
Trupti Kanase June 2, 2014

Hi Hamish,

Did you find any solution for this? I am facing the same issue.

0 votes
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 24, 2014

Hi Hamish,

You can achieve that by calling the rest service from the post function using script ruuner plugin.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events