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
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
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you need to leverage atlassian's version of the jersey libraries. I use these and it works.
<dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>1.8-atlassian-14</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-core</artifactId> <version>1.8-atlassian-14</version> <scope>provided</scope> </dependency>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
same for me in a confluence plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hamish,
Did you find any solution for this? I am facing the same issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hamish,
You can achieve that by calling the rest service from the post function using script ruuner plugin.
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.