Referencing to external jars from the Eclipse OSGi Plug-in bundle [message #50010] |
Wed, 14 September 2005 15:48  |
Eclipse User |
|
|
|
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 #54526 is a reply to message #50042] |
Mon, 12 December 2005 11:39   |
Eclipse User |
|
|
|
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 18:23  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.22128 seconds