Hi All,
I have developed an eclipse plugin which references an external jar present in a external installation directory. So I have added an entry to my bundle classpath as below:
Bundle-ClassPath: external:C:\mylib.jar
My class loads properly - and the plugin is able to detect a class MyClass
present in this external lib
.
However, the method a()
- I am calling in the class MyClass
is failing.
Method a() is as follows :
public void a()
{
URL url = this.class.getClassLoader().getResource("META-INF/startup-jar ");
...
}
so the URL which is returned is that of the eclipse plugin directory C:\eclipse3.4\test
and not of the physical location of the external jar which is C:\mylib.jar
This is causing method a()
to fail. Now, my question is -
As I don't have the external jar copied to my plugin directory (it is only present on the plugin classpath)
how can I ensure the classloader gets the URL path of my external jar and not of my plugin directory?
Note : I cannot change the classloading mechanism in the external jar as it is a third party dependency and I have no control over the code. So please suggest a solution which would help me to load the external jar class correctly so I can get the correct URL.
Thanks a lot for your help - in advance
To explain a bit more on the problem I am facing :: My external jar is present inside the installation directory of my server installation.
When the class in my external jar calls the URL url = this.class.getClassLoader().getResource("startup-jar")
it returns the URL relative to the eclipse bundle path - Something like C:\eclipse3.4...
and this URL is used for getting the boot directory (installation directory of the server) .
So it should have returned a path which is relative to the server installation directory, but instead returns a path relative to the eclipse installation directory.
Because of this, I am not able to call any APIs on the server as the server installation directory which it tries to use is incorrect.
So I wanted to know what is the best way I can handle this, so that this method call returns the server installation dir and not eclipse bundle path.