Can't make my plugin to work in Jira 10

Hi,

I have a jira plugin, worked on Jira 9.X.X
Tried to make it compatable for Jira 10.X.X with no luck.
The app have no API, there is only 1 Java file that is a custom condition
extends AbstractWebCondition
the rest are all JS files

when trying to install the plugin in Jira getting this error in logs:

com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.company.jira.myPlugin
	at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:423)
	at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:260)
...
Caused by: org.osgi.framework.BundleException: Unable to resolve com.company.jira.myPlugin [261](R 261.0): missing requirement [com.company.jira.myPlugin [261](R 261.0)] osgi.wiring.package; (osgi.wiring.package=org.python.util) Unresolved requirements: [[com.company.jira.myPlugin [261](R 261.0)] osgi.wiring.package; (osgi.wiring.package=org.python.util)]
...
...

this is my pom:

<dependencies>
        <!--suppress VulnerableLibrariesLocal -->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.velocity.htmlsafe</groupId>
            <artifactId>velocity-htmlsafe</artifactId>
            <version>5.0.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.platform.dependencies</groupId>
                <artifactId>platform-public-api</artifactId>
                <version>${platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <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>
                    <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.company.jira.myPlugin.api,</Export-Package>
                        <!-- Add package import here -->
                        <Import-Package>
                            org.python.util,
                            org.jspecify.annotations,
                            *
                        </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>10.3.0</jira.version>
        <amps.version>9.1.1</amps.version>
        <platform.version>7.2.4</platform.version>
        <plugin.testrunner.version>2.0.9</plugin.testrunner.version>
        <!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
        <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>

Can anyone please point me to what is wrong?
what am i missing?

Thanks.

Is the org.python.util somewhere referenced in your own code?

Then you’ll have to either:

  • Remove it, as its no longer available to your plugin
  • Or include and package the library yourself.

If you no-where reference it in your code:

  1. Double check that it isn’t in your jar’s META-INF/manifest.mf

If it is also no-where there, then JIRA screws up and adds magic imports.
In general we fixed that in other Atlassian platforms by:

  • Ensure that you have a Atlassian-Plugin-Key: your.apps.key in the META-INF/manifest.mf.
    Otherwise the Atlassian platforms does more magic and often fails at it.
  • We generally moved to Spring Java based configuration, that seems to reduce the likelyhood of mistery errors as well.

Thank you for your respond @RomanStoffel

i am not using org.python.util anywhere in my code.
i just removed it now from my pom Import-Package and this error is gone.

but i have another error now:

Caused by: java.io.FileNotFoundException: OSGi resource[classpath:com/atlassian/plugin/web/Condition.class|bnd.id=263|bnd.sym=com.pitronote.jira.select2] cannot be resolved to URL because it does not exist

the Web Condition i am using is: public class myCondition extends AbstractWebCondition
then in my atlassian-plugin.xml:

<web-resource key="my-general" name="my General">
    <condition class="com.company.jira.myPlugin.condition.myCondition"/>
....
....

Seems like the problem is the condition i mentioned before in atlassian-plugin.xml

According to this:
https://bitbucket.org/atlassian/atlassian-plugins-webresource/src/c3fa362e247708e2ddae3a75e8f47972574f6b90/UPGRADE_700.md?at=release/7.0.x

<condition> is no longer support for <web-resource>

com.atlassian.plugin.web.Condition can no longer be used on web-resources, use UrlReadingCondition instead. Condition will not be deleted, it will remain part of web fragments and can continue to be used with web-item, web-section, and web-panel.

any idea how to use the UrlReadingCondition?
and in the Java class, should i use something else then extends AbstractWebCondition?

Managed to solve this.

seems like <condition> still works inside <web-resource>
the problem was in the class, instead of using extends AbstractWebCondition
I changed to implements UrlReadingCondition and now everything works :slight_smile:

Hi @nirhai

In Jira 10, the web-resources element still supports the condition element.
However, it is important to note that the condition class must implement the UrlReadingCondition.

Example:

import com.atlassian.plugin.PluginParseException;
import com.atlassian.webresource.api.QueryParams;
import com.atlassian.webresource.api.url.UrlBuilder;
import com.atlassian.webresource.spi.condition.UrlReadingCondition;

import javax.inject.Inject;
import java.util.Map;

public class LicenseIsValid implements UrlReadingCondition {

    @Inject
    public LicenseIsValid(){ }

    @Override
    public void init(Map<String, String> params) throws PluginParseException { }

    @Override
    public void addToUrl(UrlBuilder urlBuilder) {

    }

    @Override
    public boolean shouldDisplay(QueryParams queryParams) {

        //Logic implementation for the app

        return true;
    }
}

Cheers
Adam

1 Like

Thank you @adam.labus

I have just feagured it out too :slight_smile: