You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Sergio Mestre (JIRA)" <ji...@apache.org> on 2009/06/02 18:38:07 UTC

[jira] Created: (FELIX-1197) Bundle Fragments not resolved correctly

Bundle Fragments not resolved correctly
---------------------------------------

                 Key: FELIX-1197
                 URL: https://issues.apache.org/jira/browse/FELIX-1197
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: felix-1.8.0
            Reporter: Sergio Mestre


Hi all,

I have the following behaviour, if I try to attach more than one bundle fragment to the same bundle host.

java.lang.ClassCastException: org.apache.felix.framework.searchpolicy.ModuleImpl cannot be cast to [Ljava.lang.Object;
        at org.apache.felix.framework.FelixResolverState.checkForConflicts(FelixResolverState.java:220)
ERROR: Error starting file:bundle/org.apache.felix.shell.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 31: Unable to merge fragments)
        at org.apache.felix.framework.FelixResolverState.mergeFragments(FelixResolverState.java:139)
        at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:3708)
        at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3091)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1439)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
        at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
        at java.lang.Thread.run(Thread.java:619)

The bundle fragments have been tested separately and they work as they should. 
( e.g. Frag A => Host A => O.K.
          Frag B => Host A => O.K.
)

If I try to resolve both bundle fragments than i get the exception above. I took a look at the source and it seems to me that there is a bug in the FelixResolverState class. Inside the method checkForConflicts(IModule host, List fragmentList) there is a map definition Map ipMerged = new HashMap(); where the key is a String and the Value a Object[] . 
Later on in a for loop the same map is used to store keys from type String and values from type ModuleImpl. This causes a the above classcast exception in the line 220. 

Do I have any mistakes in my bundle fragment headers or is this realy a bug ?

Best regards
Sergio


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-1197) Bundle Fragments not resolved correctly

Posted by "Sergio Mestre (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715850#action_12715850 ] 

Sergio Mestre commented on FELIX-1197:
--------------------------------------

Yes that's right. I have two fragments importing nearly the same packages but exporting different packages. Both fragments should attach the same host.

> Bundle Fragments not resolved correctly
> ---------------------------------------
>
>                 Key: FELIX-1197
>                 URL: https://issues.apache.org/jira/browse/FELIX-1197
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.8.0
>            Reporter: Sergio Mestre
>            Assignee: Richard S. Hall
>
> Hi all,
> I have the following behaviour, if I try to attach more than one bundle fragment to the same bundle host.
> java.lang.ClassCastException: org.apache.felix.framework.searchpolicy.ModuleImpl cannot be cast to [Ljava.lang.Object;
>         at org.apache.felix.framework.FelixResolverState.checkForConflicts(FelixResolverState.java:220)
> ERROR: Error starting file:bundle/org.apache.felix.shell.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 31: Unable to merge fragments)
>         at org.apache.felix.framework.FelixResolverState.mergeFragments(FelixResolverState.java:139)
>         at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:3708)
>         at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3091)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:1439)
>         at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
>         at java.lang.Thread.run(Thread.java:619)
> The bundle fragments have been tested separately and they work as they should. 
> ( e.g. Frag A => Host A => O.K.
>           Frag B => Host A => O.K.
> )
> If I try to resolve both bundle fragments than i get the exception above. I took a look at the source and it seems to me that there is a bug in the FelixResolverState class. Inside the method checkForConflicts(IModule host, List fragmentList) there is a map definition Map ipMerged = new HashMap(); where the key is a String and the Value a Object[] . 
> Later on in a for loop the same map is used to store keys from type String and values from type ModuleImpl. This causes a the above classcast exception in the line 220. 
> Do I have any mistakes in my bundle fragment headers or is this realy a bug ?
> Best regards
> Sergio

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-1197) Bundle Fragments not resolved correctly

Posted by "Sergio Mestre (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12716180#action_12716180 ] 

Sergio Mestre commented on FELIX-1197:
--------------------------------------

Thanks for this advise.

