ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | oscar List | March 2006 Index

<--  Date Index  --> <--  Thread Index  -->

Activator error - java.lang.ClassCastException


Hello everyone,

Being still new to the OSGi framework, i have gotten the following error but 
do not know why it arises. 

The error is as follows:

===================================================================>
java.lang.ClassCastException: impl.KPIBundleActivator$KPIBundleImpl
        at kpiagent.impl.KPIAgentActivator.start(KPIAgentActivator.java:55)
        at 
org.ungoverned.oscar.Oscar.startBundleWithStartLevel(Oscar.java:1831)

        at org.ungoverned.oscar.Oscar.startBundle(Oscar.java:1721)
        at org.ungoverned.oscar.BundleImpl.start(BundleImpl.java:128)
        at 
org.ungoverned.osgi.bundle.shellplugin.BundleListPlugin$3.actionPerfo
rmed(BundleListPlugin.java:169)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        
        .......

        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
<==================================================================

The rest represented by the "....." were not placed as I think they are not 
necessary as thhey all say the same thing : "unknown source".


The snippet to my activator is as follows:

------------------------------------------------------------------->

public class KPIAgentActivator implements BundleActivator, ServiceListener{

        private static BundleContext kpiactcntxt = null;
        private XmlRpcService xmlrpcSvc = null;
        private KPIHandler kpiHndlr = null;     
        private ServiceReference svcRef = null;
//      private ServiceReference[] sRefs = null;
        private KPIResultService krSvc = null;
        private Map KPIServiceList = null;
        
        public void start(BundleContext context) throws Exception {
                
                kpiactcntxt = context;
                KPIServiceList = new HashMap();
                
                
                // Start listening for kpiservice events using this bundle's 
context 
                kpiactcntxt.addServiceListener(this,
                                "(&(objectClass=" + 
KPIResultService.class.getName() + ")" +
                                "(KPIName=*))");
                
                // Query the framework for all KPIbundle services
                ServiceReference[] sRefs = kpiactcntxt.getServiceReferences(
                                KPIResultService.class.getName(), 
"(KPIName=*)");
                
                // Just assign the first found KPIbundle service reference 
                if (sRefs != null){
                        svcRef = sRefs[0];
                        krSvc = 
(KPIResultService)kpiactcntxt.getService(svcRef);
                        
                // Store each KPIbundle in a Map of the XMLRPC Handler
                        for (int i = 0; i < sRefs.length; i++) {
                                Bundle bundle = sRefs[i].getBundle();
                                String location = bundle.getLocation();
                                KPIServiceList.put(location, bundle);
                                kpiHndlr.setKPIBundleItems(location, bundle);
                        }
                }
                
                // Debugging line to check what is being done
                printMapToScreen(KPIServiceList);
                
                // Add an xmlrpc handler to softsells bundle
                xmlrpcSvc.addHandler(kpiHndlr.kpihName, kpiHndlr);
                
        }

        public void stop(BundleContext context) throws Exception {
                // Remove the handler from SoftSell bundle context
                xmlrpcSvc.removeHandler(kpiHndlr.kpihName);
                xmlrpcSvc = null;
        }
<-------------------------------------------------------------------

The error seems to come frm the line: 
krSvc = (KPIResultService)kpiactcntxt.getService(svcRef);

Could someone please enlighten me on this exception?

Thanks

a.v



<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster.