Class of an osgi:service defined in a spring config file cannot be instantiated 
by Spring CGLIB classes
-------------------------------------------------------------------------------------------------------

                 Key: SMX4-248
                 URL: https://issues.apache.org/activemq/browse/SMX4-248
             Project: ServiceMix 4
          Issue Type: Bug
            Reporter: Charles Moulliard


This error is generated :

s...@root:/> Exception in thread "SpringOsgiExtenderThread-14" 
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name '
activemq': FactoryBean threw exception on object creation; nested exception is 
java.lang.NoClassDefFoundError: org/springframework/core/task/TaskExecu
tor
        at 
org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:127)
        at java.security.AccessController.doPrivileged(Native Method)
        at 
org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116)
        at 
org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:91)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1288)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:217)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:425)
        at 
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
        at 
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationCont
ext.java:68)
        at 
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.ja
va:343)
        at 
org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
        at 
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplication
Context.java:308)
        at 
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(Dependen
cyWaiterApplicationContextExecutor.java:138)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.NoClassDefFoundError: 
org/springframework/core/task/TaskExecutor
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
        at java.lang.Class.getDeclaredMethod(Class.java:1907)
        at net.sf.cglib.proxy.Enhancer.getCallbacksSetter(Enhancer.java:627)
        at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:615)
        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:201)
        at 
org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
        at 
org.springframework.osgi.service.util.internal.aop.ProxyUtils$1.run(ProxyUtils.java:65)
        at java.security.AccessController.doPrivileged(Native Method)
        at 
org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:62)
        at 
org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:39)
        at 
org.springframework.osgi.service.importer.support.AbstractServiceProxyCreator.createServiceProxy(AbstractServiceProxyCreator.java:107)
        at 
org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.createProxy(OsgiServiceProxyFactoryBean.java:185)
        at 
org.springframework.osgi.service.importer.support.AbstractServiceImporterProxyFactoryBean.getObject(AbstractServiceImporterProxyFactoryBean
.java:86)
        at 
org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.getObject(OsgiServiceProxyFactoryBean.java:141)
        at 
org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:121)
        ... 15 more

When an interface is not declared (which is the case here because we would like 
to export the class : org.apache.activemq.camel.component.ActiveMQComponent), 
then Spring uses CGLIB. What we see here is that CGLIB does not find spring 
core classes (which are deployed as bundle in SMX4 - Spring )

Here is the spring xml file

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xmlns:osgi="http://www.springframework.org/schema/osgi";
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
                      http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi.xsd
                      http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd";>

      
    <bean id="activemq" 
class="org.apache.activemq.camel.component.ActiveMQComponent">
                        <property name="brokerURL" 
value="tcp://localhost:61616" />
    </bean>
    
    <osgi:service id="activemqservice" ref="activemq" 
auto-export="all-classes"/>
       
</beans>

and spring osgi bundles

s...@root:osgi> list |grep Spring
   ID   State         Spring     Level  Name
[  21] [Active     ] [       ] [   30] Spring Context (2.5.6)
[  25] [Active     ] [       ] [   30] Spring Core (2.5.6)
[  30] [Active     ] [       ] [   30] Spring Beans (2.5.6)
[  38] [Active     ] [       ] [   30] Spring AOP (2.5.6)
[  39] [Active     ] [Started] [   30] Apache ServiceMix Kernel :: Spring 
Deployer (1.1.0.SNAPSHOT)
[  48] [Active     ] [       ] [   60] Spring Transaction (2.5.6)
[  52] [Active     ] [       ] [   60] Spring JMS (2.5.6)
s...@root:osgi> list |grep spring
[  16] [Active     ] [       ] [   30] spring-osgi-io (1.2.0.m2)
[  34] [Active     ] [       ] [   30] spring-osgi-extender (1.2.0.m2)
[  41] [Active     ] [       ] [   30] spring-osgi-core (1.2.0.m2)
[  49] [Active     ] [       ] [   60] camel-spring (2.0.0.SNAPSHOT)
[  91] [Active     ] [       ] [   60] xbean-spring (3.4.3)

[ 108] [Active     ] [       ] [   60] Apache ServiceMix Bundles: cglib-2.1.3 
(2.1.3)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to