Hello,
I'm trying to develop a rest plugin for Bitbucket v4.0 and I need to use the PluginSettingsFactory yet I can't import it, lots of errors. I've tried following the guide,
but that doesn't work. If I add the component-import-key it doesn't do any good, my plugin crashes because it can't find the Factory classes.
So I tried adding the import to atlassian-plugins-component-imports.xml
<osgi:reference id="pluginSettingsFactory" interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory"/>
but that was a whole other world of hurt,
Error creating bean with name 'pluginSettingsFactory': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class[]' for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.atlassian.sal.api.pluginsettings.PluginSettingsFactory
Any help is greatly appreciated.
Community moderators have prevented the ability to post new answers.
Hi Matt,
If you are able to compile without error, but see those errors at run time I suspect the OSGi imports are the problem. You should have a section in your POM that looks like this:
<build> <plugins> <plugin> <groupId>com.atlassian.maven.plugins</groupId> <artifactId>bitbucket-maven-plugin</artifactId> <version>${amps.version}</version> <extensions>true</extensions> <configuration> <products> <product> <id>bitbucket</id> <instanceId>bitbucket</instanceId> <version>${bitbucket.version}</version> <dataVersion>${bitbucket.data.version}</dataVersion> </product> </products> <instructions> <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key> <!-- Add package to export here --> <Export-Package> com.example.api, </Export-Package> <!-- Add package import here --> <Import-Package> com.example.api, * </Import-Package> </instructions> </configuration> </plugin> </plugins> </build>
See the <Import-Package> section; probably the simplest thing to do here is to just list your own exported package (in this case com.example.api) followed by an asterisk. Note the comma at the end of the first line, this is very important and the POM will be parsed without error if you do omit it, but will not result in the asterisk import actually working like you expect.
If that does not help, please have a look at this example I just put together: https://bitbucket.org/ben_humphreys/example-sal-usage/overview
Thank you, your example provide all of the answers and help I was looking for. Is there documentation for the way you setup your plugin to use SAL?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the response. I am including the dependency in the pom.xml.
If I try the <component-import... method I end up with the following error,
ThrowableExceptionMapper Uncaught exception thrown by REST service: com/atlassian/sal/api/pluginsettings/PluginSettingsFactory
[INFO] [talledLocalContainer] java.lang.NoClassDefFoundError: com/atlassian/sal/api/pluginsettings/PluginSettingsFactory
and if I try the <osgi:reference id... method I end up with the error in my original email.
thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you say you "can't import it", do you mean compilation fails? Have you added the sal-api dependency to your Maven POM?
<dependency> <groupId>com.atlassian.sal</groupId> <artifactId>sal-api</artifactId> <scope>provided</scope> </dependency>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.