Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [pde-dev] No joy bundleing java libraries with plugins

Ah,  Thanks for your reply Philip (and not fobbing me off ;)

Well, I'm glad to say that I managed to import my jar files into the project
folder itself so that the ide and the runtime see it ;)  Sadly, it's a
multi-step process and IMO there is place for improvement.

Steps taken:

1 - created a folder <project_root>/lib  (optional)
2 - imported the jar file Import -> File System, then selected the jar file
from my filestore and told it to go into the lib directory
3 - open project properties
4 - Select 'Java Build Path/Libraries'.  click on Add Jar... (u should now
see the jar file in the browser)
5 - Order and export.  tick the jar.  then ok
6 - (and this is a pretty braindead step.  That really should be hooked
somehow because typing the lot manually is a bit... ehm...) Open plugin.xml.
Select the Runtime tab.  In the Run-time libraries section select Add...
Now type the path of the file in here.  I had to type
'lib/mysql-connector-java-3.1.1-alpha-bin.jar' for eg

Save, run and hack away...

Now, if only I could figure out how to implement an editor which a custom
IStorageEditorInput and make that editor react to an action in my view...


> -----Original Message-----
> From: pde-dev-admin@xxxxxxxxxxx [mailto:pde-dev-admin@xxxxxxxxxxx]On
> Behalf Of Philip Borlin
> Sent: 14 April 2004 18:12
> To: pde-dev@xxxxxxxxxxx
> Subject: Re: [pde-dev] No joy bundleing java libraries with plugins
>
>
> You need to make sure you load the driver with the correct classloader.
>
> We ran into these kinds of problems with resources.  For instance we
> have a "ui" plugin and then an "application.ui" plugin that depends on
> ui.  Ui has a resource loading/caching utility class (we are running
> Swing on top of Eclipse so we can't use all the cool little
> JFace/Workbench utilities) but our utility class's classloader can't see
> the resources directory in the application.ui plugin.  We modified our
> utility to take both a url and a classloader.  For instance: getIcon(Url
> url, Classloader classloader).  In our application.ui we make the call:
> getIcon(url, getClass().getClassloader) and all of our classpath
> problems go away.
>
> A second type of classloader problem reared its ugly head when we wanted
> to use a specific version of xerces in one of our plugins (our XML
> database requires us to have their version of xerces in the classpath).
>   We had no control of the classloading though, because xerces is loaded
> behind the scenes in the vendor's proprietary database driver.  We
> traced down that ultimately the context classloader was loading the
> driver, but the context classloader wasn't currently set to the plugin's
> classloader.  We put in a little hack around the driver initialization:
>
> Classloader odlClassloader =
> Thread.currentThread().getContextClassLoader();
> Thread.currentThread().setContextClassLoader(getClass().getClassloader());
> driver.init();
> Thread.currentThread().setContextClassLoader(oldClassloader);
>
> I am definately not an expert in classloading (in fact I have no clue
> how the context classloader works), but I have found that these tricks
> work in my application.
>
> Thanks,
> -Phil
>
> Nico Guba wrote:
>
> > First of all, Hello :)
> >
> > Eclipse 3.0M8
> >
> > I searched the archives (not much joy) and looked for a few
> days in tons of
> > docs but still have absolutely no joy bundleing a jdbc driver
> with my plugin
> > (ie I'd like to add a jar file to the plugins runtime and
> distribute it with
> > the plugin).
> >
> > I think I've been through all the wizzards and property sheets
> by now but I
> > still cannot get the plugin to 'see' that jar file.
> >
> > I even added the jar to the JRE system library (which alas the
> pde seems to
> > see) but yet STILL no joy just running he plugin. BOOM!
> >
> > java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
> > 	at
> >
> org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(Bu
> ndleLoader
> > .java:348)
> > 	at
> >
> org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadCl
> ass(Abstra
> > ctClassLoader.java:116)
> > 	at java.lang.ClassLoader.loadClass(Unknown Source)
> >
> > Hmmm,  I must have overlooked something in the documentation explaining
> > this.  Has anybody got any pointers as to where I need to look (probably
> > again)?
> >
> >
> > _______________________________________________
> > pde-dev mailing list
> > pde-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/pde-dev
> >
> >
> _______________________________________________
> pde-dev mailing list
> pde-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/pde-dev
>



Back to the top