Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin)
Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #51639] Tue, 24 March 2009 03:35 Go to next message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
Hello!

I've posted a lengthy question here:
http://www.skratchdot.com/eclipse/plugins/

Basically, I cannot figure out how to share 3rd party JARs between
plugins. I believe one of the issues is because the libraries are never
explicitly referenced in my code (3rd party JARs are using SPI). If I add
the JARs to a plugin's classpath, then everything works as expected.

I've included 3 small plugins and a lengthy explaination in the link above.

One of the plugins works as expected. The other one does not.

Can someone *please* take some time to download the examples, and help me
troubleshoot this issue?

Thanks for any help you can provide.

-jeff
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #51673 is a reply to message #51639] Tue, 24 March 2009 07:51 Go to previous messageGo to next message
Ankur Sharma is currently offline Ankur SharmaFriend
Messages: 84
Registered: July 2009
Member
Jeff wrote:
> Hello!
>
> I've posted a lengthy question here:
> http://www.skratchdot.com/eclipse/plugins/
>
> Basically, I cannot figure out how to share 3rd party JARs between
> plugins. I believe one of the issues is because the libraries are never
> explicitly referenced in my code (3rd party JARs are using SPI). If I
> add the JARs to a plugin's classpath, then everything works as expected.
>
> I've included 3 small plugins and a lengthy explaination in the link above.
>
> One of the plugins works as expected. The other one does not.
>
> Can someone *please* take some time to download the examples, and help
> me troubleshoot this issue?
>
> Thanks for any help you can provide.
>
> -jeff
>
Hi Jeff

I tried executing your code and saw the problem you are referring.

Since the jLayer jars are external libraries, I feel the method-one is the right way to go about it. You are right in finding that method-two not working because the jars are not referenced directly.
Is there a reason you don't wish to do it method-one way?

Ankur..
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #51769 is a reply to message #51673] Tue, 24 March 2009 11:39 Go to previous messageGo to next message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
Ankur-

Thanks for taking the time to check out the code.

I would like to figure out how to get my plugins to use the jLayer JARs
from another plugin because I will have about 5 plugins that require
jLayer.

I do not want to have a "lib" folder in each of the 5 plugins (that
contain the same 6 JAR files).

While debugging, I notice that "Method One" loads the following classes
when correctly reading in .mp3 and .ogg files:

META-INF/services/javax.sound.sampled.spi.AudioFileReader
javazoom.spi.mpeg.sampled.file.MpegAudioFileReader
javazoom.spi.vorbis.sampled.file.VorbisAudioFileReader

"Method Two" never attempts to load those classes when clicking on an .mp3
or .ogg.


Is there a way to tell a plugin/osgi bundle to use "register" SPI classes
from another plugin/bundle?

Sorry for the questions, I'm rather new to Java / OSGI / Eclipse Plugin
development.
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #51827 is a reply to message #51639] Tue, 24 March 2009 13:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: k.wint.mas_software.de

hey Jeff,

if you use some jar in multiple plug-ins you may want to convert that jar
to a plug in.
http://www.vogella.de/articles/RichClientPlatform/article.ht ml#usingexternaljars

tc,
klaus
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #51879 is a reply to message #51827] Tue, 24 March 2009 14:45 Go to previous messageGo to next message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
Klaus-

I've actually tried that a few times (in as many variations as I could
think of). Nothing I tried worked.

I'm now thinking that it has something to do with the JARs being reliant
on SPI (Service Provider Interface).

My plugins don't actually reference any of the classes in the JARs, but
when the JARs are added to the classpath, the SPI is recognized, and
mp3/.ogg files are "auto-magically" recognized ;)

Thanks for your reply though. I had actually seen that article before
posting my question. I feel like I've tried googling everything I could
think of, and I'm not coming up w/ answers (hence the newsgroup posting) :)
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #51904 is a reply to message #51879] Tue, 24 March 2009 18:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

I think you are correct that SPI is causing you the trouble. OSGi
(Equinox) is different than a normal Java application when it comes to
class loading; it is not surprising to me that classes that are not
referenced directly from a plugin aren't visible to that plugin without
doing something special.

I suggest you post the problem to the eclipse.platform and
eclipse.technology.equinox newsgroups to see if the
OSGi/plugin-class-loading gurus there can offer any advice. This is not
really a PDE question, per se.

Hope this helps,
Eric


On 3/24/2009 10:45 AM, Jeff S. wrote:
> Klaus-
>
> I've actually tried that a few times (in as many variations as I could
> think of). Nothing I tried worked.
>
> I'm now thinking that it has something to do with the JARs being reliant
> on SPI (Service Provider Interface).
>
> My plugins don't actually reference any of the classes in the JARs, but
> when the JARs are added to the classpath, the SPI is recognized, and
> mp3/.ogg files are "auto-magically" recognized ;)
>
> Thanks for your reply though. I had actually seen that article before
> posting my question. I feel like I've tried googling everything I could
> think of, and I'm not coming up w/ answers (hence the newsgroup posting) :)
>
>
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #51930 is a reply to message #51904] Tue, 24 March 2009 22:31 Go to previous messageGo to next message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
Thank you for your suggestion Eric!
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #51981 is a reply to message #51930] Wed, 25 March 2009 08:35 Go to previous message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
In case anyone was interested, I solved my problem.

All I needed to do was copy the "META-INF/services" folder to each plugin
that required the "3rd Party JAR plugin":