> Bundle Fragments not resolved correctly
> ---------------------------------------
>
>                 Key: FELIX-1197
>                 URL: https://issues.apache.org/jira/browse/FELIX-1197
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.8.0
>            Reporter: Sergio Mestre
>            Assignee: Richard S. Hall
>
> Hi all,
> I have the following behaviour, if I try to attach more than one bundle fragment to the same bundle host.
> java.lang.ClassCastException: org.apache.felix.framework.searchpolicy.ModuleImpl cannot be cast to [Ljava.lang.Object;
>         at org.apache.felix.framework.FelixResolverState.checkForConflicts(FelixResolverState.java:220)
> ERROR: Error starting file:bundle/org.apache.felix.shell.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 31: Unable to merge fragments)
>         at org.apache.felix.framework.FelixResolverState.mergeFragments(FelixResolverState.java:139)
>         at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:3708)
>         at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3091)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:1439)
>         at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
>         at java.lang.Thread.run(Thread.java:619)
> The bundle fragments have been tested separately and they work as they should. 
> ( e.g. Frag A => Host A => O.K.
>           Frag B => Host A => O.K.
> )
> If I try to resolve both bundle fragments than i get the exception above. I took a look at the source and it seems to me that there is a bug in the FelixResolverState class. Inside the method checkForConflicts(IModule host, List fragmentList) there is a map definition Map ipMerged = new HashMap(); where the key is a String and the Value a Object[] . 
> Later on in a for loop the same map is used to store keys from type String and values from type ModuleImpl. This causes a the above classcast exception in the line 220. 
> Do I have any mistakes in my bundle fragment headers or is this realy a bug ?
> Best regards
> Sergio

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (FELIX-1197) Bundle Fragments not resolved correctly

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard S. Hall reassigned FELIX-1197:
--------------------------------------

    Assignee: Richard S. Hall

> Bundle Fragments not resolved correctly
> ---------------------------------------
>
>                 Key: FELIX-1197
>                 URL: https://issues.apache.org/jira/browse/FELIX-1197
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.8.0
>            Reporter: Sergio Mestre
>            Assignee: Richard S. Hall
>
> Hi all,
> I have the following behaviour, if I try to attach more than one bundle fragment to the same bundle host.
> java.lang.ClassCastException: org.apache.felix.framework.searchpolicy.ModuleImpl cannot be cast to [Ljava.lang.Object;
>         at org.apache.felix.framework.FelixResolverState.checkForConflicts(FelixResolverState.java:220)
> ERROR: Error starting file:bundle/org.apache.felix.shell.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 31: Unable to merge fragments)
>         at org.apache.felix.framework.FelixResolverState.mergeFragments(FelixResolverState.java:139)
>         at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:3708)
>         at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3091)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:1439)
>         at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
>         at java.lang.Thread.run(Thread.java:619)
> The bundle fragments have been tested separately and they work as they should. 
> ( e.g. Frag A => Host A => O.K.
>           Frag B => Host A => O.K.
> )
> If I try to resolve both bundle fragments than i get the exception above. I took a look at the source and it seems to me that there is a bug in the FelixResolverState class. Inside the method checkForConflicts(IModule host, List fragmentList) there is a map definition Map ipMerged = new HashMap(); where the key is a String and the Value a Object[] . 
> Later on in a for loop the same map is used to store keys from type String and values from type ModuleImpl. This causes a the above classcast exception in the line 220. 
> Do I have any mistakes in my bundle fragment headers or is this realy a bug ?
> Best regards
> Sergio

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: Package import merging [was: Re: [jira] Commented: (FELIX-1197) Bundle Fragments not resolved correctly]

Posted by Glyn Normington <gl...@apache.org>.
Hi Richard

On 4 Jun 2009, at 00:13, Richard S. Hall wrote:

> The issue is, I need to determine whether or not a given fragment  
> conflicts with the existing host or other fragments or else I cannot  
> attach it. Currently, the approach I take is quite simplistic, which  
> is just requiring any overlapping Import-Package or Require-Bundle  
> to be identical (i.e., I allow that, anything else I reject  
> attaching the fragment).
>
> If/when necessary, I contemplate getting around this by just trying  
> to satisfy all dependencies and just look for interesting candidates  
> on overlapping ones, but it doesn't seem necessary now.

That's equivalent to my approach when dependencies can be satisfied,  
but when the combination of dependencies is simply unsatisfiable  
because of conflicts, I wanted to provide specific feedback about the  
clash and where the clash arose from rather than generic feedback  
about the failure to resolve dependencies. Anyway, I simply wanted to  
bring up this approach and the available code.

Regards,
Glyn


Re: Package import merging [was: Re: [jira] Commented: (FELIX-1197) Bundle Fragments not resolved correctly]

Posted by "Richard S. Hall" <he...@ungoverned.org>.
The issue is, I need to determine whether or not a given fragment 
conflicts with the existing host or other fragments or else I cannot 
attach it. Currently, the approach I take is quite simplistic, which is 
just requiring any overlapping Import-Package or Require-Bundle to be 
identical (i.e., I allow that, anything else I reject attaching the 
fragment).

If/when necessary, I contemplate getting around this by just trying to 
satisfy all dependencies and just look for interesting candidates on 
overlapping ones, but it doesn't seem necessary now.

