I'm trying to include the UserLoggedInCondition condition to a web-item in my plugin. I have included the condition tag as given within my web-element tag in the atlassian-plugin.xml file. And have imported the package in the pom file as well. The issue is that the condition only works just after an "atlas-run" If I use a "pi" command in the "atlas-cli" then my plugin breaks and notifies "This add-on couldn't be loaded. It has one or more errors that prevent it from being enabled.".
atlassian-plugin.xml
<web-item name="pluginItem" i18n-name-key="plugin-item.name" key="plugin-item" section="system.top.navigation.bar" weight="1000"> <description key="plugin-item.description">The pluginItem Plugin</description> <label key="plugin-item.label"></label> <link linkId="plugin-item-link">/exserv</link> <condition class="com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition"/> </web-item>
pom file
<Import-Package>com.atlassian.jira.plugin.webfragment.conditions, org.springframework.osgi.*;resolution:="optional",org.eclipse.gemini.blueprint.*;resolution:="optional", *</Import-Package>
Error stack after failing to enable the plugin
java.lang.RuntimeException: Unable to enable web fragment [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.AbstractWebFragmentModuleDescriptor.enabled(AbstractWebFragmentModuleDescriptor.java:133) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.DefaultWebItemModuleDescriptor.enabled(DefaultWebItemModuleDescriptor.java:72) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.DefaultAbstractWebFragmentModuleDescriptor.enabled(DefaultAbstractWebFragmentModuleDescriptor.java:35) [INFO] [talledLocalContainer] at com.atlassian.plugin.manager.DefaultPluginManager.notifyModuleEnabled(DefaultPluginManager.java:1991) [INFO] [talledLocalContainer] at com.atlassian.plugin.manager.DefaultPluginManager.enableConfiguredPluginModule(DefaultPluginManager.java:1738) [INFO] [talledLocalContainer] at com.atlassian.plugin.manager.DefaultPluginManager.enableConfiguredPluginModules(DefaultPluginManager.java:1715) [INFO] [talledLocalContainer] at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1227) [INFO] [talledLocalContainer] at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1188) [INFO] [talledLocalContainer] at com.atlassian.jira.plugin.JiraPluginManager.addPlugins(JiraPluginManager.java:150) [INFO] [talledLocalContainer] at com.atlassian.plugin.manager.DefaultPluginManager.scanForNewPlugins(DefaultPluginManager.java:903) [INFO] [talledLocalContainer] at com.atlassian.plugin.manager.DefaultPluginManager.installPlugins(DefaultPluginManager.java:821) [INFO] [talledLocalContainer] at com.atlassian.jira.plugin.JiraPluginManager.installPlugins(JiraPluginManager.java:168) [INFO] [talledLocalContainer] ... 3 filtered [INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:498) [INFO] [talledLocalContainer] at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26) [INFO] [talledLocalContainer] at com.sun.proxy.$Proxy292.installPlugins(Unknown Source) [INFO] [talledLocalContainer] ... 3 filtered [INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:498) [INFO] [talledLocalContainer] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) [INFO] [talledLocalContainer] at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) [INFO] [talledLocalContainer] at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) [INFO] [talledLocalContainer] at com.sun.proxy.$Proxy1194.installPlugins(Unknown Source) [INFO] [talledLocalContainer] at com.atlassian.labs.plugins.quickreload.install.PluginInstallerMechanic.installPluginImmediately(PluginInstallerMechanic.java:185) [INFO] [talledLocalContainer] at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.installPluginImmediately(PluginInstaller.java:318) [INFO] [talledLocalContainer] at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.attemptInstall(PluginInstaller.java:308) [INFO] [talledLocalContainer] at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.loopWaitingForInstallPromises(PluginInstaller.java:232) [INFO] [talledLocalContainer] at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.access$000(PluginInstaller.java:36) [INFO] [talledLocalContainer] at com.atlassian.labs.plugins.quickreload.install.PluginInstaller$1.run(PluginInstaller.java:75) [INFO] [talledLocalContainer] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [INFO] [talledLocalContainer] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [INFO] [talledLocalContainer] at java.lang.Thread.run(Thread.java:745) [INFO] [talledLocalContainer] Caused by: com.atlassian.plugin.PluginParseException: Unable to load the module's display conditions: Could not load 'com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition' in plugin com.atlassian.tutorial.conditionPlugin [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.ConditionElementParser.makeConditionImplementation(ConditionElementParser.java:95) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.ConditionElementParser.makeConditionImplementation(ConditionElementParser.java:29) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.baseconditions.AbstractConditionElementParser.makeCondition(AbstractConditionElementParser.java:116) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.ConditionElementParser.makeCondition(ConditionElementParser.java:73) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.ConditionElementParser.makeCondition(ConditionElementParser.java:29) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.ConditionElementParser.makeConditions(ConditionElementParser.java:65) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.ConditionElementParser.makeConditions(ConditionElementParser.java:29) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.baseconditions.AbstractConditionElementParser.makeConditions(AbstractConditionElementParser.java:57) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.ConditionElementParser.makeConditions(ConditionElementParser.java:57) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.AbstractWebFragmentModuleDescriptor.makeConditions(AbstractWebFragmentModuleDescriptor.java:72) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.AbstractWebFragmentModuleDescriptor.enabled(AbstractWebFragmentModuleDescriptor.java:128) [INFO] [talledLocalContainer] ... 49 more [INFO] [talledLocalContainer] Caused by: com.atlassian.plugin.web.conditions.ConditionLoadingException: Could not load 'com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition' in plugin com.atlassian.tutorial.conditionPlugin [INFO] [talledLocalContainer] at com.atlassian.jira.plugin.webfragment.JiraWebFragmentHelper.loadCondition(JiraWebFragmentHelper.java:45) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.AbstractWebFragmentModuleDescriptor$1.create(AbstractWebFragmentModuleDescriptor.java:169) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.ConditionElementParser.makeConditionImplementation(ConditionElementParser.java:86) [INFO] [talledLocalContainer] ... 60 more [INFO] [talledLocalContainer] Caused by: java.lang.ClassNotFoundException: com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition not found by com.atlassian.tutorial.conditionPlugin [188] [INFO] [talledLocalContainer] at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) [INFO] [talledLocalContainer] at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955) [INFO] [talledLocalContainer] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [INFO] [talledLocalContainer] at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1844) [INFO] [talledLocalContainer] at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:937) [INFO] [talledLocalContainer] at com.atlassian.plugin.osgi.util.BundleClassLoaderAccessor.loadClass(BundleClassLoaderAccessor.java:45) [INFO] [talledLocalContainer] at com.atlassian.plugin.osgi.factory.OsgiPluginInstalledHelper.loadClass(OsgiPluginInstalledHelper.java:56) [INFO] [talledLocalContainer] at com.atlassian.plugin.osgi.factory.OsgiPlugin.loadClass(OsgiPlugin.java:207) [INFO] [talledLocalContainer] at com.atlassian.jira.plugin.webfragment.JiraWebFragmentHelper.loadCondition(JiraWebFragmentHelper.java:42) [INFO] [talledLocalContainer] ... 62 more
JIRA version : 7.1.9 if that is any additional help
Please let me know whether I'm missing out any step.
Community moderators have prevented the ability to post new answers.
FastDev and atlas-cli have been deprecated. Please use Automatic Plugin Reinstallation with QuickReload instead. See here: https://developer.atlassian.com/docs/developer-tools/automatic-plugin-reinstallation-with-fastdev
Thanks Volodymyr, It worked. But the plugin breaks again if I use the "IsAdminCondition" instead of the "UserLoggedInCondition". With the "IsAdminCondition" the plugin does not get enabled at all. Please help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It should work. I have IsAdminCondition in few addons and no problems so far. Did you clean the project via atlas-clean?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I tried. I tried including both the conditions as below
<conditions type="AND"> <condition class="com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition"/> <condition class="com.atlassian.jira.plugin.webfragment.conditions.UserIsAdminCondition"/> </conditions>
Error stack. Please take a look.
Caused by: com.atlassian.plugin.web.conditions.ConditionLoadingException: Could not load 'com.atlassian.jira.plugin.webfragment.conditions.UserIsAdminCondition' in plugin com.atlassian.tutorial.conditionPlugin [INFO] [talledLocalContainer] at com.atlassian.jira.plugin.webfragment.JiraWebFragmentHelper.loadCondition(JiraWebFragmentHelper.java:45) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.AbstractWebFragmentModuleDescriptor$1.create(AbstractWebFragmentModuleDescriptor.java:169) [INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.ConditionElementParser.makeConditionImplementation(ConditionElementParser.java:86) [INFO] [talledLocalContainer] ... 51 more [INFO] [talledLocalContainer] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.atlassian.jira.plugin.webfragment.conditions.UserIsAdminCondition': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.jira.security.PermissionManager]: : No qualifying bean of type [com.atlassian.jira.security.PermissionManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.jira.security.PermissionManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The error is "No qualifying bean of type [com.atlassian.jira.security.PermissionManager]" and I checked JIRA 7.1.9 sources and for sure PermissionManager and it's implementations are on place.
Try to change JIRA version in your pom.xml, for example: 7.1.0. Do not forget atlas-clean before running the JIRA.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried changing the version to 7.1.0. Still the same error. Am I missing out a step? Only the "UserLoggedInCondition" alone works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tried once again and it works for me. Do you have "*" in <Import-Package> section of your pom.xml.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thankx for reply. But I don't have that much credit to reply back yesterday.
Not working for UserIsAdminCondition.
In pom.xml file: dependency for jira-core commented.
pom.xml
<!-- Add package import here --> <Import-Package> com.atlassian.jira.plugin.webfragment.conditions, org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", * </Import-Package>
atlassian-plugin.xml
<web-section key="my_links_section" name="My Links Main Section" location="my_links_link" weight="10"/> <web-item key="my_links_link" name="Link on My Links Main Section" section="system.top.navigation.bar" weight="47"> <condition class="com.atlassian.jira.plugin.webfragment.conditions.UserIsAdminCondition" /> <label>My Company</label> <link linkId="my_links_link">http://www.atlassian.com</link> </web-item>
following is the error:
This add-on couldn't be loaded. It has one or more errors that prevent it from being enabled.
Is correctly working for "UserLoggedInCondition". But not for "UserIsAdminCondition".
Thankx
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see you stuck here and I can not help you since the UserIsAdminCondition works for me. As quick work-around you may create your own "is admin condition" by extending AbstractWebCondition. You can copy the code from UserIsAdminCondition or just use GlobalPermissionManager#hasPermission passing ADMINISTER permission.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am also facing same problem , could you please help me ??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rather than rewriting the condition, you can more simply add an an empty class that extends the desired condition and use the @Scanned annotation to wire all dependencies correctly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys,
What was the solution here? I'm trying to use the UserIsAdminCondition unsuccessfully, so I created my own condition. But why? :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had the same issue. I don't know how, but all work fine after adding this to pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
It might be good for someone.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This question is already resolved but I think it might be helpful to describe what is needed to make conditions work.
First thing is that fast dev is also now deprecated and we advise using quickreload https://developer.atlassian.com/server/framework/atlassian-sdk/automatic-plugin-reinstallation-with-quickreload/ and spring scanner https://bitbucket.org/atlassian/atlassian-spring-scanner
To understand why conditions do not load in this situation it is important to notice that conditions itself are instantiated as beans in the context of the plugin. In order to make them work one need to add appropriate component import in pom.xml file.
For example for com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition you need to add
<Import-Package>
...
com.atlassian.jira.plugin.webfragment.conditions,
..
</Import-Package>
This will make class of the condition available in class loader of your plugin.
However some conditions require some dependencies for example com.atlassian.jira.plugin.webfragment.conditions.UserIsAdminCondition has constructor
@Internal
public UserIsAdminCondition(GlobalPermissionManager permissionManager) {
this.permissionManager = Either.right(permissionManager);
}
This means that this specific condition requires bean of type GlobalPermissionManager to be visible in context of your plugin. So in order for this condition to instantiate one need to component import GlobalPermissionManager. You can achieve this by adding class like this to your plugin
/**
* Place here only components required for conditions provided by Jira
*/
public class ComponentImports {
@ComponentImport
private GlobalPermissionManager globalPermissionManager;
}
If you are still using deprecated atlassian-plugin.xml for component imports you can use https://developer.atlassian.com/server/jira/platform/component-import/
This should solve the problem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.