Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330924

Summary: Classloader Exception during EntityManager setup
Product: [RT] Virgo Reporter: Steffen Fritzsche <fritzsche>
Component: unknownAssignee: Glyn Normington <glyn.normington>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dmitry, eclipse, glyn.normington
Version: unspecified   
Target Milestone: 3.0.0.M01   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Minimal version to reproduce problem none

Description Steffen Fritzsche CLA 2010-11-23 09:46:52 EST
Build Identifier: Virgo 2.1.0.RELEASE

During startup of EntityManager a Classloader Exception is thrown:

Caused by: java.lang.ClassCastException: org.eclipse.osgi.internal.composite.CompositeClassLoader cannot be cast to org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader
        at org.eclipse.virgo.kernel.userregion.internal.equinox.EquinoxUtils.getBundleClassLoader(EquinoxUtils.java:67)
        ... 74 common frames omitted

I described the problem in detail in http://www.eclipse.org/forums/index.php?t=msg&th=200762

Reproducible: Sometimes

Steps to Reproduce:
I will upload all necessary bundles to reproduce the problem. The only relevant thing I changed in the Virgo configuration is, that I included the package "com.sun.jndi.ldap" in the server profile, since this is needed by spring-ldap 1.3.0.

Furthermore I use a modified version of spring-ldap based on the version in the springsource bundle repository. I just changed the MANIFEST to use spring 3.0 instead of spring 2.5. I will include the modified version in my upload.
Comment 1 Glyn Normington CLA 2010-11-23 09:58:53 EST
This appears to be a bug in EquinoxUtils which assumes that any bundle class loader can be cast to DefaultClassLoader, which the user region bundle's CompositeClassLoader cannot.
Comment 2 Steffen Fritzsche CLA 2010-11-23 10:56:07 EST
Created attachment 183679 [details]
Minimal version to reproduce problem

If you have any questions or need access to our nexus repository please pm or mail me. I will provide you with the necessary password.

I could reproduce the problem exactly with this version. In 3 out of 5 tests, the bundles did not start with the described classloader problem.
Comment 3 Glyn Normington CLA 2010-11-23 12:09:14 EST
Thanks for supplying the zip file to reproduce! (At 12.9 Mb, I'm glad it was minimal.)

I changed EquinoxUtils line 67 thus:

-                classLoader = (DefaultClassLoader) createClassLoaderMethod.invoke(bundleLoader, args);
+                classLoader = (ClassLoader) createClassLoaderMethod.invoke(bundleLoader, args);

The contract of EquinoxUtils appears to be only to return a class loader, so I'm optimistic this will fix the problem. I'm regression testing the kernel and if that passes, I'll ripple the change up and then crack open the zip file and see if I can reproduce the problem without the fix before seeing if the fix fixes it.

Please could you spell out the steps to reproduce the problem as I peeked inside the zip file and it's not entirely obvious and I don't want to waste time guessing. I'd prefer to use the inner zip file as I have no interested in building this code from scratch if I can avoid it. ;-) Thanks!
Comment 4 Glyn Normington CLA 2010-11-23 12:15:04 EST
Kernel regression test passed. Now rippling. I'm going home and will pick up the thread tomorrow although I have sprint tasks to keep me busy, so it may take a while to get to testing this.
Comment 5 Steffen Fritzsche CLA 2010-11-23 15:24:14 EST
I'll create a simpler version with an embedded database tomorrow, containing just the binaries. I think this should be enough for testing.
Comment 6 Glyn Normington CLA 2010-11-23 23:16:07 EST
The fix is available in development build http://dl.dropbox.com/u/2487064/virgo-web-server-2.2.0.D-20101123182904.zip. If you wouldn't mind testing it, that would be very helpful. Otherwise I will await more instructions.
Comment 7 Steffen Fritzsche CLA 2010-11-24 05:23:36 EST
No problem. I'm loading the provided developer build right now and test it.
Comment 8 Glyn Normington CLA 2010-11-24 06:24:29 EST
Thanks. Much appreciated!
Comment 9 Steffen Fritzsche CLA 2010-11-24 10:38:37 EST
I'm finished with testing, good news the provided developer version seems to fix the bug!

All testing was done on a iMac on OSX 10.6.5, running java 1.6_u22

First test series:

I used the minimal version of my app provided above, with the current stable virgo release 2.1.0.RELEASE

Deployment was successful 4 times out of 10  :(



Second test series:

Minimal version, on provided developer build 2.2.0.D-20101123182904

Deployment was successful 10 times out of 10 :)



Third test series:

Full app version, on provided developer build 2.2.0.D-20101123182904

Deployment was successful 10 times out of 10 :)



So I would say, this fixes my problem! Thanks for the fast response!
Comment 10 Glyn Normington CLA 2010-11-24 10:47:31 EST
Great news and thanks for re-testing! We're not always this responsive, but the fact that this had come up before and wasn't solved added impetus.
Comment 11 Glyn Normington CLA 2010-11-24 10:50:46 EST
Oh and thanks to Dmitry for spotting the root cause.