-> richard

On 6/3/09 8:56 AM, Glyn Normington wrote:
> I don't know how imported the conflict detection mentioned below is, 
> but I wrote a bunch of code to merge groups of package imports from 
> various sources and throw helpful exceptions identifying any conflict 
> together with the original sources of the conflict. Merging computes 
> the intersection of version ranges and squares up other attributes and 
> directives. Currently, this is in the GPL portion of dm Server, but if 
> it would help, I could look into migrating it down into the Apache 
> licensed util area for Felix to reuse or fork.
>
> If and only if you are comfortable looking at GPL source code, see [1] 
> and the other classes in the same directory. If you're not 
> comfortable, I'm happy to answer any questions here.
>
> Glyn
>
> [1] 
> https://src.springsource.org/svn/dm-server-kernel/main-branches/jersey/com.springsource.kernel.osgi/src/main/java/com/springsource/kernel/osgi/framework/support/merge/TrackedPackageImports.java 
>
>
> On 3 Jun 2009, at 16:16, Richard S. Hall (JIRA) wrote:
>
>>
>>    [ 
>> https://issues.apache.org/jira/browse/FELIX-1197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715947#action_12715947 
>> ]
>>
>> Richard S. Hall commented on FELIX-1197:
>> ----------------------------------------
>>
>> You mention that your fragments import nearly the same packages, Be 
>> aware that Felix fragment import conflict detection currently 
>> requires overlapping imports of fragments to be identical (i.e., same 
>> package, version range, attributes, and directives). If not, then it 
>> will not allow it.

Package import merging [was: Re: [jira] Commented: (FELIX-1197) Bundle Fragments not resolved correctly]

Posted by Glyn Normington <gl...@springsource.com>.
I don't know how imported the conflict detection mentioned below is,  
but I wrote a bunch of code to merge groups of package imports from  
various sources and throw helpful exceptions identifying any conflict  
together with the original sources of the conflict. Merging computes  
the intersection of version ranges and squares up other attributes and  
directives. Currently, this is in the GPL portion of dm Server, but if  
it would help, I could look into migrating it down into the Apache  
licensed util area for Felix to reuse or fork.

If and only if you are comfortable looking at GPL source code, see [1]  
and the other classes in the same directory. If you're not  
comfortable, I'm happy to answer any questions here.

Glyn

[1] https://src.springsource.org/svn/dm-server-kernel/main-branches/jersey/com.springsource.kernel.osgi/src/main/java/com/springsource/kernel/osgi/framework/support/merge/TrackedPackageImports.java

On 3 Jun 2009, at 16:16, Richard S. Hall (JIRA) wrote:

>
>    [ https://issues.apache.org/jira/browse/FELIX-1197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715947 
> #action_12715947 ]
>
> Richard S. Hall commented on FELIX-1197:
> ----------------------------------------
>
> You mention that your fragments import nearly the same packages, Be  
> aware that Felix fragment import conflict detection currently  
> requires overlapping imports of fragments to be identical (i.e.,  
> same package, version range, attributes, and directives). If not,  
> then it will not allow it.

[jira] Commented: (FELIX-1197) Bundle Fragments not resolved correctly

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715947#action_12715947 ] 

Richard S. Hall commented on FELIX-1197:
----------------------------------------

You mention that your fragments import nearly the same packages, Be aware that Felix fragment import conflict detection currently requires overlapping imports of fragments to be identical (i.e., same package, version range, attributes, and directives). If not, then it will not allow it.

> Bundle Fragments not resolved correctly
> ---------------------------------------
>
>                 Key: FELIX-1197
>                 URL: https://issues.apache.org/jira/browse/FELIX-1197
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.8.0
>            Reporter: Sergio Mestre
>            Assignee: Richard S. Hall
>
> Hi all,
> I have the following behaviour, if I try to attach more than one bundle fragment to the same bundle host.
> java.lang.ClassCastException: org.apache.felix.framework.searchpolicy.ModuleImpl cannot be cast to [Ljava.lang.Object;
>         at org.apache.felix.framework.FelixResolverState.checkForConflicts(FelixResolverState.java:220)
> ERROR: Error starting file:bundle/org.apache.felix.shell.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 31: Unable to merge fragments)
>         at org.apache.felix.framework.FelixResolverState.mergeFragments(FelixResolverState.java:139)
>         at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:3708)
>         at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3091)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:1439)
>         at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
>         at java.lang.Thread.run(Thread.java:619)
> The bundle fragments have been tested separately and they work as they should. 
> ( e.g. Frag A => Host A => O.K.
>           Frag B => Host A => O.K.
> )
> If I try to resolve both bundle fragments than i get the exception above. I took a look at the source and it seems to me that there is a bug in the FelixResolverState class. Inside the method checkForConflicts(IModule host, List fragmentList) there is a map definition Map ipMerged = new HashMap(); where the key is a String and the Value a Object[] . 
> Later on in a for loop the same map is used to store keys from type String and values from type ModuleImpl. This causes a the above classcast exception in the line 220. 
> Do I have any mistakes in my bundle fragment headers or is this realy a bug ?
> Best regards
> Sergio

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (FELIX-1197) Bundle Fragments not resolved correctly

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard S. Hall resolved FELIX-1197.
------------------------------------

       Resolution: Fixed
    Fix Version/s: felix-2.0.0

