Back Forum Reply New

Spring AOP w/ cglib + OSGi failing

I am attempting to use Spring AOP's lt;aop:scoped-proxy /gt; element with a class in an OSGi environment (Virgo Web Server). When deploying the project I get the following exception:Code:
o.a.catalina.core.ContainerBase.[Catalina].[localhost].[/prototype]   Exception sending context initialized event to listener instance of class org..web.context.ContextLoaderListener org..beans.factory.BeanCreationException: Error creating bean with name 'testBean' defined in BeanDefinition defined in ServletContext resource [/WEB-INF/bundle-context.xml]: Initialization of bean failed; nested exception is org..aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.test.TestBean]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: class com.test.TestBean$$EnhancerByCGLIB$$9990ff93 is not an enhanced class
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org..beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org..beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org..beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org..beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:540)
at org..context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
at org..context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
at org..osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$301(AbstractDelegatedExecutionApplicationContext.java:69)
at org..osgi.context.support.AbstractDelegatedExecutionApplicationContext$1.run(AbstractDelegatedExecutionApplicationContext.java:186)
at org..osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org..osgi.context.support.AbstractDelegatedExecutionApplicationContext.normalRefresh(AbstractDelegatedExecutionApplicationContext.java:182)
at org..osgi.context.support.AbstractDelegatedExecutionApplicationContext$NoDependenciesWaitRefreshExecutor.refresh(AbstractDelegatedExecutionApplicationContext.java:89)
at org..osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)
at org..web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
at org..web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
at org..web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3983)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4483)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:120)
at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:90)
at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:120)
at org.eclipse.virgo.kernel.install.artifact.internal.ArtifactStateMonitor.onStarted(ArtifactStateMonitor.java:205)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStartSucceeded(AbstractInstallArtifact.java:273)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.access$0(AbstractInstallArtifact.java:270)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact$StateMonitorSignal.signalSuccessfulCompletion(AbstractInstallArtifact.java:223)
at org.eclipse.virgo.kernel.core.internal.BundleStartTracker$1.run(BundleStartTracker.java:140)
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: org..aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.test.TestBean]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: class com.test.TestBean$$EnhancerByCGLIB$$9990ff93 is not an enhanced class
at org..aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:212)
at org..aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
at org..aop.scope.ScopedProxyFactoryBean.setBeanFactory(ScopedProxyFactoryBean.java:109)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1422)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1389)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
... 33 common frames omitted
Caused by: java.lang.IllegalArgumentException: class com.test.TestBean$$EnhancerByCGLIB$$9990ff93 is not an enhanced class
at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:618)
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..aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:200)
... 38 common frames omitted
The bean definition is:Code:
lt;bean id=quot;testBeanquot; scope=quot;requestquot; class=quot;com.test.TestBeanquot;gt;   lt;aop:scoped-proxy /gt;
lt;/beangt;
Has anyone seen this issue before?

This error occurs for both classes within the same bundle or imported from another. I'm using Spring AOP 3.0.0.RELEASE and cglib 2.1.3 from the EBR (confirmed the issue is present in 2.2.0 as well).

I solved the problem. It must have been a missing Import-Package. I used Require-Bundle and the problem disappeared.
¥
Back Forum Reply New