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

Is it possible to add plugin v1 or JAR library to system-bundle?

Marek Adamek October 28, 2012

Hello,

According to this article (https://developer.atlassian.com/display/DOCS/Setting+OSGi+Manifest+Instructions+in+your+Plugin#SettingOSGiManifestInstructionsinyourPlugin-Usingthird-partycode) putting a jar into WEB_INF/lib dictionary does not make the classes inside the jar jira-wide accessible. How can I make it so?

The problem is I have a plugin (version 1) that provides some interfaces (without implementation), that are used by other plugins (version 2) to implement these interfaces. However when I add dependency to plugin v1 inside pom.xml of plugin v2 with provided scope, then the interface cannot be found (class not found exception during atlas-run). When I use compile scope then I get class cast exception as interfaces are loaded by different classloaders.

How can I make to use the provided scope, but force plugin v2 classloader to see the interface?

Thanks in advance,
Marek

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Maxim Abramovich October 29, 2012

When I upgraded JIRA 3 to 4 I used dirty hack: atlassian-plugins-osgi-2.8.1.jar has list of defaults imports in txt files. I just add my packages to osgi-packages.txt file. It works.

But it is dirty hack. Good way - it is convert plugin.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 29, 2012

interesting hack. Never noticed that jar before!

0 votes
Akeles
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 29, 2012

You are right. You can add the following arguments to the setenv.bat/setenv.sh

Replace com.myplugin.* accordingly

set JVM_SUPPORT_RECOMMENDED_ARGS=-Datlassian.org.osgi.framework.bootdelegation=sun.*,com.sun.*,com.myplugin.*

Boot delegation occurs when the plugin's class loader delegates to the JVM "boot class loader" to load a class, rather than loading the class itself or delegating to another bundle's class loader. And classes in the WEB-INF/lib are loaded by the JVM boot class loader.

0 votes
Akeles
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 29, 2012

Have you tried loading the classes in the v1 plugin using boot delegation?

Marek Adamek October 29, 2012

I haven't. I'm a bit new to OSGi framework. Could you share some details how to use boot delegation in Jira? Should I modify setenv.sh/setenv.bat file? And should I include all exported packages or just mine?

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 28, 2012
Marek Adamek October 28, 2012

Not yet, I'm searching for sollution that does not require reflection. The options I see is to modify plugin v2 classloader to see my JARs in WEB_INF/lib directory or to add my plugin v1 to system bundle like com.google.collect.* classes for example. However I do not know how to apply any of this solution. I would appriciate any hint

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events