I'm am using Kotlin and `jira-rest-java-client-core` to automate some internal process. My Gradle dependecies are:
implementation "com.atlassian.jira:jira-rest-java-client-core:5.2.1
implementation "io.atlassian.fugue:fugue:4.7.2
When I want to create this bean
@Bean
fun getJiraRestClient(): JiraRestClient
{
val jiraServer = URI(JIRA_SERVER_URL)
return AsynchronousJiraRestClientFactory()
.createWithBasicHttpAuthentication(jiraServer, jiraUser, jiraPassword)
}
I receive the exception
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getJiraRestClient' defined in class path resource [at/oebb/tools/pnw/jira/JiraConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.atlassian.jira.rest.client.api.JiraRestClient]: Factory method 'getJiraRestClient' threw exception; nested exception is java.lang.NoClassDefFoundError: com/atlassian/sal/api/executor/ThreadLocalContextManager
Caused by:
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:483)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
... 51 more
Caused by:
org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.atlassian.jira.rest.client.api.JiraRestClient]: Factory method 'getJiraRestClient' threw exception; nested exception is java.lang.NoClassDefFoundError: com/atlassian/sal/api/executor/ThreadLocalContextManager
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650)
... 70 more
Caused by:
java.lang.NoClassDefFoundError: com/atlassian/sal/api/executor/ThreadLocalContextManager
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35)
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42)
However the library "com.atlassian.sal:sal-api:3.0.7" is there (indirect dependecy)
com.atlassian.sal:sal-api:3.0.7
`was a transitive dependency, but it is a plugin. I took a look at the feature matrix and since we are using Jira 7.1 I choose SAL 3.0.3. The dependency has to be included as runtime, so I added
runtimeOnly "com.atlassian.sal:sal-api:3.0.3"
This version has a transitve dependency
com.atlassian.sal:sal-api:atlassian-plugin:3.0.7
`which is not included in
com.atlassian.sal:sal-api:3.0.7
, but solves the problem.
Still thinking about joining us for Team '25 Europe? Early bird has been extended for just one week! Now’s the time to lock in your lowest rate. Use code TEU25COMM-20 to save 20% at checkout. Hurry, this only lasts for 1 more week.
Learn more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.