Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Class exchange - Problem with Classloader
Class exchange - Problem with Classloader [message #1778461] Thu, 14 December 2017 14:10 Go to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 63
Registered: March 2015
Member
Hello,

i have a pluginproject, lets call it A, and A has a ClassA that references another ClassX that is in plugin B.

If i deploy both plugins, obviously it works.

Now i mark the plugin-dependency from A to B as optional and put my ClassX in Plugin C.

If i deploy plugins A and C and try to initilalize my ClassA (which references ClassX) it says: ClassNotFound Exception, because ClassX could not be found.

Is there a restriction why this doesent work? And if so, is there a way i can make it work?

Thank you.

Simon

PS: All Plugins have different ids.

[Updated on: Fri, 15 December 2017 09:00]

Report message to a moderator

Re: Class exchange - Problem with Classloader [message #1778522 is a reply to message #1778461] Fri, 15 December 2017 16:20 Go to previous messageGo to next message
Eclipse UserFriend
Marking A's dependency on B or C as optional simply means that OSGi won't fail the installation of A when B or C aren't present. But if you have code in A that references classes in B or C, then you need to check that those referenced classes can be found. You can either try to resolve the classes by name (see `Class.forName()`) or wrap your code in a try-catch for `ClassNotFoundException`.
Re: Class exchange - Problem with Classloader [message #1778574 is a reply to message #1778522] Mon, 18 December 2017 06:27 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 63
Registered: March 2015
Member
Thank you for your answer. Sadly i have generated code with many classes so that its not possible to make a class-specific solution. is there a way to change the way that osgi uses to find a class?
Re: Class exchange - Problem with Classloader [message #1778665 is a reply to message #1778574] Tue, 19 December 2017 15:21 Go to previous messageGo to next message
Eclipse UserFriend
Equinox does provide class loading hooks, but I'm not sure what you would do? Ultimately your code needs to handle the case where class definitions are not available. There are some pointers to resources on this message thread:

https://www.eclipse.org/forums/index.php/t/828380/

Good luck!
Re: Class exchange - Problem with Classloader [message #1778768 is a reply to message #1778665] Thu, 21 December 2017 06:58 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 63
Registered: March 2015
Member
Hello, thx for your help.

I managed to get my mock-implementation to work as i would like to.

But now i have to create my own jar and copy it manually into my plugins directory and then restart eclipse to test ist. This takes a lot of time.

i found this tutorial https://wiki.eclipse.org/Adaptor_Hooks#Hookable_Adaptor to setup a working enviroment for developing fragments/classloader hooks. I imported the org.eclipse.osgi project into my workspace and added

-Dosgi.framework.extensions=mypluginbundleid

to my vm-arguments. but it doesent work and i get the message

!ENTRY org.eclipse.osgi 4 0 2017-12-21 07:50:49.096
!MESSAGE Bundle mypluginbundleid not found.

what am i doing wrong?

edit: I found it. The org.eclipse.osgi-project has to be directly beside the fragment-project (on the hdd) simply importing wont work.

[Updated on: Thu, 21 December 2017 09:25]

Report message to a moderator

Re: Class exchange - Problem with Classloader [message #1778798 is a reply to message #1778768] Thu, 21 December 2017 15:17 Go to previous message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 63
Registered: March 2015
Member
i got my ClassLoaderHook to work. but i am not sure how to procede from here.

what i want to do is: if the standard resolution fails (and throws a ClassNotFoundException) then i want to try a specific alternative resolution.

how can i achieve that?
Previous Topic:"Unable to get workspace root" when exporting plug-ins
Next Topic:Hide views in RCP application - custom perspective
Goto Forum:
  


Current Time: Thu Apr 18 01:22:39 GMT 2024

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

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

Back to the top