http://www.eclipse.org/newsportal/article.php?id=80607&g roup=eclipse.platform#80607
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #593836 is a reply to message #51639] Tue, 24 March 2009 07:51 Go to previous message
Ankur Sharma is currently offline Ankur SharmaFriend
Messages: 84
Registered: July 2009
Member
Jeff wrote:
> Hello!
>
> I've posted a lengthy question here:
> http://www.skratchdot.com/eclipse/plugins/
>
> Basically, I cannot figure out how to share 3rd party JARs between
> plugins. I believe one of the issues is because the libraries are never
> explicitly referenced in my code (3rd party JARs are using SPI). If I
> add the JARs to a plugin's classpath, then everything works as expected.
>
> I've included 3 small plugins and a lengthy explaination in the link above.
>
> One of the plugins works as expected. The other one does not.
>
> Can someone *please* take some time to download the examples, and help
> me troubleshoot this issue?
>
> Thanks for any help you can provide.
>
> -jeff
>
Hi Jeff

I tried executing your code and saw the problem you are referring.

Since the jLayer jars are external libraries, I feel the method-one is the right way to go about it. You are right in finding that method-two not working because the jars are not referenced directly.
Is there a reason you don't wish to do it method-one way?

Ankur..
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #593868 is a reply to message #51673] Tue, 24 March 2009 11:39 Go to previous message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
Ankur-

Thanks for taking the time to check out the code.

I would like to figure out how to get my plugins to use the jLayer JARs
from another plugin because I will have about 5 plugins that require
jLayer.

I do not want to have a "lib" folder in each of the 5 plugins (that
contain the same 6 JAR files).

While debugging, I notice that "Method One" loads the following classes
when correctly reading in .mp3 and .ogg files:

META-INF/services/javax.sound.sampled.spi.AudioFileReader
javazoom.spi.mpeg.sampled.file.MpegAudioFileReader
javazoom.spi.vorbis.sampled.file.VorbisAudioFileReader

"Method Two" never attempts to load those classes when clicking on an .mp3
or .ogg.


Is there a way to tell a plugin/osgi bundle to use "register" SPI classes
from another plugin/bundle?

Sorry for the questions, I'm rather new to Java / OSGI / Eclipse Plugin
development.
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #593897 is a reply to message #51639] Tue, 24 March 2009 13:14 Go to previous message
Klaus is currently offline KlausFriend
Messages: 7
Registered: July 2009
Junior Member
hey Jeff,

if you use some jar in multiple plug-ins you may want to convert that jar
to a plug in.
http://www.vogella.de/articles/RichClientPlatform/article.ht ml#usingexternaljars

tc,
klaus
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #593914 is a reply to message #51827] Tue, 24 March 2009 14:45 Go to previous message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
Klaus-

I've actually tried that a few times (in as many variations as I could
think of). Nothing I tried worked.

I'm now thinking that it has something to do with the JARs being reliant
on SPI (Service Provider Interface).

My plugins don't actually reference any of the classes in the JARs, but
when the JARs are added to the classpath, the SPI is recognized, and
mp3/.ogg files are "auto-magically" recognized ;)

Thanks for your reply though. I had actually seen that article before
posting my question. I feel like I've tried googling everything I could
think of, and I'm not coming up w/ answers (hence the newsgroup posting) :)
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #593928 is a reply to message #51879] Tue, 24 March 2009 18:53 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
I think you are correct that SPI is causing you the trouble. OSGi
(Equinox) is different than a normal Java application when it comes to
class loading; it is not surprising to me that classes that are not
referenced directly from a plugin aren't visible to that plugin without
doing something special.

I suggest you post the problem to the eclipse.platform and
eclipse.technology.equinox newsgroups to see if the
OSGi/plugin-class-loading gurus there can offer any advice. This is not
really a PDE question, per se.

Hope this helps,
Eric


On 3/24/2009 10:45 AM, Jeff S. wrote:
> Klaus-
>
> I've actually tried that a few times (in as many variations as I could
> think of). Nothing I tried worked.
>
> I'm now thinking that it has something to do with the JARs being reliant
> on SPI (Service Provider Interface).
>
> My plugins don't actually reference any of the classes in the JARs, but
> when the JARs are added to the classpath, the SPI is recognized, and
> mp3/.ogg files are "auto-magically" recognized ;)
>
> Thanks for your reply though. I had actually seen that article before
> posting my question. I feel like I've tried googling everything I could
> think of, and I'm not coming up w/ answers (hence the newsgroup posting) :)
>
>
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #593935 is a reply to message #51904] Tue, 24 March 2009 22:31 Go to previous message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
Thank you for your suggestion Eric!
Re: Share 3rd party JARs between plugins (Buddy-Policy / SPI / JARS as plugin) [message #593951 is a reply to message #51930] Wed, 25 March 2009 08:35 Go to previous message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
In case anyone was interested, I solved my problem.

All I needed to do was copy the "META-INF/services" folder to each plugin
that required the "3rd Party JAR plugin":

http://www.eclipse.org/newsportal/article.php?id=80607&g roup=eclipse.platform#80607
Previous Topic:Extending the Samples wizard in Eclipse welcome screen
Next Topic:How to define a "garage"-folder?
Goto Forum:
  


Current Time: Fri Apr 19 20:53:32 GMT 2024

Powered by FUDForum. Page generated in 0.03845 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top