nebulae | 2 Jun 05:36
Picon

help understanding osgi.parentClassLoader

Hi,

I'm new to OSGI so please bear with me if they are basically naive questions.
I'm using Equinox's latest version, I've gone through the mailing
lists and OSGI's core manual especailly the Module layer section and
found lots of very important information.

Under Eclipse's runtime options there is

osgi.parentClassLoader
    the classloader type to use as the parent classloader for all
bundles installed in the Framework. The valid types are the following:

        * app - the application classloader.
        * boot - the boot classloader.
        * ext - the extension classloader.
        * fwk - the framework classloader.

So my questions are -

How do you decide which type to use as your parent class loader (pcl) ?

Basically these 4 types of classloaders load classes from different
classpaths (boot and system), right?

What does it mean to be an extension classloader? In the spec it says
the extension bundles are fragments (framework or bootclasspath) but
fragments don't have their classloaders.

System.bundle is the framework bundle which exports packages through
(Continue reading)

Jan Stette | 2 Jun 14:58
Picon

Question regarding class loader and getPackages()

I'm trying to call Package.getPackages() in some code in an OSGi bundle.  This calls into getPackages on the classloader, where I'm observing that:

1.  The call is not overridden in the Equinox classloader, so the default implementation in java.lang.ClassLoader is used.  Hence, only the bundle's own packages, and the system packages are returned.
2.  Only packages from which at least one class has been loaded are returned.  So, if a class hasn't been loaded from a given package, it won't be included in the returned list.

I haven't found anything in the OSGi or Java language specs that specify this, but I expected all packages that the bundle classloader can see to be returned, something aking to the java doc description of Package.getPackages(): "Get all the packages currently known for the caller's ClassLoader instance. Those packages correspond to classes loaded via or accessible by name to that ClassLoader instance".  Which seems to suggest that both packages of classes that haven't been loaded yet, and packages imported by the bundle class loader should be listed.

I realise that the Package Admin service is an alternative for this, but I'm surprised if these details can't be accessed through the class loader...

Could anyone shed some light on this, please?

Regards,
Jan

Thomas Watson | 2 Jun 16:12
Picon
Favicon

Re: help understanding osgi.parentClassLoader

equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org wrote on 06/01/2008 10:36:04 PM:
>
> Hi,
>
> I'm new to OSGI so please bear with me if they are basically naive questions.
> I'm using Equinox's latest version, I've gone through the mailing
> lists and OSGI's core manual especailly the Module layer section and
> found lots of very important information.
>
> Under Eclipse's runtime options there is
>
> osgi.parentClassLoader
>     the classloader type to use as the parent classloader for all
> bundles installed in the Framework. The valid types are the following:
>
>         * app - the application classloader.
>         * boot - the boot classloader.
>         * ext - the extension classloader.
>         * fwk - the framework classloader.
>
>
> So my questions are -
>
> How do you decide which type to use as your parent class loader (pcl) ?
>
> Basically these 4 types of classloaders load classes from different
> classpaths (boot and system), right?
>
> What does it mean to be an extension classloader? In the spec it says
> the extension bundles are fragments (framework or bootclasspath) but
> fragments don't have their classloaders.

Here extension class loader refers to the VM's extension class loader
which loads classes from the ext/ directory of the VM.

>
> System.bundle is the framework bundle which exports packages through
> pcl  using org.osgi.framework.system.packages then why there is
> specific fwk type?

The fwk type specifies the actual class loader which loads the
Equinox framework.  I would avoid this setting if possible, it only
kind of makes sense when embedding the Framework in your own
Java application and you need to expose the class loader used to
load the framework.

>
> If all the classes starting with java and the one's specified by
> org.osgi.framework.bootdelegation are to be loaded by pcl then what is
> boot type?

The boot type specifies the "boot" classloader of the VM.  This is
the default used by Eclipse.  This class loader is used to load the
class built into the VM (java.* and others packages, javax.xml etc.).

