Hi Guillaume,

The stack trace shows the CGLIB tries to create a proxy and thus introspect
the beans: such introspection requires all the classes referenced on all
methods to be available.  Looks like this is not the case.    I have hardly
used CGLIB from inside spring-dm and I usually use only interface exports,

>> You are right but the ActiveMqComponent is only available as a java class
>> (not interface). Do you think that it is a good idea to request the
>> creation of a java interface for this camel component or maybe a service
>> that we can call to obtain the java class like

public interface ServiceHelper {

    public Component getComponent(Component component)

}

public class ServiceHelperImpl {
   
    public Component getComponent(Component component) {
        return (Component) new ....
    }
}

With such a service, we can use interface in the osgi service :

<osgi:service id="activemqService" ref="activemqcomponent"
interface="ServiceHelper" />

<bean id="activemqcomponent" class="ServiceHelperImpl" />


not class exports so that plain JDK proxies are used instead.  This also
means that only classes referenced from the exported interface need to be
available.
Just use an interface for the export, or make sure you client bundle as all
the packages available...

Does it make sense the bundle packaging the osgi:service exports also all
the spring core classes required by CGLIB like org.springframework.core.task
?

Regards,

Charles

gnodet wrote:
> 
> 2009/3/16 cmoulliard <[email protected]>
> 
>>
>> Hi Guillaume,
>>
>> Here is the output of the command executed for the osgi bundle exporting
>> the
>> service :
>>
>> ActiveMq Broker Feature (105) provides:
>> ---------------------------------------
>> org.apache.activemq.camel.component.ActiveMQComponent
>>
> 
> Try with "osgi/ls 105" it will give you all the classes exported by the
> service.
> You need all those packages as imports on your client bundle.
> Check the objectClass header associated with the exported service in this
> output.
> 
> 
>>
>> Nevertheless, if I change the syntax in my service like this :
>>
>> from :
>>    <osgi:service id="activemqservice" ref="active-mq"
>> auto-export="all-classes"/>
>>  to
>>   <osgi:service id="activemqservice" ref="active-mq"
>> interface="org.apache.activemq.camel.component.ActiveMQComponent"/>
>>
>> it works except that I have a new error during proxy creation of the
>> class
>> ActiveMqComponent :
>>
>> 16:48:27,902 | ERROR | xtenderThread-16 | OsgiBundleXmlApplicationContext
>>  |
>> gatedExecutionApplicationContext  366 | Post refresh error
>> org.springframework.beans.factory.BeanCreationException: Error creating
>> bean
>> with name 'importedActiveMqService': FactoryBean threw exception on
>> object
>> creation; nested exception is java.lang.NoClassDefFoundError:
>> org/springframework/core/task/TaskExecutor
>>        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(AbstractDelegatedExecutionApplicationContext.java:68)
>>        at
>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:343)
>>        at
>>
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>>        at
>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:308)
>>        at
>>
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:138)
>>        at java.lang.Thread.run(Thread.java:619)
>> Caused by: java.lang.NoClassDefFoundError:
>> org/springframework/core/task/TaskExecutor
>>        at java.lang.Class.getDeclaredMethods0(Native Method)
>>        at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
>>        at java.lang.Class.getDeclaredMethod(Class.java:1935)
>>        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
>> Caused by: java.lang.ClassNotFoundException:
>> org.springframework.core.task.TaskExecutor
>>        at
>>
>> org.springframework.osgi.context.internal.classloader.ChainedClassLoader.doLoadClass(ChainedClassLoader.java:126)
>>        at
>>
>> org.springframework.osgi.context.internal.classloader.ChainedClassLoader.loadClass(ChainedClassLoader.java:108)
>>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>>
> 
> The stack trace shows the CGLIB tries to create a proxy and thus
> introspect
> the beans: such introspection requires all the classes referenced on all
> methods to be available.  Looks like this is not the case.    I have
> hardly
> used CGLIB from inside spring-dm and I usually use only interface exports,
> not class exports so that plain JDK proxies are used instead.  This also
> means that only classes referenced from the exported interface need to be
> available.
> Just use an interface for the export, or make sure you client bundle as
> all
> the packages available...
> 
> 
>>
>>
>> gnodet wrote:
>> >
>> > Can you run the "osgi/ls xx" command on the service bundle and paste
>> the
>> > output ?
>> >
>> > 2009/3/16 cmoulliard <[email protected]>
>> >
>> >>
>> >> 1) Service
>> >>
>> >> The bundle where the service is declared (osgi:service) only import
>> this
>> >> package
>> >>
>> >> org.apache.activemq.camel.component
>> >>
>> >> 2) Referenced
>> >>
>> >> The bundle where the service will be consumed (osgi:reference) import
>> >> these
>> >> references :
>> >>
>> >> org.apache.commons.logging,
>> >> org.apache.camel,
>> >> org.apache.camel.component,
>> >> org.apache.camel.component.jms,
>> >> org.apache.activemq.camel.component;${activemq.osgi.version},
>> >> org.apache.activemq.pool,
>> >>
>> >> but the error is alway there
>> >>
>> >>
>> >>
>> >> gnodet wrote:
>> >> >
>> >> > You don't need to export the package, as this one is exported by the
>> >> > activemq-camel bundle.
>> >> > But you need to import additional packages such as org.apache.camel
>> and
>> >> > all
>> >> > packages that are used by the osgi service that you are trying to
>> get
>> a
>> >> > reference to.
>> >> >
>> >> > 2009/3/16 cmoulliard <[email protected]>
>> >> >
>> >> >>
>> >> >> My issue is that the name of the package is the same between
>> >> >> import-package
>> >> >> and export-package and maven felix bnd does not add export package
>> :
>> >> >>
>> >> >>                                <configuration>
>> >> >>
>> >> >>  <manifestLocation>META-INF</manifestLocation>
>> >> >>                                        <instructions>
>> >> >>
>> >> >>  <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
>> >> >>
>> >> >>
>> >> <Import-Package>org.apache.activemq.camel.component,*</Import-Package>
>> >> >>
>> >> >> 
>> <Export-Package>org.apache.activemq.camel.component</Export-Package>
>> >> >>
>> >> >>  <Include-Resource>src/main/resources</Include-Resource>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> <Spring-Context>*;publish-context:=false;create-asynchronously:=true</Spring-Context>
>> >> >>
>> >> >>  <Private-Package></Private-Package>
>> >> >>                                        </instructions>
>> >> >>                                </configuration>
>> >> >>
>> >> >> and result of the importation (no Export-Package appears)
>> >> >>
>> >> >> ActiveMq Broker Feature (103)
>> >> >> -----------------------------
>> >> >> Manifest-Version = 1.0
>> >> >> Bnd-LastModified = 1237215735043
>> >> >> Tool = Bnd-0.0.255
>> >> >> Spring-Context =
>> *;publish-context:=false;create-asynchronously:=true
>> >> >> Bundle-Name = ActiveMq Broker Feature
>> >> >> Built-By = Charlesm
>> >> >> Import-Package = org.apache.activemq.camel.component
>> >> >> Bundle-SymbolicName = reportincident.activemq
>> >> >> Bundle-Version = 1.0.0.SNAPSHOT
>> >> >> Build-Jdk = 1.6.0_12
>> >> >> Created-By = Apache Maven Bundle Plugin
>> >> >> Bundle-ManifestVersion = 2
>> >> >>
>> >> >>
>> >> >>
>> >> >> gnodet wrote:
>> >> >> >
>> >> >> > The reason is that for a given OSGi bundle to be able to see a
>> >> service
>> >> >> in
>> >> >> > the OSGi registry, it has to have on its classpath all the
>> classes
>> >> or
>> >> >> > interfaces exported by the target OSGi service.  I suspect that
>> in
>> >> your
>> >> >> > case, your client bundle does not import all the needed packages.
>> >> You
>> >> >> can
>> >> >> > see the exact list of classes exported using the "osgi/ls"
>> command
>> >> and
>> >> >> the
>> >> >> > list of packages imported using "packages/import" command.
>> >> >> > Make sure your bundle imports all the packages from the export
>> list.
>> >> >> > This is a drawback of using auto-export imho.
>> >> >> >
>> >> >> > 2009/3/16 cmoulliard <[email protected]>
>> >> >> >
>> >> >> >>
>> >> >> >> Hi,
>> >> >> >>
>> >> >> >> I have created an osgi bundle where the bean to expose as a
>> service
>> >> is
>> >> >> >> defined in a spring file :
>> >> >> >>
>> >> >> >>    <bean id="activemq"
>> >> >> >> class="org.apache.activemq.camel.component.ActiveMQComponent">
>> >> >> >>                        <property name="brokerURL"
>> >> >> >> value="vm://localhost:61616?create=false" />
>> >> >> >>    </bean>
>> >> >> >>
>> >> >> >>    <osgi:service id="activemqservice" ref="activemq"
>> >> >> >> auto-export="all-classes"/>
>> >> >> >>
>> >> >> >> The service is well published. See the log here after.
>> >> >> >>
>> >> >> >> 13:18:42,058 | DEBUG | xtenderThread-16 |
>> >> >> OsgiBundleXmlApplicationContext
>> >> >> >>  |
>> >> >> >> ractOsgiBundleApplicationContext  247 | Registering
>> BundleContext
>> >> as
>> >> a
>> >> >> >> bean
>> >> >> >> named bundleContext
>> >> >> >> 13:18:42,058 | DEBUG | xtenderThread-16 |
>> >> >> >> WaiterApplicationContextExecutor
>> >> >> >> |
>> >> >> >> WaiterApplicationContextExecutor  218 | Pre-refresh completed;
>> >> >> >> determining
>> >> >> >> dependencies...
>> >> >> >> 13:18:42,058 | DEBUG | xtenderThread-16 |
>> DependencyServiceManager
>> >> >> >> |
>> >> >> >> startup.DependencyServiceManager  253 | Discovered local
>> dependency
>> >> >> >> factories: []
>> >> >> >> 13:18:42,074 | DEBUG | xtenderThread-16 |
>> >> DefaultListableBeanFactory
>> >> >> >> |
>> >> >> >> ort.DefaultSingletonBeanRegistry  214 | Creating shared instance
>> of
>> >> >> >> singleton bean 'activemqservice'
>> >> >> >> 13:18:42,074 | DEBUG | xtenderThread-16 |
>> >> DefaultListableBeanFactory
>> >> >> >> |
>> >> >> >> ractAutowireCapableBeanFactory$1  383 | Creating instance of
>> bean
>> >> >> >> 'activemqservice'
>> >> >> >> 13:18:42,074 | DEBUG | xtenderThread-16 |
>> >> DefaultListableBeanFactory
>> >> >> >> |
>> >> >> >> stractAutowireCapableBeanFactory  459 | Eagerly caching bean
>> >> >> >> 'activemqservice' to allow for resolving potential circular
>> >> references
>> >> >> >> 13:18:42,105 | DEBUG | xtenderThread-16 |
>> >> CachedIntrospectionResults
>> >> >> >> |
>> >> >> >> beans.CachedIntrospectionResults  151 | Not strongly caching
>> class
>> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> [org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean]
>> >> >> >> because it is not cache-safe
>> >> >> >> 13:18:42,105 | DEBUG | xtenderThread-16 |
>> >> DefaultListableBeanFactory
>> >> >> >> |
>> >> >> >> stractAutowireCapableBeanFactory 1367 | Invoking
>> >> afterPropertiesSet()
>> >> >> on
>> >> >> >> bean with name 'activemqservice'
>> >> >> >> 13:18:42,105 | DEBUG | xtenderThread-16 |
>> >> DefaultListableBeanFactory
>> >> >> >> |
>> >> >> >> ractAutowireCapableBeanFactory$1  411 | Finished creating
>> instance
>> >> of
>> >> >> >> bean
>> >> >> >> 'activemqservice'
>> >> >> >> 13:18:42,105 | INFO  | xtenderThread-16 |
>> DependencyServiceManager
>> >> >> >> |
>> >> >> >> startup.DependencyServiceManager  278 | Adding OSGi service
>> >> dependency
>> >> >> >> for
>> >> >> >> importer [&activemqservice] matching OSGi filter
>> >> >> >>
>> >> [(objectClass=org.apache.activemq.camel.component.ActiveMQComponent)]
>> >> >> >>
>> >> >> >> Unfortunately, the osgi bundle who will consume the osgi:service
>> >> >> >>
>> >> >> >>        <osgi:reference id="activemqservice"
>> >> >> >>
>> interface="org.apache.activemq.camel.component.ActiveMQComponent"
>> >> />
>> >> >> >>
>> >> >> >> generates an error
>> >> >> >>
>> >> >> >> 13:18:42,105 | DEBUG | xtenderThread-16 |
>> DependencyServiceManager
>> >> >> >> |
>> >> >> >> startup.DependencyServiceManager  226 | 1 OSGi service
>> >> dependencies,
>> >> 1
>> >> >> >> unsatisfied (for beans [&activemqservice]) in
>> >> >> >>
>> OsgiBundleXmlApplicationContext(bundle=reportincident.interfaces,
>> >> >> >> config=osgibundle:/META-INF/spring/*.xml)
>> >> >> >> 13:18:42,105 | INFO  | xtenderThread-16 |
>> DependencyServiceManager
>> >> >> >> |
>> >> >> >> startup.DependencyServiceManager  232 |
>> >> >> >>
>> OsgiBundleXmlApplicationContext(bundle=reportincident.interfaces,
>> >> >> >> config=osgibundle:/META-INF/spring/*.xml) is waiting for
>> >> unsatisfied
>> >> >> >> dependencies [[&activemqservice]]
>> >> >> >> 13:18:42,105 | DEBUG | xtenderThread-16 |
>> >> >> >> WaiterApplicationContextExecutor
>> >> >> >> |
>> >> >> >> WaiterApplicationContextExecutor  257 | Registering service
>> >> dependency
>> >> >> >> dependencyDetector for
>> >> >> >>
>> OsgiBundleXmlApplicationContext(bundle=reportincident.interfaces,
>> >> >> >> config=osgibundle:/META-INF/spring/*.xml)
>> >> >> >> 13:18:42,121 | DEBUG | xtenderThread-16 |
>> DependencyServiceManager
>> >> >> >> |
>> >> >> >> startup.DependencyServiceManager  297 |
>> >> >> >>
>> OsgiBundleXmlApplicationContext(bundle=reportincident.interfaces,
>> >> >> >> config=osgibundle:/META-INF/spring/*.xml) has registered service
>> >> >> >> dependency
>> >> >> >> dependencyDetector with filter:
>> >> >> >>
>> (objectClass=org.apache.activemq.camel.component.ActiveMQComponent)
>> >> >> >>
>> >> >> >> What is the cause of this issue ? Do I have to change something
>> in
>> >> my
>> >> >> >> MANIFEST file ?
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> -----
>> >> >> >> Charles Moulliard
>> >> >> >> SOA Architect
>> >> >> >>
>> >> >> >> My Blog :  http://cmoulliard.blogspot.com/
>> >> >> >> http://cmoulliard.blogspot.com/
>> >> >> >> --
>> >> >> >> View this message in context:
>> >> >> >>
>> >> >>
>> >>
>> http://www.nabble.com/1-OSGi-service-dependencies%2C-1-unsatisfied-%28for-beans---activemqservice-%29-in-OsgiBundleXmlApplicationContext-tp22537014p22537014.html
>> >> >> >> Sent from the ServiceMix - User mailing list archive at
>> Nabble.com.
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Cheers,
>> >> >> > Guillaume Nodet
>> >> >> > ------------------------
>> >> >> > Blog: http://gnodet.blogspot.com/
>> >> >> > ------------------------
>> >> >> > Open Source SOA
>> >> >> > http://fusesource.com
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >> -----
>> >> >> Charles Moulliard
>> >> >> SOA Architect
>> >> >>
>> >> >> My Blog :  http://cmoulliard.blogspot.com/
>> >> >> http://cmoulliard.blogspot.com/
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/1-OSGi-service-dependencies%2C-1-unsatisfied-%28for-beans---activemqservice-%29-in-OsgiBundleXmlApplicationContext-tp22537014p22540154.html
>> >> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Cheers,
>> >> > Guillaume Nodet
>> >> > ------------------------
>> >> > Blog: http://gnodet.blogspot.com/
>> >> > ------------------------
>> >> > Open Source SOA
>> >> > http://fusesource.com
>> >> >
>> >> >
>> >>
>> >>
>> >> -----
>> >> Charles Moulliard
>> >> SOA Architect
>> >>
>> >> My Blog :  http://cmoulliard.blogspot.com/
>> >> http://cmoulliard.blogspot.com/
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/1-OSGi-service-dependencies%2C-1-unsatisfied-%28for-beans---activemqservice-%29-in-OsgiBundleXmlApplicationContext-tp22537014p22540577.html
>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> > ------------------------
>> > Open Source SOA
>> > http://fusesource.com
>> >
>> >
>>
>>
>> -----
>> Charles Moulliard
>> SOA Architect
>>
>> My Blog :  http://cmoulliard.blogspot.com/
>> http://cmoulliard.blogspot.com/
>> --
>> View this message in context:
>> http://www.nabble.com/1-OSGi-service-dependencies%2C-1-unsatisfied-%28for-beans---activemqservice-%29-in-OsgiBundleXmlApplicationContext-tp22537014p22541181.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
> 
> 


-----
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/1-OSGi-service-dependencies%2C-1-unsatisfied-%28for-beans---activemqservice-%29-in-OsgiBundleXmlApplicationContext-tp22537014p22554683.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to