ClassCastException in ServiceTango open source for OSGi and similiar to JES

I tried to excute bundle Club of JES tutorial in ServiceTango for a while.

But I couldn't.

I wrote the code for Club bundle exactly same with JES tutorial(p17).

And I had command start bundle Club in ServiceTango.

As u know ServiceTango couldn't excute Club.

I can't understand why this problem exist.

Is there any problem casting below code?

Don't support 'Using Another Service' in ServiceTango?

Finally, Is there any site for ServiceTango in activity.

I know servicetango in sorceforge. But, there don't have any activity.

Thanks...

Jeongpyo

>>See below

This is error output

-

Error starting bundle '11'

org.servicetango.core.STException: ; nested exception is:

org.servicetango.core.STException: ; nested exception is:

org.servicetango.core.STException: Failed to start bundle 'file:D:\HOMENET\WORK\osgi\mywork\bundle\club2.jar'; nested exception is:

java.lang.ClassCastException

org.servicetango.core.STException: ; nested exception is:

org.servicetango.core.STException: Failed to start bundle 'file:D:\HOMENET\WORK\osgi\mywork\bundle\club2.jar'; nested exception is:

java.lang.ClassCastException

org.servicetango.core.STException: Failed to start bundle 'file:D:\HOMENET\WORK\osgi\mywork\bundle\club2.jar'; nested exception is:

java.lang.ClassCastException

java.lang.ClassCastException

java.lang.Throwable()

java.lang.Exception()

java.lang.RuntimeException()

java.lang.ClassCastException()

void club2.Activator.start(org.osgi.framework.BundleContext)

void club2.Activator.start(org.osgi.framework.BundleContext)

void org.servicetango.core.BundleManager.startBundle(long)

void org.servicetango.startup.ServiceTango$6.run(java.lang.String [])

void org.servicetango.startup.ServiceTango.run()

void org.servicetango.startup.ServiceTango.main(java.lang.String [])

-

Follow code create exception.

public void start(org.osgi.framework.BundleContext ctxt) throws BundleException {

try{

ServiceReference[] ref = ctxt.getServiceReferences("greeting2.service.GreetingService", "(description=casual)");

GreetingService greetingSvc = (GreetingService) ctxt.getService(ref[0]);//this crete exception

greetingSvc.greet("Bill", "Gates", "Chairman");

}

This is manifest for club

Bundle-Activator: club.ClubActivator

Import-Package: greeting2.service

[2591 byte] By [ikong] at [2007-9-26 5:17:50]
# 1

I thing that the code must work.

Maybe the problem is that you have bundle classes in your classpath. And when the server load the classes one is loaded with java System ClassLoader, another with Bundle Class loader. Remove the direcrory where are java sources and classes of the bundle from your classpath.

If this doesn't work try to add dump like this:

Object obj = ctxt.getService(ref[0]);System.out.println(obj.getClass().getName());System.out.println(obj.getClass().getClassLoader())

... and you may be figurate the error...

Pavlin at 2007-6-29 19:22:00 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 2

Thank u very much.

output message for ur code is

1. greeting2.impl.CasualGreetingImpl

2. org.servicetango.core.STClassLoader@2587

result must be greeting2.service.GreetingService!

what's the problem?

plz help me...

follow source is about greeting2

===================================================

1.The GreetingService Interface(greeting2/service/GreetingService.java)

--

package greeting2.service;

public interface GreetingService {

public void greet(String firstName, String lastName, String title);

}

2.Implementing GreetingService(greeting2/impl/CasualGreetingImpl.java)

--

package greeting2.impl;

import greeting2.service.GreetingService;

class CasualGreetingImpl implements GreetingService {

public void greet(String firstName, String lastName, String title) {

System.out.println("Hey, I'm Jeongpyo. Nice to meet you, " + firstName);

}

}

3.The Activator Class for greeting2(greeting2/impl/Activator.java)

--

package greeting2.impl;

import java.util.Properties;

import org.osgi.framework.*;

import greeting2.service.GreetingService;

public class Activator implements BundleActivator {

private ServiceRegistration reg = null;

public void start(BundleContext ctxt) throws BundleException {

GreetingService greetingSvc = new CasualGreetingImpl();

Properties props = new Properties();

props.put("description", "casual");

reg = ctxt.registerService("greeting2.service.GreetingService", greetingSvc, props);

}

public void stop(BundleContext ctxt) throws Exception {

if(reg != null)

reg.unregister();

}

}

4. Greeting Manifest

Bundle-Activator: greeting2.impl.Activator

Export-Package: greeting2.service

ikong at 2007-6-29 19:22:00 > top of Java-index,Java Mobility Forums,Consumer and Commerce...