>
> what does app mean, which classloader is this referring to?

This is the application class loader setup by the VM to launch an
application.  The VM sets up the classloaders with the following
hierarchy

app->ext->boot

In eclipse the app class loader is used to load the boot strap
launcher (org.eclipse.equinox.launder jar).  This code creates
another classloader for the framework to launch (fwk)

>
> I was having some classloading issues with xerces parser and when I
> switched to app it suddenly worked, I really want to understand what
> happened.
>

More than likely the xerces stuff you were trying to load came from
the VM's extension classloader then.  With that said, all of this is
not really recommended in OSGi.  The parent class loader should
really only be used for java.* packages.  This allows for much more
control over what packages you get and what versions.  Depending on
the packages from the app, ext or boot class loader in the VM without
specifying constraints (Import-Package/Require-Bundle) is not a good
practice because your bundle may resolve in an environment where the
package is not available from the VM.

> Clarifications of the above questions will be very much appreciated.
>
> Thanks much.
>
> Shravan
>

Tom.

BJ Hargrave | 2 Jun 16:27
Picon
Favicon

Re: Question regarding class loader and getPackages()


equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org wrote on 2008/06/02 08:58:36 AM:

> [image removed]
>
> [equinox-dev] Question regarding class loader and getPackages()
>
> Jan Stette
>
> to:
>
> Equinox development mailing list
>
> 2008/06/02 08:59 AM
>
> Sent by:
>
> equinox-dev-bounces-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
>
> Please respond to Equinox development mailing list <equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org>
>
> I'm trying to call Package.getPackages() in some code in an OSGi
> bundle.  This calls into getPackages on the classloader, where I'm
> observing that:
>
> 1.  The call is not overridden in the Equinox classloader, so the
> default implementation in java.lang.ClassLoader is used.  Hence,
> only the bundle's own packages, and the system packages are returned.

I don't think imported packages should be listed since they are imported from other bundles.

> 2.  Only packages from which at least one class has been loaded are
> returned.  So, if a class hasn't been loaded from a given package,
> it won't be included in the returned list.
>
> I haven't found anything in the OSGi or Java language specs that
> specify this, but I expected all packages that the bundle
> classloader can see to be returned, something aking to the java doc
> description of Package.getPackages(): "Get all the packages
> currently known for the caller's ClassLoader instance. Those

The packages "currently known" are those for which at least one successful class load has occurred. There is no reliable or specified way for a class loader to "know" all the classes which it can successfully load.

> packages correspond to classes loaded via or accessible by name to that
> ClassLoader instance".  Which seems to suggest that both packages of
> classes that haven't been loaded yet, and packages imported by the
> bundle class loader should be listed.
>
> I realise that the Package Admin service is an alternative for this,
> but I'm surprised if these details can't be accessed through the
> class loader...
>
> Could anyone shed some light on this, please?
>
> Regards,
> Jan
> _______________________________________________
> equinox-dev mailing list
> equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
> https://dev.eclipse.org/mailman/listinfo/equinox-dev

--

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
hargrave-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org

office: +1 386 848 1781
mobile: +1 386 848 3788



Jan Stette | 2 Jun 19:38
Picon

Re: Question regarding class loader and getPackages()

2008/6/2 BJ Hargrave <hargrave-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>:


> 1.  The call is not overridden in the Equinox classloader, so the
> default implementation in java.lang.ClassLoader is used.  Hence,
> only the bundle's own packages, and the system packages are returned.

I don't think imported packages should be listed since they are imported from other bundles.

Does it matter which bundles the packages come from?  From the client of the classloader, I would have thought this should be transparent, i.e. that it returns all packages that are visible through this classloader.  From the javadoc for java.lang.ClassLoader.getPackages():  "Returns all of the Packages defined by this class loader and its ancestors".  In an OSGi environment, wouldn't it be natural to include classloaders from bundles depended on as well?

