Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot instantiate jira-rest-java-client-core, ClassNotFoundException ThreadLocalContextManager

Christian Lipp
Contributor
September 1, 2020 edited

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)

1 answer

1 accepted

0 votes
Answer accepted
Christian Lipp
Contributor
September 2, 2020 edited
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.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events