I am trying to compile my plugin. But plugin is not getting enabled and i have this error:
Unresolved constraint in bundle [114]: Unable to resolve 114.0: missing requirement [114.0] osgi.wiring.package; (osgi.wiring.package=[package name])
I meet so many errors of this type and I added the missing package to <Export-Package> one by one as you can see below. But this is very annoying and is there any other solutions to this problem?
I tried other answers from here, but it doesn't work for me.
Any advice and help will be greatly appreciated. Thanks for you all in advance.
My pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ms.plugins.cmdb.jira</groupId>
<artifactId>cmdb-jira-custom-field</artifactId>
<version>1.0.0-SNAPSHOT</version>
<organization>
<name>Morgan Stanley</name>
<url>https://www.morganstanley.com/</url>
</organization>
<name>cmdb-jira-custom-field</name>
<description>This is the com.ms.plugins.cmdb.jira:cmdb-jira-custom-field plugin for Atlassian JIRA.</description>
<packaging>atlassian-plugin</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.4.9</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.6</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</exclusion>
<exclusion>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.runtime.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.google.code.gson</groupId>-->
<!-- <artifactId>gson</artifactId>-->
<!-- <version>2.2.2-atlassian-1</version>-->
<!-- </dependency>-->
<!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
<!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
<!--
<dependency>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-client</artifactId>
<version>${testkit.version}</version>
<scope>test</scope>
</dependency>
-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
<version>5.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.atlassian.jira.plugins</groupId>
<artifactId>insight</artifactId>
<version>10.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.servicedesk</groupId>
<artifactId>insight-core-model</artifactId>
<version>10.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.servicedesk</groupId>
<artifactId>insight-core-services</artifactId>
<version>10.13.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.atlassian.servicedesk</groupId>
<artifactId>insight-core-utils</artifactId>
<version>10.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.servicedesk</groupId>
<artifactId>insight-external-services</artifactId>
<version>10.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.servicedesk</groupId>
<artifactId>insight-core-index</artifactId>
<version>10.13.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.atlassian.servicedesk</groupId>
<artifactId>insight-core-iql</artifactId>
<version>10.13.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.atlassian.event</groupId>
<artifactId>atlassian-event</artifactId>
<version>5.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.3.33</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.33</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>jira-maven-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<log4jProperties>src/aps/log4j.properties</log4jProperties>
<!-- Uncomment to install TestKit backdoor in JIRA. -->
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId>
<version>${testkit.version}</version>
</pluginArtifact>
</pluginArtifacts>
<enableQuickReload>true</enableQuickReload>
<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<!-- Add package to export here -->
<Export-Package>
com.ms.plugins.cmdb.jira.customfields.api,
android.os,
com.mindville.insight.services.model,
kotlin.reflect.jvm.internal,
org.ehcache.impl.internal.concurrent,
com.sun.tools.javac.code,
com.sun.tools.javac.util,
io.riada.insight.index,
com.sun.xml.fastinfoset.sax,
com.sun.xml.fastinfoset.stax,
io.riada.insight.file,
javax.enterprise.util,
org.antlr.v4.runtime,
org.antlr.v4.runtime.atn,
org.antlr.v4.runtime.dfa,
org.antlr.v4.runtime.tree,
org.eclipse.jdt.internal.compiler,
org.eclipse.jdt.internal.compiler.apt.model,
org.eclipse.jdt.internal.compiler.ast,
org.eclipse.jdt.internal.compiler.env,
org.eclipse.jdt.internal.compiler.lookup,
org.glassfish.hk2.osgiresourcelocator,
org.jvnet.fastinfoset,
org.jvnet.fastinfoset.stax,
org.jvnet.staxex,
com.riadalabs.jira.plugins.insight.common.tools,
com.riadalabs.jira.plugins.insight.services.core.dal,
com.riadalabs.jira.plugins.insight.services.model.graph,
com.riadalabs.jira.plugins.insight.services.model.icontheme,
com.riadalabs.jira.plugins.insight.services.user,
io.riada.insight.utils,
io.riada.insight.services.comparator,
io.riada.insight.common,
io.riada.insight.external.services,
io.riada.insight.featureflags,
io.riada.insight.index.cache,
io.riada.insight.index.filter,
com.google.errorprone.annotations,
com.google.errorprone.annotations.concurrent
</Export-Package>
<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*
</Import-Package>
<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jira.version>9.17.0</jira.version>
<amps.version>9.1.1</amps.version>
<plugin.testrunner.version>2.0.1</plugin.testrunner.version>
<atlassian.spring.scanner.version>4.0.0</atlassian.spring.scanner.version>
<atlassian.spring.scanner.runtime.version>3.0.3</atlassian.spring.scanner.runtime.version>
<!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<!-- TestKit version 6.x for JIRA 6.x -->
<testkit.version>6.3.11</testkit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
Hi @Wenjing Liu
That error means your plugin is importing packages that Jira don’t export. Adding those packages to <Export-Package>
in your bundle won’t fix it. Long story short, you can’t export classes you don’t own. Only export your own API (if another plugin must import it).
I see, thanks very much. But could you please give me some advice on how can I fix this missing requirement osgi.wiring.package error? Here's my import code. I guess the error is from I import ObjectTicketConnectionService?
CmdbCustomField.java
import com.atlassian.jira.issue.context.JiraContextNode;
import com.atlassian.jira.issue.customfields.impl.SelectCFType;
import com.atlassian.jira.issue.customfields.impl.FieldValidationException;
import com.atlassian.jira.issue.customfields.option.Option;
import com.atlassian.jira.issue.customfields.option.Options;
import com.atlassian.jira.issue.customfields.persistence.PersistenceFieldType;
import com.atlassian.plugin.spring.scanner.annotation.imports.JiraImport;
import com.riadalabs.jira.plugins.insight.common.exception.InsightException;
import lombok.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;
import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
import com.atlassian.jira.issue.customfields.manager.OptionsManager;
import com.atlassian.jira.issue.fields.rest.json.beans.JiraBaseUrls;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.config.FieldConfig;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
import com.atlassian.jira.component.ComponentAccessor;
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade;
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade;
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean;
AssetLinkListener.java
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.event.api.EventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.issue.Issue;
import com.atlassian.plugin.spring.scanner.annotation.imports.JiraImport;
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade;
import com.riadalabs.jira.plugins.insight.common.exception.InsightException;
import com.riadalabs.jira.plugins.insight.services.model.*;
import io.riada.insight.model.ObjectTicketConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import io.riada.insight.services.ObjectTicketConnectionService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
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 coming from those io.riada imports. Those packages aren’t exported by the Assets bundle.
I'd suggest removing all io.riada packages and using com.riadalabs.jira.plugins.insight.channel.external.api.facade.*
and the public model com.riadalabs.jira.plugins.insight.services.model.ObjectBean.
As far as I know from my short search, these are the supported, exported classes/services.
With Java, you can resolve your Asset object using (ObjectFacade.loadObjectBean(...)), then write its key/id to the issues's Asset's custom field or call the Assets REST API (see this article: https://developer.atlassian.com/server/jira/platform/assets-app-development)
I hope it was helpful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks very much. They are really helpful. And how can I write Asset's key/id to the issues' Asset custom field? Must I use REST API to do this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's a good question that I do not know the answer exactly :)
However I can share a code that might be helpful for you, but please be aware that I haven't tried this code, it's just the code I am adapting some code of mine and writing it here
CustomField cf = customFieldManager.getCustomFieldObject("customfield_xxxx);
ObjectBean obj = objectFacade.loadObjectBean(objectId);
IssueInputParameters iip = issueService.newIssueInputParameters()
.addCustomFieldValue(cf.getId(), String.valueOf(obj.getId()));
IssueService.UpdateValidationResult vr = issueService.validateUpdate(user, issue.getId(), iip);
if (!vr.isValid()) throw new IllegalStateException(vr.getErrorCollection().toString());
issueService.update(user, vr);
Don't fortget to import and inject objectFacade in the constructor or inject via annotation
private final ObjectFacade objectFacade;
this.objectFacade = objectFacade;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tuncay Senturk _Snapbytes_ , thanks very much for your help. But it seems to not work. Maybe I don't express clearly. What I want to do is that when I create a ticket like "SIEM-14"and choose an asset like "Reference database". In the "Related Jira issues" area of "Reference database", "SIEM-14" will be added here like the official Asset Field.
I found an interface called "com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTicketFacade". However, it can just
findTicketsForObject
instead of creating connection between object and ticket.
Really Thanks very much for your lot of help. Wish you a good day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I wish I could assist at this stage but I can't as I don't know the answer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh please feel free about that, you have really helped me a lot. Thanks very much for your advice and kindness~
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Wenjing Liu ,
Have you reviewed this article?
https://developer.atlassian.com/server/framework/atlassian-sdk/managing-dependencies/
In any case,if you don't find a satisfactory answer here, I'd recommend to leverage the Atlassian development community as well (https://developer.atlassian.com/)
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.