Anyway, is this a question better suited for osgi-dev instead of this list?

Regards,
Jan

Thomas Watson | 2 Jun 19:59
Picon
Favicon

Re: Question regarding class loader and getPackages()

Yes, please ask this on the osgi-dev mailing list or open an OSGi specification bug at https://www.osgi.org/bugzilla/enter_bug.cgi.

I would not expect you to get Package objects for any packages for which a class is not defined. In most cases I don't think the VM class loaders do that (boot, extension, application etc.).

Tom



"Jan Stette" ---06/02/2008 12:41:34 PM---2008/6/2 BJ Hargrave <hargrave <at> us.ibm.com>: >


From:

"Jan Stette" <jan.stette-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

To:

"Equinox development mailing list" <equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org>

Date:

06/02/2008 12:41 PM

Subject:

Re: [equinox-dev] Question regarding class loader and getPackages()



2008/6/2 BJ Hargrave <hargrave-Tt1OGPs9TXc@public.gmane.orgcom>:


    > 1.  The call is not overridden in the Equinox classloader, so the
    > default implementation in java.lang.ClassLoader is used.  Hence,
    > only the bundle's own packages, and the system packages are returned.

    I don't think imported packages should be listed since they are imported from other bundles.

Does it matter which bundles the packages come from? From the client of the classloader, I would have thought this should be transparent, i.e. that it returns all packages that are visible through this classloader. From the javadoc for java.lang.ClassLoader.getPackages(): "Returns all of the Packages defined by this class loader and its ancestors". In an OSGi environment, wouldn't it be natural to include classloaders from bundles depended on as well?

Anyway, is this a question better suited for osgi-dev instead of this list?

Regards,
Jan
_______________________________________________
equinox-dev mailing list
equinox-dev-j9T/66MeVpFAfugRpC6u6w@public.gmane.org
https://dev.eclipse.org/mailman/listinfo/equinox-dev


nebulae | 2 Jun 20:38
Picon

Re: help understanding osgi.parentClassLoader

Thanks a lot Tom, you're right xerces.jar was indeed in the ext dir
and that's why osgi.parentClassloader=app worked and so would ext.

I was able to fix this problem by supplying DynamicImport-Package: *
in one of my bundles. Here are the details:

I have a declarative service let's say in a bundle - Ads.
Now Ads calls a leagcy code which has been wrapped as a bundle and
loaded in the OSGI environ - Lega

Ads is calling Lega's APIs.

Now Lega is calling Jdom which  in turn calls
org.sax.helpers.XMLReaderFactory.loadClass which is in rt.jar.

Now I'm assuming rt.jar is using class.forName() to load a Sax driver
from xerces.jar.

What I did was put DynamicImport-Package in Ads's manifest and it
appears to work fine.

Can you please explain the flow here in your view that made it work.

Thanks a lot.

Shravan

