Hi,

I'm trying to create an RMI Service Exporter inside a bundle to be deployed over equinox (no Spring DM).

The following spring core bundles are installed as OSGi bundles on the equinox framework:
id State Bundle
0 ACTIVE org.eclipse.osgi_3.5.0.v20090520
13 ACTIVE org.springframework.core_3.0.5.RELEASE
14 ACTIVE com.springsource.org.apache.commons.logging_1.1.1
15 ACTIVE org.springframework.beans_3.0.5.RELEASE
16 ACTIVE org.springframework.context_3.0.5.RELEASE
17 ACTIVE org.springframework.context.support_3.0.5.RELEASE
18 ACTIVE org.springframework.expression_3.0.5.RELEASE
19 ACTIVE org.springframework.asm_3.0.5.RELEASE
20 ACTIVE org.springframework.aop_3.0.5.RELEASE
22 ACTIVE com.springsource.org.aopalliance_1.0.0
24 ACTIVE org.springframework.aspects_3.0.5.RELEASE

Since Im using OSGi I chose not to use the traditional Spring beans xml file (because of classloading issues) but to create the beans programatically using the GenericApplicationContext and GenericBeanDefinition classes as follows:

//================================================== ===============================
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
GenericBeanDefinition myServiceBeanDef = new GenericBeanDefinition();
GenericBeanDefinition rmiExporterBeanDef = new GenericBeanDefinition();
RmiServiceExporter rmiExporter = null;

//Create My Service Instance
myServiceBeanDef.setBeanClass(MyServiceImpl.class) ;
myServiceBeanDef.setScope("singleton");
myServiceBeanDef.setAutowireCandidate(true);
ctx.registerBeanDefinition("myService", myServiceBeanDef);

//Set RMI Exporter Properties
MutablePropertyValues values = new MutablePropertyValues();
values.addPropertyValue("serviceName", "myService");
values.addPropertyValue("serviceInterface", MyService.class);
values.addPropertyValue("service", new RuntimeBeanReference("myService"));

//Create RMI Exporter
rmiExporterBeanDef.setBeanClass(RmiServiceExporter .class);
rmiExporterBeanDef.setPropertyValues(values);
ctx.registerBeanDefinition("rmiExporter", rmiExporterBeanDef);

this.rmiExporter = (RmiServiceExporter) ctx.getBean("rmiExporter");
//================================================== ===============================

The above piece of code is executed by my bundle's Activator.
However, when I try to start my bundle I get the following Exception:

java.lang.IllegalArgumentException: interface demo.spring.remoting.MyService is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:3 53)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.jav a:581)
at org.springframework.aop.framework.JdkDynamicAopPro xy.getProxy(JdkDynamicAopProxy.java:117)
at org.springframework.aop.framework.ProxyFactory.get Proxy(ProxyFactory.java:112)
at org.springframework.remoting.support.RemoteExporte r.getProxyForService(RemoteExporter.java:169)
at org.springframework.remoting.rmi.RmiBasedExporter. getObjectToExport(RmiBasedExporter.java:61)
at org.springframework.remoting.rmi.RmiServiceExporte r.prepare(RmiServiceExporter.java:273)
at org.springframework.remoting.rmi.RmiServiceExporte r.afterPropertiesSet(RmiServiceExporter.java:229)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1417)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 91)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:288 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:1075)
at demo.spring.remoting.MyServiceInit.init(MyServiceI nit.java:64)
at demo.osgi.Activator.start(Activator.java:17)
at org.eclipse.osgi.framework.internal.core.BundleCon textImpl$1.run(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleCon textImpl.startActivator(BundleContextImpl.java:773 )
at org.eclipse.osgi.framework.internal.core.BundleCon textImpl.start(BundleContextImpl.java:754)
at org.eclipse.osgi.framework.internal.core.BundleHos t.startWorker(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(AbstractBundle.java:272)
at org.eclipse.osgi.framework.internal.core.Framework CommandProvider._start(FrameworkCommandProvider.ja va:253)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.osgi.framework.internal.core.Framework CommandInterpreter.execute(FrameworkCommandInterpr eter.java:155)
at org.eclipse.osgi.framework.internal.core.Framework Console.docommand(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.Framework Console.console(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.Framework Console.run(FrameworkConsole.java:224)
at java.lang.Thread.run(Thread.java:619)

I should add that MyService resides in my bundle and not in another bundle.
I understand that there is a problem that the classloader that creates the Proxy isn't exposed to my service and somehow the proxy creation
should be done by the defining classloader (i.e. my bundle's classloader) but I really dont know how to solve that.

Maybe im totally in the wrong way here and there is a better way to make Spring RMI work on top of equinox.
The solution to use Spring DM is not an option since I have to work on top of an Application Server that uses Equinox and Aries as OSGi Core and Enterprise
solution respectively.


Help we be appreciated.
Thanks

YA