Yes, this was just a bug in the use of a map with incorrect types for values. I guess generics would have helped in this case. :-)

It is fixed now. If you can test against the trunk, please do and then close this issue if satisfied. Thanks.

> Bundle Fragments not resolved correctly
> ---------------------------------------
>
>                 Key: FELIX-1197
>                 URL: https://issues.apache.org/jira/browse/FELIX-1197
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.8.0
>            Reporter: Sergio Mestre
>            Assignee: Richard S. Hall
>             Fix For: felix-2.0.0
>
>
> Hi all,
> I have the following behaviour, if I try to attach more than one bundle fragment to the same bundle host.
> java.lang.ClassCastException: org.apache.felix.framework.searchpolicy.ModuleImpl cannot be cast to [Ljava.lang.Object;
>         at org.apache.felix.framework.FelixResolverState.checkForConflicts(FelixResolverState.java:220)
> ERROR: Error starting file:bundle/org.apache.felix.shell.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 31: Unable to merge fragments)
>         at org.apache.felix.framework.FelixResolverState.mergeFragments(FelixResolverState.java:139)
>         at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:3708)
>         at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3091)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:1439)
>         at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
>         at java.lang.Thread.run(Thread.java:619)
> The bundle fragments have been tested separately and they work as they should. 
> ( e.g. Frag A => Host A => O.K.
>           Frag B => Host A => O.K.
> )
> If I try to resolve both bundle fragments than i get the exception above. I took a look at the source and it seems to me that there is a bug in the FelixResolverState class. Inside the method checkForConflicts(IModule host, List fragmentList) there is a map definition Map ipMerged = new HashMap(); where the key is a String and the Value a Object[] . 
> Later on in a for loop the same map is used to store keys from type String and values from type ModuleImpl. This causes a the above classcast exception in the line 220. 
> Do I have any mistakes in my bundle fragment headers or is this realy a bug ?
> Best regards
> Sergio

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-1197) Bundle Fragments not resolved correctly

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715615#action_12715615 ] 

Richard S. Hall commented on FELIX-1197:
----------------------------------------

Sounds like a bug. To make sure I understand the scenario, you just have two fragments wanting to attach to the same host, that's it. Right? If so, I will create such a test case and fix it. Thanks for reporting it.

> Bundle Fragments not resolved correctly
> ---------------------------------------
>
>                 Key: FELIX-1197
>                 URL: https://issues.apache.org/jira/browse/FELIX-1197
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.8.0
>            Reporter: Sergio Mestre
>
> Hi all,
> I have the following behaviour, if I try to attach more than one bundle fragment to the same bundle host.
> java.lang.ClassCastException: org.apache.felix.framework.searchpolicy.ModuleImpl cannot be cast to [Ljava.lang.Object;
>         at org.apache.felix.framework.FelixResolverState.checkForConflicts(FelixResolverState.java:220)
> ERROR: Error starting file:bundle/org.apache.felix.shell.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 31: Unable to merge fragments)
>         at org.apache.felix.framework.FelixResolverState.mergeFragments(FelixResolverState.java:139)
>         at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:3708)
>         at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3091)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:1439)
>         at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
>         at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
>         at java.lang.Thread.run(Thread.java:619)
> The bundle fragments have been tested separately and they work as they should. 
> ( e.g. Frag A => Host A => O.K.
>           Frag B => Host A => O.K.
> )
> If I try to resolve both bundle fragments than i get the exception above. I took a look at the source and it seems to me that there is a bug in the FelixResolverState class. Inside the method checkForConflicts(IModule host, List fragmentList) there is a map definition Map ipMerged = new HashMap(); where the key is a String and the Value a Object[] . 
> Later on in a for loop the same map is used to store keys from type String and values from type ModuleImpl. This causes a the above classcast exception in the line 220. 
> Do I have any mistakes in my bundle fragment headers or is this realy a bug ?
> Best regards
> Sergio

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.