Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Using own classloader for plugin
Using own classloader for plugin [message #207828] Tue, 09 March 2004 06:26 Go to next message
Eclipse UserFriend
Originally posted by: mremme.braintags.de

Hi all,

i am creating a plugin where i need to use an own classloader. Is it
possible to define the classloader to be used inside the plugin.xml as
extension point for the complete Plugin?

tia, Michael
Re: Using own classloader for plugin [message #207881 is a reply to message #207828] Tue, 09 March 2004 08:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: igorf.ca.ibm.com

No, there is no such extension point. What exactly do you need this
classloader for? I might give you some ideas, but I need to understand
your problem better.

Remme wrote:
> Hi all,
>
> i am creating a plugin where i need to use an own classloader. Is it
> possible to define the classloader to be used inside the plugin.xml as
> extension point for the complete Plugin?
>
> tia, Michael
>
Re: Using own classloader for plugin [message #207951 is a reply to message #207881] Tue, 09 March 2004 09:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mremme.braintags.de

Thank you for reply. The thing is the following:

I am building a plugin, where used classes are not all placed inside the
local classpath. Part of classes are coming from an own server. Those
classes are buildt by a factory, thus, additionally, i don't know them
complete, only the interfaces / abstracts from a framework.
For this i need to add an own classloader, which is able to find the
needed classes.
So far no problem, but since the local classes are loaded by the standard
plugin classloader, which does not know about the network classloader, i
am running into a ClassNotFoundException as soon as i am trying to load a
class, which was loaded by the plugin classloader and which is using
another class, which is stored on the server.
At that time i am starting to build a forced loader, which is using
resources from local files and is using defineClass to build the class and
will see, how this will run.
But the simply best solution would be if i could load the plugin class
already under my own classloader.

Michael


Igor Fedorenko wrote:

> No, there is no such extension point. What exactly do you need this
> classloader for? I might give you some ideas, but I need to understand
> your problem better.

> Remme wrote:
> > Hi all,
> >
> > i am creating a plugin where i need to use an own classloader. Is it
> > possible to define the classloader to be used inside the plugin.xml as
> > extension point for the complete Plugin?
> >
> > tia, Michael
> >
Re: Using own classloader for plugin [message #208319 is a reply to message #207951] Tue, 09 March 2004 19:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ifedorenko.rogers.com

Remme wrote:
> Thank you for reply. The thing is the following:
>
> I am building a plugin, where used classes are not all placed inside the
> local classpath. Part of classes are coming from an own server. Those
> classes are buildt by a factory, thus, additionally, i don't know them
> complete, only the interfaces / abstracts from a framework.
> For this i need to add an own classloader, which is able to find the
> needed classes.
> So far no problem, but since the local classes are loaded by the standard
> plugin classloader, which does not know about the network classloader, i
> am running into a ClassNotFoundException as soon as i am trying to load a
> class, which was loaded by the plugin classloader and which is using
> another class, which is stored on the server.
How do you get instances of the server provided classes? Do you use JNDI
lookup or you have your own factory that knows classnames to be
instantiated and calls Class.forName? How would your code and JVM's
classpath look like if it did not run inside Eclipse?

For JNDI to work you need to set your network classloader as thread
context classloader before calling context.lookup.

For the factory to work, you need to make sure that it uses your network
classloader to load classes by name. This may be little bit clumsy, but
should work.

> At that time i am starting to build a forced loader, which is using
> resources from local files and is using defineClass to build the class and
> will see, how this will run.
> But the simply best solution would be if i could load the plugin class
> already under my own classloader.
>
> Michael
>
>
> Igor Fedorenko wrote:
>
>
>>No, there is no such extension point. What exactly do you need this
>>classloader for? I might give you some ideas, but I need to understand
>>your problem better.
>
>
>>Remme wrote:
>>
>>>Hi all,
>>>
>>>i am creating a plugin where i need to use an own classloader. Is it
>>>possible to define the classloader to be used inside the plugin.xml as
>>>extension point for the complete Plugin?
>>>
>>>tia, Michael
>>>
>
>
>
Re: Using own classloader for plugin [message #208467 is a reply to message #207951] Tue, 09 March 2004 23:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pascal.ibm.canada

If you are targeting eclipse 3.0, did you look at trying to create a new
plugin dynamically and dynamically install it once you know the classes?

There is also another example of interesting usage of classloader in the
ant.core plugin which run apps using external jars.

PaScaL

Remme wrote:

> Thank you for reply. The thing is the following:
>
> I am building a plugin, where used classes are not all placed inside the
> local classpath. Part of classes are coming from an own server. Those
> classes are buildt by a factory, thus, additionally, i don't know them
> complete, only the interfaces / abstracts from a framework.
> For this i need to add an own classloader, which is able to find the
> needed classes.
> So far no problem, but since the local classes are loaded by the standard
> plugin classloader, which does not know about the network classloader, i
> am running into a ClassNotFoundException as soon as i am trying to load a
> class, which was loaded by the plugin classloader and which is using
> another class, which is stored on the server.
> At that time i am starting to build a forced loader, which is using
> resources from local files and is using defineClass to build the class and
> will see, how this will run.
> But the simply best solution would be if i could load the plugin class
> already under my own classloader.
>
> Michael
>
>
> Igor Fedorenko wrote:
>
>
>>No, there is no such extension point. What exactly do you need this
>>classloader for? I might give you some ideas, but I need to understand
>>your problem better.
>
>
>>Remme wrote:
>>
>>>Hi all,
>>>
>>>i am creating a plugin where i need to use an own classloader. Is it
>>>possible to define the classloader to be used inside the plugin.xml as
>>>extension point for the complete Plugin?
>>>
>>>tia, Michael
>>>
>
>
>
Re: Using own classloader for plugin [message #208869 is a reply to message #208319] Wed, 10 March 2004 11:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mremme.braintags.de

Igor Fedorenko wrote:

>
>
> Remme wrote:
>> Thank you for reply. The thing is the following:
>>
>> I am building a plugin, where used classes are not all placed inside the
>> local classpath. Part of classes are coming from an own server. Those
>> classes are buildt by a factory, thus, additionally, i don't know them
>> complete, only the interfaces / abstracts from a framework.
>> For this i need to add an own classloader, which is able to find the
>> needed classes.
>> So far no problem, but since the local classes are loaded by the standard
>> plugin classloader, which does not know about the network classloader, i
>> am running into a ClassNotFoundException as soon as i am trying to load a
>> class, which was loaded by the plugin classloader and which is using
>> another class, which is stored on the server.
> How do you get instances of the server provided classes? Do you use JNDI
> lookup or you have your own factory that knows classnames to be
> instantiated and calls Class.forName? How would your code and JVM's
> classpath look like if it did not run inside Eclipse?
>
> For JNDI to work you need to set your network classloader as thread
> context classloader before calling context.lookup.
>
> For the factory to work, you need to make sure that it uses your network
> classloader to load classes by name. This may be little bit clumsy, but
> should work.
>

I am using a complete own format, where the server is deciding, which class
implementation is used and sends this class back if needed.
But the mistake i made was before, i think, because i tried to make a very
clumsy solution, where parent- and new ClassLoader are connecting partially
to the same repositories.
I have to restyle the plugin now first, so that i can make a solution, where
the plugin itself is working with interfaces only and something like a
bridge as own jar is loaded by the other classloader.

If i am finished with that and still desparating, then i would like to come
back again :-)

Thank you very much,

Michael

>> At that time i am starting to build a forced loader, which is using
>> resources from local files and is using defineClass to build the class
>> and will see, how this will run.
>> But the simply best solution would be if i could load the plugin class
>> already under my own classloader.
>>
>> Michael
>>
>>
>> Igor Fedorenko wrote:
>>
>>
>>>No, there is no such extension point. What exactly do you need this
>>>classloader for? I might give you some ideas, but I need to understand
>>>your problem better.
>>
>>
>>>Remme wrote:
>>>
>>>>Hi all,
>>>>
>>>>i am creating a plugin where i need to use an own classloader. Is it
>>>>possible to define the classloader to be used inside the plugin.xml as
>>>>extension point for the complete Plugin?
>>>>
>>>>tia, Michael
>>>>
>>
>>
>>
Re: Using own classloader for plugin [message #213907 is a reply to message #207951] Sat, 20 March 2004 02:39 Go to previous message
Eclipse UserFriend
When I need to load classes that I don't have installed with the plugin
I simply
instantiate a URLClassLoader - and it works perfectly.

Genady

Remme wrote:

>Thank you for reply. The thing is the following:
>
>I am building a plugin, where used classes are not all placed inside the
>local classpath. Part of classes are coming from an own server. Those
>classes are buildt by a factory, thus, additionally, i don't know them
>complete, only the interfaces / abstracts from a framework.
>For this i need to add an own classloader, which is able to find the
>needed classes.
>So far no problem, but since the local classes are loaded by the standard
>plugin classloader, which does not know about the network classloader, i
>am running into a ClassNotFoundException as soon as i am trying to load a
>class, which was loaded by the plugin classloader and which is using
>another class, which is stored on the server.
>At that time i am starting to build a forced loader, which is using
>resources from local files and is using defineClass to build the class and
>will see, how this will run.
>But the simply best solution would be if i could load the plugin class
>already under my own classloader.
>
>Michael
>
>
>Igor Fedorenko wrote:
>
>
>
>>No, there is no such extension point. What exactly do you need this
>>classloader for? I might give you some ideas, but I need to understand
>>your problem better.
>>
>>
>
>
>
>>Remme wrote:
>>
>>
>>>Hi all,
>>>
>>>i am creating a plugin where i need to use an own classloader. Is it
>>>possible to define the classloader to be used inside the plugin.xml as
>>>extension point for the complete Plugin?
>>>
>>>tia, Michael
>>>
>>>
>>>
>
>
>
>

--
Genady Beryozkin
http://www.genady.net/
Previous Topic:jad decompiler
Next Topic:When creating an image with ImageDescriptor.createImage()...
Goto Forum:
  


Current Time: Wed Nov 05 20:14:42 EST 2025

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

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

Back to the top