Hi Everyone,
I am facing below error on Jira Server 8.5.4. Does anyone have any knowledge of how to mitigate this error.
Caused by: org.osgi.framework.BundleException: Unable to resolve plugin.name [261](R 261.0): missing requirement [plugin.name [261](R 261.0)] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.util.thread.JiraThreadLocalUtil) Unresolved requirements: [[plugin.name [261](R 261.0)] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.util.thread.JiraThreadLocalUtil)]
Relevant part of pom -
<Import-Package>
com.atlassian.jira.plugin.webfragment.conditions,
com.atlassian.jira.util.thread.JiraThreadLocalUtil,
*;resolution:="optional"
</Import-Package>
and if I don’t include the the package in import-package and try to use it directly. The system throws exception while initializing the plugin pasted below -
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'issueStateCalculatorImpl': Unsatisfied dependency expressed through constructor parameter 5; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jqlExecutorImpl': Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.atlassian.jira.util.thread.JiraThreadLocalUtil' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}
The actual problem is present somewhere else, as the same code is being used in compiling another jar and is working fine.
When I try to import the service via below LOC to find out the original root cause of the problem.
final JiraThreadLocalUtil jiraThreadLocalUtil = ComponentAccessor.getComponent(JiraThreadLocalUtil.class);
It throws below error when trying to run the above LOC-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>500</status-code><message>loader constraint violation: when resolving interface method "com.atlassian.jira.util.thread.JiraThreadLocalUtil.postCall(Lorg/apache/log4j/Logger;)V" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) of the current class, com/adc/commons/jira/service/JqlExecutorImpl, and the class loader (instance of org/apache/catalina/loader/ParallelWebappClassLoader) for the method's defining class, com/atlassian/jira/util/thread/JiraThreadLocalUtil, have different Class objects for the type org/apache/log4j/Logger used in the signature</message><stack-trace>java.lang.LinkageError: loader constraint violation: when resolving interface method "com.atlassian.jira.util.thread.JiraThreadLocalUtil.postCall(Lorg/apache/log4j/Logger;)V" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) of the current class, com/adc/commons/jira/service/JqlExecutorImpl, and the class loader (instance of org/apache/catalina/loader/ParallelWebappClassLoader) for the method's defining class, com/atlassian/jira/util/thread/JiraThreadLocalUtil, have different Class objects for the type org/apache/log4j/Logger used in the signature
If I remove everything related to JiraThreadLocalUtil from my plugin. Then everything is working fine except the specific part of plugin (JqlSearch) which needs to use JiraThreadLocalUtil.