[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] Problem with classloaders and class visibility when wrapping an existing framework into a bundle plugin


Hi list,

I`m using equinox implementation of osgi and start designing a set of classes to allow use remote services with osgi,
a simple project for college work
I created a bundle which provide a service for:
addRemoteServers(ip) // here i use an approach like debian apt - just a list of servers that can provide remote services
publishRemoteService(interface, implementation) // a method that register the interface for proxy and it`s implementation on server side
getRemoteServices(ip) returns a list of services provided by ip
getRemoteService(interface) this method just lookup in a local hash table what server provide the interface and returns the an instance of a proxy for access remote services.
I'm wrapping xml_rpc from apache software foundation and using dinamic proxies approach.
my problem is:
I made it as service that publish and retrieve remote services, like a facade wrapping some apache xml-rpc`s methods.

when I tried to create an instance of a remote reference I got the following message:


Caused by: java.lang.IllegalArgumentException: interface helloremote.service.SaySomething is not visible from class loader
    at java.lang.reflect.Proxy.getProxyClass(Unknown Source)
    at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
    at org.apache.xmlrpc.client.util.ClientFactory.newInstance(ClientFactory.java:98)
    at org.apache.xmlrpc.client.util.ClientFactory.newInstance(ClientFactory.java:90)
    at br.com.porto.osgi.remote.Connection.createProxyInstance(RemoteBundleImpl.java:330)
    at br.com.porto.osgi.remote.RemoteBundleImpl.getRemoteService(RemoteBundleImpl.java:165)
    at helloremoteclient.Activator.start(Activator.java:27)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:997)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:991)
    ... 13 more
********************
SaySomething is an interface(client side) implemented by SaySomethingImpl (remote) and it is initialized by
the service. Actually the sercice initiate SaySomething with a proxy built by xmlrpc factory:
public Object createProxyInstance(Class _interface){
       Object obj;
        obj = factory.newInstance(_interface);
        return obj;

    }


I trace the newInstance inside xmlrpc package and find this:

/** Creates an object, which is implementing the given interface.
     * The objects methods are internally calling an XML-RPC server
     * by using the factories client.
     */
    public Object newInstance(Class pClass) {
        return newInstance(Thread.currentThread().getContextClassLoader(), pClass);
    }
I read some messages in felix list
http://mail-archives.apache.org/mod_mbox/incubator-felix-dev/200512.mbox/%3C43AC14F2.3000100@xxxxxxxxxxxxxx%3E
the problem seems to be the same but the solution didnot work for me.. and they said that eclipse has an different solution for that.

if someone face this problem before, how did you fix it?

thanks for help

Charles

__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/