Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Referencing to external jars from the Eclipse OSGi Plug-in bundle
Referencing to external jars from the Eclipse OSGi Plug-in bundle [message #50010] Wed, 14 September 2005 19:48 Go to next message
Eclipse UserFriend
Originally posted by: lamikr.cc.jyu.fi

Hi

I have an standalone repository application with Eclipse 3.1 that has
Java interface for accessing it. Now I would like to make Eclipse a
plug-in that uses repositorys java interface, but I am having problems
to get plug-in to load required classes.

Simplified example is following:

1) Repository offers repo.jar that can be used for controlling it
2) I have created EclipseRepoPlugin that access to classes in repo.jar.
The plug-in has all of it's files like plugin.xml and jars in directory
"eclipse/plugins/eclipse.repo.plugin"
3) If I copy repo.jar to directory "eclipse/plugins/eclipse.repo.plugin"
and add to manifest.mf of plugin following line then everything works
just fine.
Bundle-ClassPath: EclipseRepoPlugin.jar, repo.jar
4) But if I instead in step 3 try to reference to the original repo.jar
in the repository c:\Programs\RepoTool\lib\repo.jar by changing Plugins
Bundle-ClassPath to following I get classnot found error.
Bundle-ClassPath: EclipseRepoPlugin.jar, c:\Programs\RepoTool\lib\repo.jar

Does OSGi has any solutions for my problem or should I try to make my
own classloader somehow?

I have noticed that Bundle-classpath seems to accept relative paths like
Bundle-ClassPath: EclipseRepoPlugin.jar, ../../RepoTool/lib/repo.jar
but there may be situations when RepoTool is in the network drive and
Eclipse is in the workstations c-drive.

The copy of repo.jar is not a good solution as it is third party product
and there may be updates to it. In addition I may not have rights to
release that jar itself...

Mika
Re: Referencing to external jars from the Eclipse OSGi Plug-in bundle [message #50042 is a reply to message #50010] Thu, 15 September 2005 02:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jeff_nospam_mcaffer.ca.ibm.com

I have to say that I am surprised it worked with relative paths. I was
pretty sure that we didn't allow that...

In any event, the answer to your question is to use external: at the
beginning of your classpath entry. For example
Bundle-Classpath: external:$JDBC_HOME$/drivers/jdbc.jar
Here you do not have to use variables (they bind to Enviroment vars and
system properties) but you can. You could also spec an absolute path.

NOTE: In your case you may be ok using this IF you are not exporting parts
of repo.jar. If you are exporting parts of the library then you have to be
sensitive to changes in that jar's content. Your last point about the jar
being 3rd party and possibly being updated scared me. If you are exposing
the jar to others via your plugin and the jar changes, your plugin should
change as well. At the very least you might be exporting different packages
and the version number of the plugin should change. Laziness in this area
is one of the prime problems with this approach. You can easily end up with
a plugin definition that does not match its content.

Jeff


"lamikr" <lamikr@cc.jyu.fi> wrote in message
news:dg9uqs$hn5$1@news.eclipse.org...
> Hi
>
> I have an standalone repository application with Eclipse 3.1 that has
> Java interface for accessing it. Now I would like to make Eclipse a
> plug-in that uses repositorys java interface, but I am having problems
> to get plug-in to load required classes.
>
> Simplified example is following:
>
> 1) Repository offers repo.jar that can be used for controlling it
> 2) I have created EclipseRepoPlugin that access to classes in repo.jar.
> The plug-in has all of it's files like plugin.xml and jars in directory
> "eclipse/plugins/eclipse.repo.plugin"
> 3) If I copy repo.jar to directory "eclipse/plugins/eclipse.repo.plugin"
> and add to manifest.mf of plugin following line then everything works
> just fine.
> Bundle-ClassPath: EclipseRepoPlugin.jar, repo.jar
> 4) But if I instead in step 3 try to reference to the original repo.jar
> in the repository c:\Programs\RepoTool\lib\repo.jar by changing Plugins
> Bundle-ClassPath to following I get classnot found error.
> Bundle-ClassPath: EclipseRepoPlugin.jar, c:\Programs\RepoTool\lib\repo.jar
>
> Does OSGi has any solutions for my problem or should I try to make my
> own classloader somehow?
>
> I have noticed that Bundle-classpath seems to accept relative paths like
> Bundle-ClassPath: EclipseRepoPlugin.jar, ../../RepoTool/lib/repo.jar
> but there may be situations when RepoTool is in the network drive and
> Eclipse is in the workstations c-drive.
>
> The copy of repo.jar is not a good solution as it is third party product
> and there may be updates to it. In addition I may not have rights to
> release that jar itself...
>
> Mika
Re: Referencing to external jars from the Eclipse OSGi Plug-in bundle [message #50073 is a reply to message #50042] Thu, 15 September 2005 15:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lamikr.cc.jyu.fi

Thanks for the external tip, it helped!

Jeff McAffer wrote:
> I have to say that I am surprised it worked with relative paths. I was
> pretty sure that we didn't allow that...

Well, should I fill a bug :-)

