Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Does fastdev work with a plugin that uses servlets/rest?

Henrik Heimbuerger December 7, 2015

I'm using the SDK v6.1.2 to create a Bitbucket Server v4.1.3. plugin (using `atlas-create-bitbucket-plugin`). This basic plugin runs, loads and can be reloaded with the fastdev UI or `atlas-cli`.

However, as soon as I introduce a servlet or a rest resource, the plugin can't be reloaded anymore, resulting in the following error message in the logs (I've cut out the full stacktraces):

[INFO] [talledLocalContainer] 2015-12-07 11:29:28,857 ERROR [UpmAsynchronousTaskManager:thread-1] admin @1ELID1x689x506x0 127.0.0.1 "POST /rest/plugins/1.0/ HTTP/1.1" c.a.plugin.osgi.factory.OsgiPlugin Detected an error (BundleException) enabling the plugin 'com.example.my-plugin' : Unresolved constraint in bundle com.example.myplugin [123]: Unable to resolve 123.0: missing requirement [123.0] osgi.wiring.package; (&(osgi.wiring.package=javax.servlet)(version>=2.5.0)(!(version>=3.0.0))).  This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN
[INFO] [talledLocalContainer] 2015-12-07 11:29:28,857 WARN  [UpmAsynchronousTaskManager:thread-1] admin @1ELID1x689x506x0 127.0.0.1 "POST /rest/plugins/1.0/ HTTP/1.1" c.a.plugin.impl.AbstractPlugin Unable to enable plugin 'com.example.my-plugin'
[INFO] [talledLocalContainer] 2015-12-07 11:29:28,868 WARN  [UpmAsynchronousTaskManager:thread-1] admin @1ELID1x689x506x0 127.0.0.1 "POST /rest/plugins/1.0/ HTTP/1.1" c.a.plugin.impl.AbstractPlugin Because of this exception
[INFO] [talledLocalContainer] com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.example.my-plugin
[INFO] [talledLocalContainer] Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.example.myplugin [123]: Unable to resolve 123.0: missing requirement [123.0] osgi.wiring.package; (&(osgi.wiring.package=javax.servlet)(version>=2.5.0)(!(version>=3.0.0)))

It's referring to `javax.servlet`, but that's only a groupId, not an artifactId, correct?

Is it referring to the `servlet-api` artifact? `atlas-create-bitbucket-plugin-module` seems to insert a dependency to this in version 2.4, which would explain the unresolved constraint. Which one is correct?

But I've already tried giving that a `<version>2.5</version>` in my POM, with no effect.

---

PS: https://developer.atlassian.com/docs/faq/advanced-plugin-development-faq/plugins-that-cannot-be-reloaded-with-fastdev-or-pi supposedly has a list of plugin module types which cannot be reloaded, but Bitbucket isn't mentioned there at all (not even Stash…)!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Ben Humphreys
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 7, 2015

Hi Henrik,

Your dependency on javax.servlet should look like this:

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

That way you will get the correct version from the version of Bitbucket Server you are building against.

However due to AMPS-1165 (atlas-cli/pi appears to build incorrect Import-Package headers) many Bitbucket Server plugins will no longer be able to use atlas-cli's "pi" command. Just in case yours falls into that category, here are some instructions for an alternative.

As an alternative many have been using Quick Reload and I would encourage you to give it a try. The instructions are on the website, but here are the bits you need to add to your pom.xml:

<properties>
    <quick.reload.version>1.28</quick.reload.version>
</properties>

and

<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>bitbucket-maven-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
...
</instructions>
      <products>
<product>
<id>bitbucket</id>
<instanceId>bitbucket</instanceId>
<version>${bitbucket.version}</version>
<dataVersion>${bitbucket.data.version}</dataVersion>
        <systemPropertyVariables>
...
</systemPropertyVariables>
        <pluginArtifacts>
<!-- See https://bitbucket.org/atlassianlabs/quickreload -->
<pluginArtifact>
<groupId>com.atlassian.labs.plugins</groupId>
<artifactId>quickreload</artifactId>
<version>${quick.reload.version}</version>
</pluginArtifact>
</pluginArtifacts>
</product>
</products>
      <!-- Disable FastDev since it conflicts with QuickReload. Also disable some other things to make AMPS faster -->
<enableFastdev>false</enableFastdev>
<useFastdevCli>false</useFastdevCli>
<enablePde>false</enablePde>
<enableQuickReload>true</enableQuickReload>
<quickReloadVersion>${quick.reload.version}</quickReloadVersion>

    </plugin>
  </plugins>
</build>

Sorry, I know that is a large chunk of XML. Hopefully you can discern the context and the bits you need to add. If it is not clear let me know and I'll post a full example plugin's pom.xml with Quick Reload configured.

Then just start your plugin development environment with any of the commands: "atlas-run", "atlas-debug", "mvn bitbucket:run" or "mvn bitbucket:debug"

When you are ready to reload you plugin, in another window, just rebuild the package with "mvn package" or "atlas-package" and it will reload automatically.

Quick Reload by default is rather silent and it is not obvious from the logs when the reload has actually completed. Enabling INFO level logging for the Quick Reload loggers can be done like so:

curl -u admin -v -X PUT -d "" -H "Content-Type: application/json" \
http://localhost:7990/bitbucket/rest/api/latest/logs/logger/com.atlassian.labs.plugins.quickreload/info

After this is enabled, each time a reload completes the message "Quick Reload Finished" will be logged.

Hope this helps!

Regards,
Ben

Henrik Heimbuerger December 7, 2015

This is great information, Ben, thank you so much! I've managed to set up QuickReload and I've already done my first (artificial) reload in 5s instead of five minutes! :) I wish I had known all of this sooner. Is there any reason why this isn't part of the official documentation?

Ben Humphreys
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 8, 2015

I'm really glad to hear this is working well for you! I can't speak for any product other than Stash/Bitbucket Server, but it was only recently, with our 4.0 release, that the OSGi changes broken atlas-cli/pi for some plugins. I will see what I can do about getting QuickReload featured in our documentation somewhere.

Henrik Heimbuerger December 8, 2015

@Ben Humphreys Even before it broke, I had some issues with FastDev. I've been using Quick Reload all day yesterday and it has been working great for me! Really think you should promote it more and phase out FastDev quickly. (But I also can't speak for any other product than Bitbucket Server.)

TAGS
AUG Leaders

Atlassian Community Events