[kf-users] Classloading problem while updating a bundle

Jan Stein jan at makewave.com
Tue Aug 9 10:01:15 CEST 2011


 Hi,

 Yes, we plan to fix this problem, but I can't exactly say when. I came
 back from my vacation yesterday and have some more urgent things to do
 right now.

     /Jan

 On Mon, 8 Aug 2011 14:59:36 +0200, Jean-Baptiste Reich wrote:
> Hello again,
>
> Is there any plan to solve the ClassCastException problem or should I
> post a bug in the bug tracker.
>
> The problem is that I get a ClassCastException in a consumer bundle
> when I update a bundle that exports a service through the command
> "framework update "
>
> Thank you
>
> 2011/7/8 Jean-Baptiste Reich
>
>> Ok this version solves the configuration modification problem and
>> the command bundle problem !
>> Thank you a lot
>>
>> 2011/7/8 Jan Stein
>>
>>> Hi again,
>>>
>>> I've checked in the fix for the first problem, it is available
>>> in
>>> last nights build. I'vent tested if it solves the command bundle
>>> problem.
>>>
>>>     BR, Jan
>>>
>>> On Thu, 07 Jul 2011 09:49:50 +0100, Jan Stein wrote:
>>>
>>>> I think this command problem will also be fixed with the new
>>>> version.
>>>>
>>>>     /Jan
>>>>
>>>> On Thu, 7 Jul 2011 10:42:46 +0200, Jean-Baptiste Reich wrote:
>>>>
>>>>> Thanks a lot for your help.
>>>>>
>>>>> I will test your fix as soon as it is available and thank
>>>>> you for
>>>>> your workaround.
>>>>>
>>>>> By the way I discovered another problem but I am not sure.
>>>>> I developed a command for the Knopflerfish console but I
>>>>> discovered
>>>>> that it is activated and deactivated each time I use it with
>>>>> the
>>>>> console. I thought it was because of my SCR configuration,
>>>>> or that it
>>>>> was an optimization of the framework, but I looked at the
>>>>> OSGi
>>>>> compendium specification and it seems that immediate
>>>>> components should
>>>>> not be deactivated unless a dependency is not met. But I am
>>>>> not sure
>>>>> of my interpretation that's why I would like to ask if it is
>>>>> a normal
>>>>> behavior. I understand you will not have the time to look at
>>>>> this
>>>>> problem now (if it is a problem) but it is to inform you.
>>>>>
>>>>> I give you the code I use to test this:
>>>>>
>>>>> --------------------------------------
>>>>> Command bundle
>>>>> --------------------------------------
>>>>> TestCommand.java:
>>>>>
>>>>> package com.sandbox.test.command;
>>>>>
>>>>> import java.io.PrintWriter;
>>>>> import java.io.Reader;
>>>>> import java.security.AccessController;
>>>>> import java.security.PrivilegedAction;
>>>>> import java.util.Dictionary;
>>>>>
>>>>> import org.knopflerfish.service.console.CommandGroupAdapter;
>>>>> import org.knopflerfish.service.console.Session;
>>>>> import org.osgi.framework.BundleContext;
>>>>>
>>>>> public class TestCommand extends CommandGroupAdapter {
>>>>>     private BundleContext bc;
>>>>>
>>>>>     public TestCommand() {
>>>>>         super("test", "test");
>>>>>         System.out.println("Build command");
>>>>>     }
>>>>>
>>>>>     public void activate(BundleContext bc) {
>>>>>         System.out.println("Command starting...");
>>>>>         this.bc = bc;
>>>>>     }
>>>>>
>>>>>     public void deactivate() {
>>>>>         System.out.println("Command stopping...");
>>>>>         this.bc = null;
>>>>>     }
>>>>>
>>>>>     public final static String USAGE_PRINT = "";
>>>>>
>>>>>     public final static String[] HELP_PRINT = new String[]
>>>>> { "Print
>>>>> test" };
>>>>>
>>>>>     public synchronized int cmdPrint(final Dictionary
>>>>> opts, final
>>>>> Reader in, final PrintWriter out, final Session session) {
>>>>>         Integer res = (Integer)
>>>>> AccessController.doPrivileged(new
>>>>> PrivilegedAction() {
>>>>>             public Object run() {
>>>>>                 out.println("test");
>>>>>                 return new Integer(0);
>>>>>             }
>>>>>         });
>>>>>         return res.intValue();
>>>>>     }
>>>>> }
>>>>>
>>>>> activator.xml
>>>>>
>>>>>  
>>>>>  
>>>>>    
>>>>>  
>>>>>  
>>>>>
>>>>> Knopflerfish console:
>>>>> ./kf2
>>>>>
>>>>> Knopflerfish OSGi framework, version 5.1.6
>>>>> Copyright 2003-2010 Knopflerfish. All Rights Reserved.
>>>>>
>>>>> See http://www.knopflerfish.org [5] [7] for more
>>>>> information.
>>>>> Build command
>>>>> Command starting...
>>>>>
>>>>>> Framework launched
>>>>>
>>>>>> help
>>>>> Command stopping...
>>>>> Available command groups (type 'enter' to enter a group):
>>>>> test - test
>>>>> session - Session commands built into the console
>>>>> logconfig - Configuration commands for the log.
>>>>> log - Log commands
>>>>> framework - Framework commands
>>>>> configuration - Configuration commands
>>>>>
>>>>>> .
>>>>> e="margin:0 0 0 .8ex;border-left:1px #ccc
>>>>> solid;padding-left:1ex">
>>>>>
>>>>> 2011/7/7 Jan Stein
>>>>>
>>>>> > starting...");
>>>>>>>             service = (TestService)
>>>>>>> componentContext.locateService("TestService");
>>>>>>>         } catch (RuntimeException e) {
>>>>>>>             e.printStackTrace();
>>>>>>>         }
>>>>>>>     }
>>>>>>>
>>>>>>>     public void deactivate() {
>>>>>>>         System.out.println("Consumer stopping...");
>>>>>>>         service = null;
>>>>>>>     }
>>>>>>> }
>>>>>>>
>>>>>>> activator.xml:
>>>>>>>
>>>>>>>  
>>>>>>>  
>>>>>>>
>>>>>>> --------------------------------------
>>>>>>> Service bundle
>>>>>>> --------------------------------------
>>>>>>> TestService.java:
>>>>>>>
>>>>>>> package com.sandbox.test.service;
>>>>>>>
>>>>>>> public interface TestService {
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>> TestActivator.java:
>>>>>>>
>>>>>>> package com.sandbox.test.service;
>>>>>>>
>>>>>>> import java.util.Map;
>>>>>>>
>>>>>>> import org.osgi.service.component.ComponentContext;
>>>>>>>
>>>>>>> public class TestActivator implements TestService {
>>>>>>>
>>>>>>>     public TestActivator() {
>>>>>>>         System.out.println("Build service");
>>>>>>>     }
>>>>>>>
>>>>>>>     public void activate(ComponentContext
>>>>>>> componentContext, Map
>>>>>>> config) throws Exception {
>>>>>>>         System.out.println("Service starting...");
>>>>>>>     }
>>>>>>>
>>>>>>>     public void deactivate() {
>>>>>>>         System.out.println("Service stopping...");
>>>>>>>     }
>>>>>>> }
>>>>>>>
>>>>>>> activator.xml:
>>>>>>>
>>>>>>>  
>>>>>>>  
>>>>>>>    
>>>>>>>  
>>>>>>>
>>>>>>> These are the logs I get when updating the service
>>>>>>> bundle:
>>>>>>>
>>>>>>>> framework update 17
>>>>>>>
>>>>>>> debug    20110704 12:30:42 bid#4        - Remove
>>>>>>> BundleImpl[id=17] from SCR
>>>>>>> info     20110704 12:30:42 bid#17       - Disable
>>>>>>> Immediate
>>>>>>> component: com.sandbox.test.service.TestActivator
>>>>>>> info     20110704 12:30:42 bid#18       -
>>>>>>> Unsatisfied:
>>>>>>> Immediate component:
>>>>>>> com.sandbox.test.consumer.TestConsumer
>>>>>>> debug    20110704 12:30:42 bid#4        - Call
>>>>>>> public void
>>>>>>> com.sandbox.test.consumer.TestConsumer.deactivate() in
>>>>>>> class
>>>>>>> com.sandbox.test.consumer.TestConsumer for component
>>>>>>> com.sandbox.test.consumer.TestConsumer registered for
>>>>>>> BundleImpl[id=18]
>>>>>>> Consumer stopping...
>>>>>>> info     20110704 12:30:42 bid#17       -
>>>>>>> [26;com.sandbox.test.service.TestService] ServiceEvent
>>>>>>> UNREGISTERING
>>>>>>> debug    20110704 12:30:42 bid#4        - Call
>>>>>>> public void
>>>>>>> com.sandbox.test.service.TestActivator.deactivate() in
>>>>>>> class
>>>>>>> com.sandbox.test.service.TestActivator for component
>>>>>>> com.sandbox.test.service.TestActivator registered for
>>>>>>> BundleImpl[id=17]
>>>>>>> Service stopping...
>>>>>>> info     20110704 12:30:42 bid#17       -
>>>>>>> BundleEvent
>>>>>>> STOPPED
>>>>>>> info     20110704 12:30:42 bid#17       -
>>>>>>> BundleEvent
>>>>>>> UNRESOLVED
>>>>>>> info     20110704 12:30:42 bid#17       -
>>>>>>> BundleEvent
>>>>>>> UPDATED
>>>>>>> info     20110704 12:30:42 bid#17       -
>>>>>>> BundleEvent
>>>>>>> RESOLVED
>>>>>>> debug    20110704 12:30:42 bid#4        - Process
>>>>>>> header
>>>>>>> Service-Component for bundle#17: OSGI-INF/activator.xml
>>>>>>> debug    20110704 12:30:42 bid#4        - Parse
>>>>>>> component
>>>>>>> description: bundle://17/OSGI-INF/activator.xml
>>>>>>> debug    20110704 12:30:42 bid#4        - Check
>>>>>>> for
>>>>>>> component description: START_TAG @3:52 in
>>>>>>> java.io.InputStreamReader at 566fe6b6
>>>>>>> debug    20110704 12:30:42 bid#4        - Found
>>>>>>> component
>>>>>>> sub-element: implementation
>>>>>>> debug    20110704 12:30:42 bid#4        - Found
>>>>>>> component
>>>>>>> sub-element: service
>>>>>>> debug    20110704 12:30:42 bid#4        - Got
>>>>>>> component
>>>>>>> description:
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>> org.knopflerfish.bundle.component.ComponentDescription at 993d9d4
>>>>>>> debug    20110704 12:30:42 bid#4        - Got
>>>>>>> component
>>>>>>> description: null
>>>>>>> info     20110704 12:30:42 bid#17       - Enable
>>>>>>> Immediate
>>>>>>> component: com.sandbox.test.service.TestActivator
>>>>>>> info     20110704 12:30:42 bid#17       -
>>>>>>> Satisfied:
>>>>>>> Immediate component:
>>>>>>> com.sandbox.test.service.TestActivator
>>>>>>> debug    20110704 12:30:42 bid#4        - Created
>>>>>>> ComponentConfiguration#2, component name =
>>>>>>> com.sandbox.test.service.TestActivator
>>>>>>> info     20110704 12:30:42 bid#18       -
>>>>>>> Satisfied:
>>>>>>> Immediate component:
>>>>>>> com.sandbox.test.consumer.TestConsumer
>>>>>>> debug    20110704 12:30:42 bid#4        - Created
>>>>>>> ComponentConfiguration#3, component name =
>>>>>>> com.sandbox.test.consumer.TestConsumer
>>>>>>> Build consumer
>>>>>>> debug    20110704 12:30:42 bid#4        - Bind
>>>>>>> service
>>>>>>> org.knopflerfish.framework.ServiceReferenceImpl at f4c1f4c6
>>>>>>> to
>>>>>>> ComponentConfiguration#3, component name =
>>>>>>> com.sandbox.test.consumer.TestConsumer
>>>>>>> debug    20110704 12:30:42 bid#4        -
>>>>>>> CC.getService(),
>>>>>>> ComponentConfiguration#2, component name =
>>>>>>> com.sandbox.test.service.TestActivator, active = 0
>>>>>>> Build service
>>>>>>> debug    20110704 12:30:42 bid#4        - Call
>>>>>>> public void
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
> 
> com.sandbox.test.service.TestActivator.activate(org.osgi.service.component.ComponentContext,java.util.Map)
>>>>> left:1ex"> throws java.lang.Exception in class
>>>>> com.sandbox.test.service.TestActiva
>>>>>
>>>>>> =17]
>>>>>> Service starting...
>>>>>> debug    2011
>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
> 
> com.sandbox.test.consumer.TestConsumer.activate(org.osgi.service.component.ComponentContext,java.util.Map)
>>>>>>> throws java.lang.Exception in class
>>>>>>> com.sandbox.test.consumer.
>>>>>> for component
>>>>>> com.sandbox.test.consumer.TestConsumer registered for
>>>>>> BundleImpl[id=18]
>>>>>> Consumer starting...
>>>>>> java.lang.ClassCastException:
>>>>>> com.sandbox.test.service.TestActiv
>>>>>       at
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
> com.sandbox.test.consumer.TestConsumer.activate(TestConsumer.java:19)
>>>>>         at
>>>>>
>>>>> org.kno
>>>>>
>>>>>>
>>>>> r-left:1px #ccc solid;padding-left:1ex">
>>>>>         at
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
> 
> org.knopflerfish.bundle.component.ComponentMethod.invoke(ComponentMethod.j
>>>>>
>>>>>> d;padding-left:1ex">         at
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
> 
> org.knopflerfish.bundle.component.ComponentConfiguration.activate(ComponentConfiguration.java:104)
>>>>>
>>>>>>
>>>>>
>>>>
>>>
>> component.ImmediateComponent.satisfied(ImmediateComponent.java:67)
>>>>> ccc solid;padding-left:1ex">         at
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
> 
> org.knopflerfish.bundle.component.Component.refAvailable(Component.java:276)
>>>>>         at
>>>>>>
>>>>>> org.knopflerfish.bundle.component.R
>>>>> /u>refAvailable(Reference.java:246)
>>>>>
>>>>>         at
>>>>>
>>>>> > ReferenceListener.java:306)
>>>>> _quote" style="margin:0 0 0 .8ex;border-left:1px #ccc
>>>>> solid;padding-left:1ex">         at
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
> 
> org.knopflerfish.framework.Listeners.serviceChanged(Listeners.java:393)
>>>>> class="gmail_quote" style="margin:0 0 0
>>>>> .8ex;border-left:1px
>>>>>> #ccc solid;padding-left:1ex">         at
>>>>>
>>>>
>>>
>>
> 
> knopflerfish.framework.PermissionOps.callServiceChanged(PermissionOps.java:269)
>>>>>
>>>>>        
>>>>>
>>>>>> at
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
> 
> org.knopflerfish.framework.BundleContextImpl.registerService(BundleContextImpl.
>>>>>         at
>>>>>
>>>>> u>registerService(ComponentConfiguration.java:214)
>>>>> g-left:1ex">
>>>>>         at
>>>>>
>>>>> org.knopflerfish.bundle.component.ImmediateComponent.
>>>>> .8ex;border-left:1px #ccc solid;padding-left:1ex">
>>>>>   at
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
> 
> org.knopflerfish.bundle.component.Component.trackConstraints(Component.java:162)
>>>>>
>>>>>         at
>>>>>
>>>>>
>>>>
>>> org.knopflerfish.bundle.component.SCR.processBundle(SCR.java:280)
>>>>>         at
>>>>>
>>>>>
>>>>
>>> org.knopflerfish.bundle.component.SCR.bundleChanged(SCR.java:125)
>>>>>         at
>>>>>
>>>>> der-left:1px #ccc solid;padding-left:1ex">
>>>>>         at
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
> 
> org.knopflerfish.framework.Listeners.bundleChanged(Listeners.java:310)
>>>>>         at
>>>>> org.knopfl
>>>>>
>>>>>> /blockquote>
>>>>>>
>>>>>
>>>>
>>>
>> org.knopflerfish.framework.BundleThread.run(BundleThread.java:100)
>>>>> px #ccc solid;padding-left:1ex">
>>>>>         at java.lang.Thread.startup(Thread.java:785)
>>>>> info     20110704 12:30:42 bid#17       -
>>>>> [29;com.sandbox.test.service.TestService] ServiceEvent
>>>>> REGISTERED
>>>>> info     20110704 12:30:42 bid#17       - BundleEvent
>>>>> STARTED
>>>>> Updated: Test service (#17)
>>>>> Note: Use refresh command
>>>>>
>>>>>> _______________
>>>>>> Knopflerfish-users mailing list
>>>>>> Knopflerfish-users@
>>>>> h.org [4]
>>>>>
>>>>>
>>>> http://www.knopflerfish.org/mailman/listinfo/knopflerfish-users
>>>>> [6]
>>>>> [5]
>>>>>
>>>>> Links:
>>>>> ------
>>>>> [1] /a>
>>>>>> [2] http://www.osgi.org/xmlns/scr/v1.1.0 [1]
>>>>>> [3]
>>>>> lns/scr/v1.1.0%7Dscr:component"
>>>>>
>>>>
>>>
>>
> target="_blank">http://www.osgi.org/xmlns/scr/v1.1.0%7Dscr:component
>>>>> [4] mailto:Knopflerfish-users at knopflerfish.org [7]
>>>>> [5]
>>>>
>>>> _______________________________________________
>>>> Knopflerfish-users mailing list
>>>> Knopflerfish-users at knopflerfish.org [8]
>>>>
>>>> http://www.knopflerfish.org/mailman/listinfo/knopflerfish-users
>>>> [9]
>
>
>
> Links:
> ------
> [1] http://www.osgi.org/xmlns/scr/v1.1.0
> [2] http://www.osgi.org/xmlns/scr/v1.1.0
> [3] http://www.knopflerfish.org
> [4] mailto:jan at makewave.com
> [5] http://www.knopflerfish.org
> [6] http://www.knopflerfish.org/mailman/listinfo/knopflerfish-users
> [7] mailto:Knopflerfish-users at knopflerfish.org
> [8] mailto:Knopflerfish-users at knopflerfish.org
> [9] http://www.knopflerfish.org/mailman/listinfo/knopflerfish-users
> [10] mailto:jan at makewave.com
> [11] mailto:jeanbaptiste.reich at gmail.com



More information about the Knopflerfish-users mailing list