>
> In any event, the answer to your question is to use external: at the
> beginning of your classpath entry. For example
> Bundle-Classpath: external:$JDBC_HOME$/drivers/jdbc.jar
> Here you do not have to use variables (they bind to Enviroment vars and
> system properties) but you can. You could also spec an absolute path.

I tried earlier to find solution for my problem both from the net and
eclicpse help pages but any of them mentioned this magic keyword.

Another thing which sounds interesting but does not have much
documentation is this Eclipse-BuddyPolicy. Documentation talks that it
helps plug-in to resolve user classes but what those are? Are they
classes generated by the plug-in or could external jar somehow register
to be a buddy?

> NOTE: In your case you may be ok using this IF you are not exporting parts
> of repo.jar. If you are exporting parts of the library then you have to be
> sensitive to changes in that jar's content. Your last point about the jar
> being 3rd party and possibly being updated scared me. If you are exposing
> the jar to others via your plugin and the jar changes, your plugin should
> change as well. At the very least you might be exporting different packages
> and the version number of the plugin should change. Laziness in this area
> is one of the prime problems with this approach. You can easily end up with
> a plugin definition that does not match its content.

Yeh, I agree that this sounds very scary design. But currently I am just
investigating different possibilities and try and this one seemed
quite flexible, if the update policy is just well controlled.

Mika
Re: Referencing to external jars from the Eclipse OSGi Plug-in bundle [message #50188 is a reply to message #50073] Fri, 23 September 2005 14:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jeff_nospam_mcaffer.ca.ibm.com

"lamikr" <lamikr@cc.jyu.fi> wrote in message
news:dgc2gi$au9$1@news.eclipse.org...
> Thanks for the external tip, it helped!
>
> Jeff McAffer wrote:
> > I have to say that I am surprised it worked with relative paths. I was
> > pretty sure that we didn't allow that...
>
> Well, should I fill a bug :-)

Yup. On first glance you should at least need to put the external: on it.

> > In any event, the answer to your question is to use external: at the
> > beginning of your classpath entry. For example
> > Bundle-Classpath: external:$JDBC_HOME$/drivers/jdbc.jar
> > Here you do not have to use variables (they bind to Enviroment vars and
> > system properties) but you can. You could also spec an absolute path.
>
> I tried earlier to find solution for my problem both from the net and
> eclicpse help pages but any of them mentioned this magic keyword.
>
> Another thing which sounds interesting but does not have much
> documentation is this Eclipse-BuddyPolicy. Documentation talks that it
> helps plug-in to resolve user classes but what those are? Are they
> classes generated by the plug-in or could external jar somehow register
> to be a buddy?

