Class exchange - Problem with Classloader [message #1778461] |
Thu, 14 December 2017 14:10 |
Simon BBBBBBB 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 |
Eclipse User |
|
|
|
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 #1778768 is a reply to message #1778665] |
Thu, 21 December 2017 06:58 |
Simon BBBBBBB 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.01431 seconds