My own plugin hangs on importOsgiService method

Hello everyone,

I have two apps/plugins running on Jira server. There is a daily maintenance procedure where Jira server is restarted and here comes the weird part.
Let’s say on every 10 restarts of the Jira server, there is one, where server doesn’t start (hangs). Based on the thread dumps, I can see that there is a thread in BLOCKED state and this thread is related to one of the plugins.
Every time it blocked/stuck on the same place:

java.lang.Thread.State: BLOCKED (on object monitor)
at java.lang.Object.wait(java.base@11.0.15/Native Method)
- waiting on
at java.lang.Object.wait(java.base@11.0.15/Object.java:328)
at org.apache.felix.framework.Felix.acquireGlobalLock(Felix.java:5366)
- waiting to re-lock in wait() <0x0000000405bc5bd0> (a [Ljava.lang.Object;)
at org.apache.felix.framework.StatefulResolver.resolve(StatefulResolver.java:528)
at org.apache.felix.framework.BundleWiringImpl.searchDynamicImports(BundleWiringImpl.java:1717)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1617)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
at java.lang.ClassLoader.loadClass(java.base@11.0.15/ClassLoader.java:522)
at org.eclipse.gemini.blueprint.context.support.internal.classloader.ChainedClassLoader.doLoadClass(ChainedClassLoader.java:182)
- locked <0x0000000419b110f0> (a java.util.ArrayList)
at org.eclipse.gemini.blueprint.context.support.internal.classloader.ChainedClassLoader.doLoadClass(ChainedClassLoader.java:154)
at org.eclipse.gemini.blueprint.context.support.internal.classloader.ChainedClassLoader.loadClass(ChainedClassLoader.java:149)
at java.lang.Class.forName0(java.base@11.0.15/Native Method)
at java.lang.Class.forName(java.base@11.0.15/Class.java:398)
at java.lang.reflect.Proxy$ProxyBuilder.ensureVisible(java.base@11.0.15/Proxy.java:854)
at java.lang.reflect.Proxy$ProxyBuilder.validateProxyInterfaces(java.base@11.0.15/Proxy.java:681)
at java.lang.reflect.Proxy$ProxyBuilder.(java.base@11.0.15/Proxy.java:627)
at java.lang.reflect.Proxy.lambda$getProxyConstructor$1(java.base@11.0.15/Proxy.java:426)
at java.lang.reflect.Proxy$$Lambda$342/0x0000000800577040.apply(java.base@11.0.15/Unknown Source)
at jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(java.base@11.0.15/AbstractClassLoaderValue.java:329)
- locked <0x0000000419b11188> (a jdk.internal.loader.AbstractClassLoaderValue$Memoizer)
at jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(java.base@11.0.15/AbstractClassLoaderValue.java:205)
at java.lang.reflect.Proxy.getProxyConstructor(java.base@11.0.15/Proxy.java:424)
at java.lang.reflect.Proxy.newProxyInstance(java.base@11.0.15/Proxy.java:1006)
at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:126)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.eclipse.gemini.blueprint.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:68)
at org.eclipse.gemini.blueprint.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:37)
at org.eclipse.gemini.blueprint.service.importer.support.AbstractServiceProxyCreator.createServiceProxy(AbstractServiceProxyCreator.java:105)
at org.eclipse.gemini.blueprint.service.importer.support.OsgiServiceProxyFactoryBean.createProxy(OsgiServiceProxyFactoryBean.java:176)
at org.eclipse.gemini.blueprint.service.importer.support.AbstractServiceImporterProxyFactoryBean.getObject(AbstractServiceImporterProxyFactoryBean.java:95)
- locked <0x0000000419b11310> (a org.eclipse.gemini.blueprint.service.importer.support.OsgiServiceProxyFactoryBean)
at org.eclipse.gemini.blueprint.service.importer.support.OsgiServiceProxyFactoryBean.getObject(OsgiServiceProxyFactoryBean.java:122)
at com.atlassian.plugins.osgi.javaconfig.OsgiServices.importOsgiService(OsgiServices.java:192)
at com.atlassian.plugins.osgi.javaconfig.OsgiServices.importOsgiService(OsgiServices.java:145)
at a.b.c.ItemAImportBeans.myOwnService1(ItemAImportBeans.java:199)

I have a lot of Bean definitions in ItemAImportBeans, the place from where the call comes is:

@Configuration
public class ItemAImportBeans {

@Bean
public MyOwnService1 myOwnService1() {
	return importOsgiService(MyOwnInterface.class);
}

}

Is there any additional debug to enabled for more detail information. What I enabled so far is:

log4j.logger.com.atlassian.plugin.osgi.factory = DEBUG, filelog
log4j.additivity.com.atlassian.plugin.osgi.factory = false

log4j.logger.com.atlassian.plugin.osgi.container = DEBUG, filelog
log4j.additivity.com.atlassian.plugin.osgi.container = false

log4j.logger.com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager = DEBUG, filelog
log4j.additivity.com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager = false

log4j.logger.com.atlassian.activeobjects.osgi = DEBUG, filelog
log4j.additivity.com.atlassian.activeobjects.osgi = false

Cheers,
Roga