These are both very new. We are not really advertising them until we get a
handle on how it SHOULD be used. There is alot of danger in using external:
and buddy loading. Having said that, they do resolve some real issues for
some people. I believe there is some info in the doc. I know that there is
info in the new RCP book (http://eclipsercp.org)

Jeff
Re: Referencing to external jars from the Eclipse OSGi Plug-in bundle [message #54526 is a reply to message #50042] Mon, 12 December 2005 16:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aparasur.ugs.com

Jeff,
I have a problem similar to Mika's. I posted my message on the
"eclipse.platform" newsgroup and the only reply I received points to your
post.

My plugins reference third party jars. It appears that the eclipse
recommendation is to create a separate plugin that holds all the third party
jars and have a dependency on this third party jar. The problem with this
approach is that the third party jars are maintained centrally for all
projects to use and I don't want to keep resync-ing the jars in the plugin
every time the jars in the central location are updated.

I tried using the "external" keyword in "Bundle-Classpath" and I can get it
to work if I hardcode the directory. However, I want to use an environment
variable or some other mechanism that can be configured and am not able to
get it to work. I have set a system environment variable called
"THIRD_PARTY". How do I specify it in the MANIFEST.MF file? In yout post,
you have mentioned $JDBC_HOME$/drivers/jdbc.jar. How/where is JDBC_HOME
defined? And does it need to be prefixed and suffixed with the "$" sign? I
tried specifying $THIRD_PARTY$/xxxx.jar but can't get it to work.
Appreciate your help.

Thanks in advance.
-Arvind


"Jeff McAffer" <jeff_nospam_mcaffer@ca.ibm.com> wrote in message
news:dganun$fqi$1@news.eclipse.org...
>I have to say that I am surprised it worked with relative paths. I was
> pretty sure that we didn't allow that...
>
> In any event, the answer to your question is to use external: at the
> beginning of your classpath entry. For example
> Bundle-Classpath: external:$JDBC_HOME$/drivers/jdbc.jar
> Here you do not have to use variables (they bind to Enviroment vars and
> system properties) but you can. You could also spec an absolute path.
>
> NOTE: In your case you may be ok using this IF you are not exporting
> parts
> of repo.jar. If you are exporting parts of the library then you have to
> be
> sensitive to changes in that jar's content. Your last point about the jar
> being 3rd party and possibly being updated scared me. If you are exposing
> the jar to others via your plugin and the jar changes, your plugin should
> change as well. At the very least you might be exporting different
> packages
> and the version number of the plugin should change. Laziness in this area
> is one of the prime problems with this approach. You can easily end up
> with
> a plugin definition that does not match its content.
>
> Jeff
>
>
> "lamikr" <lamikr@cc.jyu.fi> wrote in message
> news:dg9uqs$hn5$1@news.eclipse.org...
>> Hi
>>
>> I have an standalone repository application with Eclipse 3.1 that has
>> Java interface for accessing it. Now I would like to make Eclipse a
>> plug-in that uses repositorys java interface, but I am having problems
>> to get plug-in to load required classes.
>>
>> Simplified example is following:
>>
>> 1) Repository offers repo.jar that can be used for controlling it
>> 2) I have created EclipseRepoPlugin that access to classes in repo.jar.
>> The plug-in has all of it's files like plugin.xml and jars in directory
>> "eclipse/plugins/eclipse.repo.plugin"
>> 3) If I copy repo.jar to directory "eclipse/plugins/eclipse.repo.plugin"
>> and add to manifest.mf of plugin following line then everything works
>> just fine.
>> Bundle-ClassPath: EclipseRepoPlugin.jar, repo.jar
>> 4) But if I instead in step 3 try to reference to the original repo.jar
>> in the repository c:\Programs\RepoTool\lib\repo.jar by changing Plugins
>> Bundle-ClassPath to following I get classnot found error.
>> Bundle-ClassPath: EclipseRepoPlugin.jar,
>> c:\Programs\RepoTool\lib\repo.jar
>>
>> Does OSGi has any solutions for my problem or should I try to make my
>> own classloader somehow?
>>
>> I have noticed that Bundle-classpath seems to accept relative paths like
>> Bundle-ClassPath: EclipseRepoPlugin.jar, ../../RepoTool/lib/repo.jar
>> but there may be situations when RepoTool is in the network drive and
>> Eclipse is in the workstations c-drive.
>>
>> The copy of repo.jar is not a good solution as it is third party product
>> and there may be updates to it. In addition I may not have rights to
>> release that jar itself...
>>
>> Mika
>
>
Re: Referencing to external jars from the Eclipse OSGi Plug-in bundle [message #54814 is a reply to message #54526] Mon, 12 December 2005 23:23 Go to previous message
Eclipse UserFriend
Originally posted by: jeff_nospam_mcaffer.ca.ibm.com

"Arvind Parasuram" <aparasur@ugs.com> wrote in message
news:dnk94r$3i0$1@news.eclipse.org...
> I tried using the "external" keyword in "Bundle-Classpath" and I can get
it
> to work if I hardcode the directory. However, I want to use an environment
> variable or some other mechanism that can be configured and am not able to
> get it to work. I have set a system environment variable called
> "THIRD_PARTY". How do I specify it in the MANIFEST.MF file? In yout post,
> you have mentioned $JDBC_HOME$/drivers/jdbc.jar. How/where is JDBC_HOME
> defined? And does it need to be prefixed and suffixed with the "$" sign? I
> tried specifying $THIRD_PARTY$/xxxx.jar but can't get it to work.

I'm surprised that the $THIRD_PARTY$/xxxx.jar didn't work. Did you define
THIRD_PARTY as an environment var? That should work. For an experiment,
try defining it as a system propety (use -D on the command line or put it in
the config.ini).

BTW, your example illustrates why this approach is dangerous. If you update
the jars in some central place and those updates are independent of the
manifest.mf then how do you ensure that the metadata in the manifest is
accurate wrt the jar? There may be API changes? new packages?...

Summary: This approach can work in limited situations but please do be
careful.

Jeff
Previous Topic:equinox vs. standard Plug-in Project
Next Topic:Stand alone tutorial
Goto Forum:
  


Current Time: Fri Mar 29 09:13:26 GMT 2024

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

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

Back to the top