Bitbucket plugin: dependency jira-rest-java-client-core raises org.osgi.framework.BundleException

Hi,

I'm trying to build a Bitbucket pre-receive hook plugin that checks Jira issue status before allowing 'git push'. I use the Jira REST API:

import com.atlassian.jira.rest.client.api.IssueRestClient;
import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.RestClientException;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
import com.atlassian.util.concurrent.Promise;

I have added the required dependency to my pom:

        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-rest-java-client-core</artifactId>
            <version>4.0.0</version>
            <scope>compile</scope>
        </dependency>

The package is not supplied by Bitbucket System Bundle, so scope is 'compile'.

My code compiles and works fine in a unit test, so the dependency seems to be correct basically.

But jira-rest-java-client-core brings ~45 transiently dependent packages with it and I have no idea which of them to either

  • exclude from the depdency or
  • exclude from OSGI's <Import-Package> or
  • include as additional 'compile' scope dependencies.

No matter what combination of the above I try (believe me, I have tried beyond frustration) every time there is a different BundleException. I use 'atlas-debug' (or 'atlas-cli' and 'pi') to deploy my plugin to the local Tomcat and I always get something like this:

Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.rockwell.ssb.atlas.bitbucket.plugins.bitbucket-4.13.0-git-pre-tests [129]: Unable to resolve 129.0: missing requirement [129.0] osgi.wiring.package; (osgi.wiring.package=com.rockwell.ssb.atlas.bitbucket.plugins.api) [caused by: Unable to resolve 141.0: missing requirement [141.0] osgi.wiring.package; (osgi.wiring.package=_something.new.every.time_)]
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)

  • Does someone have a pom that correctly resolves the jira-rest-java-client-core dependencies in a Bitbucket pre-receive hook plugin project that I could use?
  • Is there a systematic approach to get this resolved?

Any help greatly appreciated - thanks!

 

1 answer

1 accepted

0 votes
Accepted answer
Timothy Chin Community Champion Dec 04, 2017

There is a simpler way to do it if Jira and Bitbucket are application linked together:

This is an example using:

<groupId>com.atlassian.applinks</groupId>
<artifactId>applinks-api</artifactId>

Thanks for the Info. The solution was indeed to use a different API to access Jira. Yet in the end I decided to use javax.json, which has a low footprint and was fairly easy to include in my OSGI bundle.

I gave up on using jira-rest-java-client-core because the ~45 transiently dependent packages it brings contain too many conflicts with other components inherited from Bitbucket System Bundle to handle.

I was reluctant to try applinks-api, because the connection cannot be unit tested independently. (Needs unit test plugin on Bitbucket actually linked to Jira.)

Thanks again for your support!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

433 views 6 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you