ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google

Mail Archive Home | oscar List | March 2006 Index

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

Re: [oscar] Activator error - java.lang.ClassCastException

This is just a guess, but is the class you are trying to cast to available on the class path and also exported from a bundle? If so, this would be causing problems, since the bundle is seeing two different classes. By default, Oscar exposes classes on the class path. On the contrary, Felix hides classes on the class path by default to eliminate these types of issues.

-> richard

ali_van123@xxxxxxxxx wrote:
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.startBundle(Oscar.java:1721)
        at org.ungoverned.oscar.BundleImpl.start(BundleImpl.java:128)
        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() + 
")" +
                // Query the framework for all KPIbundle services
                ServiceReference[] sRefs = kpiactcntxt.getServiceReferences(
// Just assign the first found KPIbundle service reference if (sRefs != null){
                        svcRef = sRefs[0];
                        krSvc = 
                // 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
                // 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 = null;

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

Could someone please enlighten me on this exception?




You receive this message as a subscriber of the oscar@xxxxxxxxxxxxx mailing 
To unsubscribe: mailto:oscar-unsubscribe@xxxxxxxxxxxxx
For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

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

Reply via email to:

Powered by MHonArc.

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