[DMS-2491] Cannot export more than one service through RMI: NotSerializableException: c.s.k.u.i.e.KernelBundleClassLoader Created: 28/Apr/10  Updated: 11/May/10  Resolved: 11/May/10

Status: Done
Project: dm Server
Component/s: None
Affects Version/s: 2.0.1.RELEASE
Fix Version/s: Sprint 28

Type: Defect Priority: Blocker
Reporter: Rico Besson Assignee: Chris Frost [X] (Inactive)
Resolution: Complete Votes: 0
Labels: None
Σ Remaining Estimate: 0h Remaining Estimate: 0h
Σ Time Spent: 9h 5m Time Spent: 8h
Σ Original Estimate: 12h Original Estimate: 8h
Environment:

ubuntu 9.04


Attachments: Zip Archive rmiExportSample.zip    
Sub-Tasks:
Key
Summary
Type
Status
Assignee
DMS-2525 Assist with RMI bug Sub-task Done Glyn Normington (c)  
Story Points: 5
Spring Forum Reference: http://forum.springsource.org/showthread.php?p=297056#post297056
First Response Date:

 Description   

I want to upgrade my application which was running on dm Server 1.0.2. One of the applications bundles exports several services to rmi via spring.

No the upgrade is blocking because this is not working on my dm Server 2.0.1. With a little bit trying and
playing around i realised, that the failure occurs just when more than one service is exported.

Attached is a small application containing two bundels packaged in a par.

When i start the server, while starting the bundle which exports the services, i get the following trace:

...
[2010-04-28 11:13:43.603] Thread-2 <UR0001I> User region ready.
[2010-04-28 11:13:44.693] TCP Connection(2)-127.0.0.1 <DE0000I> Installing par 'com.not.exists.server.par' version '1.0.0'.
[2010-04-28 11:13:44.699] TCP Connection(2)-127.0.0.1 <DE0000I> Installing bundle 'com.not.exists.server.par-1-com.not.exists.server.service' version '1.0.0'.
[2010-04-28 11:13:44.705] TCP Connection(2)-127.0.0.1 <DE0000I> Installing bundle 'com.not.exists.server.par-1-com.not.exists.service' version '1.0.0'.
[2010-04-28 11:13:44.773] TCP Connection(2)-127.0.0.1 <DE0001I> Installed bundle 'com.not.exists.server.par-1-com.not.exists.server.service' version '1.0.0'.
[2010-04-28 11:13:44.778] TCP Connection(2)-127.0.0.1 <DE0001I> Installed bundle 'com.not.exists.server.par-1-com.not.exists.service' version '1.0.0'.
[2010-04-28 11:13:44.782] TCP Connection(2)-127.0.0.1 <DE0001I> Installed bundle 'com.not.exists.server.par-1-synthetic.context' version '1.0.0'.
[2010-04-28 11:13:44.786] TCP Connection(2)-127.0.0.1 <DE0001I> Installed par 'com.not.exists.server.par' version '1.0.0'.
[2010-04-28 11:13:44.804] TCP Connection(2)-127.0.0.1 <DE0004I> Starting par 'com.not.exists.server.par' version '1.0.0'.
[2010-04-28 11:13:44.809] TCP Connection(2)-127.0.0.1 <DE0004I> Starting bundle 'com.not.exists.server.par-1-com.not.exists.server.service' version '1.0.0'.
[2010-04-28 11:13:44.829] TCP Connection(2)-127.0.0.1 <DE0004I> Starting bundle 'com.not.exists.server.par-1-com.not.exists.service' version '1.0.0'.
[2010-04-28 11:13:44.855] start-signalling-1 <DE0005I> Started bundle 'com.not.exists.server.par-1-com.not.exists.service' version '1.0.0'.
[2010-04-28 11:13:44.869] TCP Connection(2)-127.0.0.1 <DE0004I> Starting bundle 'com.not.exists.server.par-1-synthetic.context' version '1.0.0'.
[2010-04-28 11:13:44.874] start-signalling-1 <DE0005I> Started bundle 'com.not.exists.server.par-1-synthetic.context' version '1.0.0'.
[2010-04-28 11:13:45.128] Thread-3 <AG0000E> Application context creation failure for bundle 'com.not.exists.server.par-1-com.not.exists.server.service' version '1.0.0'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.remoting.rmi.RmiServiceExporter#1' defined in URL [bundleentry://42.fwk6391091/META-INF/spring/context.xml]: Invocation of init method failed; nested exception is java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.springsource.kernel.userregion.internal.equinox.KernelBundleClassLoader
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
at com.springsource.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:106)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.springsource.kernel.userregion.internal.equinox.KernelBundleClassLoader
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:227)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at org.springframework.remoting.rmi.RmiServiceExporter.prepare(RmiServiceExporter.java:286)
at org.springframework.remoting.rmi.RmiServiceExporter.afterPropertiesSet(RmiServiceExporter.java:227)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
... 17 common frames omitted
Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.springsource.kernel.userregion.internal.equinox.KernelBundleClassLoader
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:225)
... 23 common frames omitted
Caused by: java.io.NotSerializableException: com.springsource.kernel.userregion.internal.equinox.KernelBundleClassLoader
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:416)
at java.lang.Throwable.writeObject(Throwable.java:648)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:403)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
... 3 common frames omitted



 Comments   
Comment by Glyn Normington (c) [ 28/Apr/10 ]

Thanks for raising this and taking the time to provide a testcase.

Comment by Glyn Normington (c) [ 28/Apr/10 ]

See http://forum.springsource.org/showthread.php?p=297056#post297056 for more background.

Comment by Chris Frost [X] (Inactive) [ 04/May/10 ]

Problem must be fixed on the 2.0.x branch and then forward ported to Virgo

Comment by Chris Frost [X] (Inactive) [ 07/May/10 ]

I am currently testing this outside of a dm Server environment in an attempt to simplify this even further.

Comment by Chris Frost [X] (Inactive) [ 10/May/10 ]

If you add an import for "org.springframework.remoting.support" it will work. The problem appears to be that it tries to serialise the classNotFoundException which is one of ours eventually and holds a ref to the KernelBundleClassLoader. So we have a fix to make that reference 'transient' and adding that import should get you going. Please let us know how this goes.

Comment by Rico Besson [ 10/May/10 ]

Yes. I confirm, with this import everything works fine now (in both, the attached sample and my "real" project which has to be updated)!!

Thanks a lot

Comment by Chris Frost [X] (Inactive) [ 11/May/10 ]

The great to hear, I hope the rest of your journey to 2.0 is a little smoother.

Comment by Chris Frost [X] (Inactive) [ 11/May/10 ]

Having looked at this further and considering that serialisation is being discussed in the OSGi alliance I'm not going to spend more time trying to improve the diagnostics. It seems simple marking the reference to the KernelBundleClassloader as transient isn't doing the job.

For anyone that has a similar issue in the future, diagnosing what is wrong is simply a case of trying to figure out what class it can't load. Using a debugger to put a stop on when the NotSerialiseable Exception is thrown then looking up the cause of the exception it is trying to serialise will show you.

Generated at Thu Nov 23 05:28:23 UTC 2017 using JIRA 6.1.4#6159-sha1:44eaedef2e4a625c6c7183698b2468d4719c20dc.