On Mon, Jun 2, 2008 at 10:12 AM, Thomas Watson <tjwatson@...> wrote:
> equinox-dev-bounces@... wrote on 06/01/2008 10:36:04 PM:
>>
>> Hi,
>>
>> I'm new to OSGI so please bear with me if they are basically naive
>> questions.
>> I'm using Equinox's latest version, I've gone through the mailing
>> lists and OSGI's core manual especailly the Module layer section and
>> found lots of very important information.
>>
>> Under Eclipse's runtime options there is
>>
>> osgi.parentClassLoader
>>     the classloader type to use as the parent classloader for all
>> bundles installed in the Framework. The valid types are the following:
>>
>>         * app - the application classloader.
>>         * boot - the boot classloader.
>>         * ext - the extension classloader.
>>         * fwk - the framework classloader.
>>
>>
>> So my questions are -
>>
>> How do you decide which type to use as your parent class loader (pcl) ?
>>
>> Basically these 4 types of classloaders load classes from different
>> classpaths (boot and system), right?
>>
>> What does it mean to be an extension classloader? In the spec it says
>> the extension bundles are fragments (framework or bootclasspath) but
>> fragments don't have their classloaders.
>
> Here extension class loader refers to the VM's extension class loader
> which loads classes from the ext/ directory of the VM.
>
>>
>> System.bundle is the framework bundle which exports packages through
>> pcl  using org.osgi.framework.system.packages then why there is
>> specific fwk type?
>
> The fwk type specifies the actual class loader which loads the
> Equinox framework.  I would avoid this setting if possible, it only
> kind of makes sense when embedding the Framework in your own
> Java application and you need to expose the class loader used to
> load the framework.
>
>>
>> If all the classes starting with java and the one's specified by
>> org.osgi.framework.bootdelegation are to be loaded by pcl then what is
>> boot type?
>
> The boot type specifies the "boot" classloader of the VM.  This is
> the default used by Eclipse.  This class loader is used to load the
> class built into the VM (java.* and others packages, javax.xml etc.).
>
>>
>> what does app mean, which classloader is this referring to?
>
> This is the application class loader setup by the VM to launch an
> application.  The VM sets up the classloaders with the following
> hierarchy
>
> app->ext->boot
>
> In eclipse the app class loader is used to load the boot strap
> launcher (org.eclipse.equinox.launder jar).  This code creates
> another classloader for the framework to launch (fwk)
>
>>
>> I was having some classloading issues with xerces parser and when I
>> switched to app it suddenly worked, I really want to understand what
>> happened.
>>
>
> More than likely the xerces stuff you were trying to load came from
> the VM's extension classloader then.  With that said, all of this is
> not really recommended in OSGi.  The parent class loader should
> really only be used for java.* packages.  This allows for much more
> control over what packages you get and what versions.  Depending on
> the packages from the app, ext or boot class loader in the VM without
> specifying constraints (Import-Package/Require-Bundle) is not a good
> practice because your bundle may resolve in an environment where the
> package is not available from the VM.
>
>> Clarifications of the above questions will be very much appreciated.
>>
>> Thanks much.
>>
>> Shravan
>>
>
> Tom.
>
>
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@...
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>
nebulae | 2 Jun 20:48
Picon

Re: help understanding osgi.parentClassLoader

I'm sorry I sent my email a little too fast, I still had the
parentclassloader set as app.

So now my question is how else can it work if I don't supply app has
the loader given the scenario I described in my previous email.

Thanks
Shravan

