You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Marek Budyn <ma...@gmail.com> on 2015/05/20 16:40:19 UTC

Bug in bundlerepository-2.0.4 ?

Hi all,

I have a question or I need a clarification on bundlerepository bundle as I
have noticed strange behavior after upgrading bundlerepository from version
2.0.2 to 2.0.4.
In general I use RepositoryAdmin service to dynamically register bundles
according to current application profile.
The approach is pretty simple: I find RepositoryAdmin service, from which I
get Resolver through resolver() method,
and later call deploy(Resolver.START) method to start bundles.

Unfortunately after upgrading from version 2.0.2 to 2.0.4 I get the
following exception:

ERROR: Bundle n3g.osgi.launcher [1] EventDispatcher: Error during dispatch.
(java.lang.ClassCastException:
org.apache.felix.bundlerepository.impl.LazyLocalResourceImpl cannot be cast
to org.apache.felix.bundlerepository.impl.LocalResourceImpl)
java.lang.ClassCastException:
org.apache.felix.bundlerepository.impl.LazyLocalResourceImpl cannot be cast
to org.apache.felix.bundlerepository.impl.LocalResourceImpl
at
org.apache.felix.bundlerepository.impl.ResolverImpl.findUpdatableLocalResource(ResolverImpl.java:703)
at
org.apache.felix.bundlerepository.impl.ResolverImpl.deploy(ResolverImpl.java:569)

So is it a bug or something substantial has changes between the versions?

Kind regards,

Marek

Re: Bug in bundlerepository-2.0.4 ?

Posted by "swapnesh.patel" <sa...@yahoo.com>.
I am trying to run deploy -s "BundleName" command and i am seeing same error.

As per the document it says that if bundle is already installed then it
tries to update else install. But i see same exception whenever it tries to
go to "update" bundle.

I tried to debug into it. Following function "findUpdatableLocalResource" in
ResolverImpl class tries to cast localResources[i] into LocalResourceImpl
and that's when it is not able to cast instance of LazyLocalResourceImpl
object into  LocalResourceImpl object. LazyLocalResourceImpl is derived from
Resource class and not the LocalResourceImpl class.

I tried to see why my bundle was installed as LazyLocalResourceImpl and i
found that "addBundle" method of LocalRepositoryImpl class by default adds
bundle as LazyLocalResourceImpl instead of LocalResourceImpl.

I believe there is a bug somewhere in below function that does not handle
different between LocalResourceImpl and LazyLocalResourceImpl.


 // TODO: OBR - Think about this again and make sure that deployment
ordering
    // won't impact it...we need to update the local state too.
    private LocalResourceImpl findUpdatableLocalResource(Resource resource)
    {
        // Determine if any other versions of the specified resource
        // already installed.
        Resource[] localResources =
findLocalResources(resource.getSymbolicName());
        if (localResources != null)
        {
            // Since there are local resources with the same symbolic
            // name installed, then we must determine if we can
            // update an existing resource or if we must install
            // another one. Loop through all local resources with same
            // symbolic name and find the first one that can be updated
            // without breaking constraints of existing local resources.
            for (int i = 0; i < localResources.length; i++)
            {
                if (isResourceUpdatable(localResources[i], resource,
localResources))
                {
                    return (LocalResourceImpl) localResources[i];
                }
            }
        }
        return null;
    }



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Bug-in-bundlerepository-2-0-4-tp5012912p5013088.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org