Issue Details (XML | Word | Printable)

Key: OSGI-110
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Costin Leau
Reporter: Andy Piper
Votes: 0
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Spring OSGi

Fix cglib issues

Created: 11/Apr/07 09:53 AM   Updated: 25/Mar/08 01:25 PM
Component/s: None
Affects Version/s: 1.0 M1
Fix Version/s: 1.0.2

Time Tracking:
Not Specified


 Description  « Hide
ServiceProxyFactoryBeanTest.testFactoryBeanForMultipleServices() fails if you use classes rather than interfaces. cglib seems to be getting confused during initialization.

 All   Comments   Work Log   Change History   FishEye   Related Builds      Sort Order: Ascending order - Click to sort in descending order
Costin Leau added a comment - 25/Apr/07 06:59 AM
I can't reproduce the issue. I have added several tests to ServiceProxyFactoryBeanTest (see #testFactoryBeanForMultipleServicesAsClasses) and everything is working fine on my machine.

Costin Leau added a comment - 25/Apr/07 07:38 AM
I managed to get the stacktrace when working on the interface test and asking for proxies over an ArrayList.
The problem seems to be CGLIB's entirely:

ERROR [org.springframework.osgi.service.collection.OsgiServiceCollection] - serviceChanged() processing failed
java.lang.ExceptionInInitializerError
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:324)
at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:616)
at net.sf.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:609)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:631)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:225)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:195)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.osgi.service.collection.OsgiServiceCollection.createServiceProxy(OsgiServiceCollection.java:225)
at org.springframework.osgi.service.collection.OsgiServiceCollection.access$000(OsgiServiceCollection.java:55)
at org.springframework.osgi.service.collection.OsgiServiceCollection$Listener.serviceChanged(OsgiServiceCollection.java:79)
at org.eclipse.osgi.framework.internal.core.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:71)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:1216)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:189)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:141)
at org.eclipse.osgi.framework.internal.core.Framework.publishServiceEventPrivileged(Framework.java:1535)
at org.eclipse.osgi.framework.internal.core.Framework.publishServiceEvent(Framework.java:1510)
at org.eclipse.osgi.framework.internal.core.ServiceRegistrationImpl.<init>(ServiceRegistrationImpl.java:103)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.createServiceRegistration(BundleContextImpl.java:649)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:601)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:667)
at org.springframework.osgi.iandt.serviceProxyFactoryBean.ServiceProxyFactoryBeanTest.publishService(ServiceProxyFactoryBeanTest.java:61)
at org.springframework.osgi.iandt.serviceProxyFactoryBean.ServiceProxyFactoryBeanTest.publishService(ServiceProxyFactoryBeanTest.java:69)
at org.springframework.osgi.iandt.serviceProxyFactoryBean.ServiceProxyFactoryBeanTest.testFactoryBeanForMultipleServicesAsInterfaces(ServiceProxyFactoryBeanTest.java:149)
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:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at org.springframework.osgi.test.AbstractOsgiTests.osgiRunTest(AbstractOsgiTests.java:259)
at org.springframework.osgi.test.support.OsgiJUnitService$1.protect(OsgiJUnitService.java:135)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at org.springframework.osgi.test.support.OsgiJUnitService.runTest(OsgiJUnitService.java:132)
at org.springframework.osgi.test.support.OsgiJUnitService.executeTest(OsgiJUnitService.java:103)
at org.springframework.osgi.test.support.OsgiJUnitService.runTest(OsgiJUnitService.java:80)
at org.springframework.osgi.test.JUnitTestActivator.executeTest(JUnitTestActivator.java:64)
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:324)
at org.springframework.osgi.test.AbstractOsgiTests.invokeOSGiTestExecution(AbstractOsgiTests.java:306)
at org.springframework.osgi.test.AbstractOsgiTests.runBare(AbstractOsgiTests.java:226)
at org.springframework.osgi.test.AbstractOsgiTests$1.protect(AbstractOsgiTests.java:214)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at org.springframework.osgi.test.AbstractOsgiTests.run(AbstractOsgiTests.java:212)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.NullPointerException
at net.sf.cglib.core.AbstractClassGenerator.getClassNameCache(AbstractClassGenerator.java:80)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:218)
at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:64)
at net.sf.cglib.proxy.MethodProxy.helper(MethodProxy.java:81)
at net.sf.cglib.proxy.MethodProxy.create(MethodProxy.java:47)
at $java.util.ArrayList$$EnhancerByCGLIB$$99b990fd.CGLIB$STATICHOOK3(<generated>)
at $java.util.ArrayList$$EnhancerByCGLIB$$99b990fd.<clinit>(<generated>)
... 58 more

Costin Leau added a comment - 25/Apr/07 07:50 AM
it's even worst. The problem seems to appear from time to time and depends on the environment. for example it works fine under Eclipse but KF fails under maven.


Tim Eck added a comment - 11/Jan/08 10:17 PM
any chance the test code that [occasionally] demonstrates the NPE is still available? <thanks>

Costin Leau added a comment - 12/Jan/08 02:33 PM
Sure - I'll update the test code and uploaded it shortly. Thanks for your interest.

Costin Leau added a comment - 21/Mar/08 04:22 AM
Sorry timeck, this task just slipped through my hands. I'll try to make time asap and send you a test case. Cheers,

Costin Leau added a comment - 25/Mar/08 01:14 PM
Tim, apparently the latest version of SpringDM (which addressed the classloader identity) doesn't exhibit this problem which leads me to believe that the problem was on our side.
I've updated the test case that I had and all tests pass fine on 1.4-1.6. Thanks for your interest.

Tim Eck added a comment - 25/Mar/08 01:25 PM
okee doke. Glad to hear it was resolved. Maybe one of these days I'll look for another bug in here.