On Mon, Jun 2, 2008 at 2:38 PM, nebulae <shravan.mishra@...> wrote:
> Thanks a lot Tom, you're right xerces.jar was indeed in the ext dir
> and that's why osgi.parentClassloader=app worked and so would ext.
>
> I was able to fix this problem by supplying DynamicImport-Package: *
> in one of my bundles. Here are the details:
>
>
> I have a declarative service let's say in a bundle - Ads.
> Now Ads calls a leagcy code which has been wrapped as a bundle and
> loaded in the OSGI environ - Lega
>
> Ads is calling Lega's APIs.
>
> Now Lega is calling Jdom which  in turn calls
> org.sax.helpers.XMLReaderFactory.loadClass which is in rt.jar.
>
> Now I'm assuming rt.jar is using class.forName() to load a Sax driver
> from xerces.jar.
>
> What I did was put DynamicImport-Package in Ads's manifest and it
> appears to work fine.
>
>
> Can you please explain the flow here in your view that made it work.
>
> Thanks a lot.
>
> Shravan
>
>
>
>
>
> On Mon, Jun 2, 2008 at 10:12 AM, Thomas Watson <tjwatson@...> wrote:
>> equinox-dev-bounces@... wrote on 06/01/2008 10:36:04 PM:
>>>
>>> Hi,
>>>
>>> I'm new to OSGI so please bear with me if they are basically naive
>>> questions.
>>> I'm using Equinox's latest version, I've gone through the mailing
>>> lists and OSGI's core manual especailly the Module layer section and
>>> found lots of very important information.
>>>
>>> Under Eclipse's runtime options there is
>>>
>>> osgi.parentClassLoader
>>>     the classloader type to use as the parent classloader for all
>>> bundles installed in the Framework. The valid types are the following:
>>>
>>>         * app - the application classloader.
>>>         * boot - the boot classloader.
>>>         * ext - the extension classloader.
>>>         * fwk - the framework classloader.
>>>
>>>
>>> So my questions are -
>>>
>>> How do you decide which type to use as your parent class loader (pcl) ?
>>>
>>> Basically these 4 types of classloaders load classes from different
>>> classpaths (boot and system), right?
>>>
>>> What does it mean to be an extension classloader? In the spec it says
>>> the extension bundles are fragments (framework or bootclasspath) but
>>> fragments don't have their classloaders.
>>
>> Here extension class loader refers to the VM's extension class loader
>> which loads classes from the ext/ directory of the VM.
>>
>>>
>>> System.bundle is the framework bundle which exports packages through
>>> pcl  using org.osgi.framework.system.packages then why there is
>>> specific fwk type?
>>
>> The fwk type specifies the actual class loader which loads the
>> Equinox framework.  I would avoid this setting if possible, it only
>> kind of makes sense when embedding the Framework in your own
>> Java application and you need to expose the class loader used to
>> load the framework.
>>
>>>
>>> If all the classes starting with java and the one's specified by
>>> org.osgi.framework.bootdelegation are to be loaded by pcl then what is
>>> boot type?
>>
>> The boot type specifies the "boot" classloader of the VM.  This is
>> the default used by Eclipse.  This class loader is used to load the
>> class built into the VM (java.* and others packages, javax.xml etc.).
>>
>>>
>>> what does app mean, which classloader is this referring to?
>>
>> This is the application class loader setup by the VM to launch an
>> application.  The VM sets up the classloaders with the following
>> hierarchy
>>
>> app->ext->boot
>>
>> In eclipse the app class loader is used to load the boot strap
>> launcher (org.eclipse.equinox.launder jar).  This code creates
>> another classloader for the framework to launch (fwk)
>>
>>>
>>> I was having some classloading issues with xerces parser and when I
>>> switched to app it suddenly worked, I really want to understand what
>>> happened.
>>>
>>
>> More than likely the xerces stuff you were trying to load came from
>> the VM's extension classloader then.  With that said, all of this is
>> not really recommended in OSGi.  The parent class loader should
>> really only be used for java.* packages.  This allows for much more
>> control over what packages you get and what versions.  Depending on
>> the packages from the app, ext or boot class loader in the VM without
>> specifying constraints (Import-Package/Require-Bundle) is not a good
>> practice because your bundle may resolve in an environment where the
>> package is not available from the VM.
>>
>>> Clarifications of the above questions will be very much appreciated.
>>>
>>> Thanks much.
>>>
>>> Shravan
>>>
>>
>> Tom.
>>
>>
>> _______________________________________________
>> equinox-dev mailing list
>> equinox-dev@...
>> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>>
>>
>
Thomas Watson | 3 Jun 03:05
Picon
Favicon

copyrights only contributions

We found a few copyrights that need updated for the next build. I did not tag in time for today's build. These will get picked up in tomorrow's build.

The map file has been updated.

The following projects have changed:
org.eclipse.equinox.security.ui
org.eclipse.equinox.security.macosx

Tom

Dominik Pich | 3 Jun 08:34

jBPM or other workflow engine

Hi,
jBPM and other BPMs use POJOs to 'back' the workflow -> for decisions  
and actions in the workflow Classes are 'called'

Now, I specify only to call e.g. de.pich.domi.MyClass. A POJO which  
only must be on the class path... this doesn't  work with Classes in a  
OSGI Bundle, does it?

I guess i'd need 'proxy classes' outside the framework which in turn  
call into the service?

Regards,
Dominik

Gmane