In OSGi, missing classes can be down to which bundles are visible to 
the bundle doing the scanning.  In this case, whatever is doing the 
classpath scanning cannot see the bundle exporting your domain package.

 From a number of years back, I remember having to use 
eclipse-registerbuddy to solve a classloader visibility issue.  I'm not 
sure what the standard approach to this became.  A quick search doesn't 
deliver anything definitive for bundle-buddypolicy, which I suspect is 
the standardised mechanism.



On 13/05/2011 15:10, Jean-Pierre Bergamin wrote:
> I just could resove some more issues.
> First of all I had to excplicitely add an Import-Package directive in
> the template.mf of our project for packages that are not recognized by
> bundlor (as the one for the missing Neo4jConfiguration):
>
> Import-Package:
>   org.springframework.data.graph.neo4j.config;version="[1.1.0, 1.2.0)",
>   org.springframework.data.repository.support;version="[1.0.0, 1.2.0)",
>   org.springframework.transaction.aspectj;version="[3.0, 3.1)"
>
> I also had to put Import-Pacakge statements for cglib packages to the
> spring data neo4j bundle.
>
> The next problem I'm facing is that graph repositories cannot be
> injected, because they seem not to be created by SDG:
>
> [2011-05-13 16:06:29.786] region-dm-0<AG0000E>
> Application context creation failure for bundle
> 'com.example.neo4j.domain' version '0.0.1.BUILD-SNAPSHOT'.
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'serviceRepositoryImpl': Injection of
> autowired dependencies failed; nested exception is
> org.springframework.beans.factory.BeanCreationException: Could not
> autowire field: private com.example.neo4j.ServiceRepository
> com.example.neo4j.ServiceRepositoryImpl.serviceRepository; nested
> exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
> No matching bean of type [com.example.neo4j.ServiceRepository] found
> for dependency: expected at least 1 bean which qualifies as autowire
> candidate for this dependency. Dependency annotations:
> {@org.springframework.beans.factory.annotation.Autowired(required=true)}
>       at 
> org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
>       at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
>       at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
>       at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
>       at 
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
>       at 
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>       at 
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
>       at 
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
>       at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
>       at 
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
>       at 
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
>       at 
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
>       at 
> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>       at 
> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>       at 
> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
>       at 
> org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95)
>       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:662)
> Caused by: org.springframework.beans.factory.BeanCreationException:
> Could not autowire field: private com.example.neo4j.ServiceRepository
> com.example.neo4j.ServiceRepositoryImpl.serviceRepository; nested
> exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
> No matching bean of type [com.example.neo4j.ServiceRepository] found
> for dependency: expected at least 1 bean which qualifies as autowire
> candidate for this dependency. Dependency annotations:
> {@org.springframework.beans.factory.annotation.Autowired(required=true)}
>       at 
> org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
>       at 
> org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
>       at 
> org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
>       ... 18 common frames omitted
> Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
> No matching bean of type [com.example.neo4j.ServiceRepository] found
> for dependency: expected at least 1 bean which qualifies as autowire
> candidate for this dependency. Dependency annotations:
> {@org.springframework.beans.factory.annotation.Autowired(required=true)}
>       at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920)
>       at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789)
>       at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
>       at 
> org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
>       ... 20 common frames omitted
>
>
> Any ideas about that?
>
>
> Best regards,
> James
>
>
> 2011/5/13 Jean-Pierre Bergamin<jpberga...@gmail.com>:
>> SDG is using bundlor to generate the MANIFEST.MF file.I already fixed
>> the MANIFEST and the spring data neo4j bundle can now be resolved.
>>
>> But when the spring application context is loaded, the class
>> "org.springframework.data.graph.neo4j.config.Neo4jConfiguration"
>> cannot be found during bean postprocessing and aspectj magic (see
>> stacktrace below).
>> The class is available and exported. I checked that with clhas and
>> clexport on the Virgo console. Does maybe the kernel space of Virgo
>> has to to know the spring data neo4j bundle, because this aspectj
>> "enhancements" are performed there?
>>
>>
>> Best regards
>> James
>>
>> [2011-05-12 16:44:23.865] region-dm-14<AG0000E>
>> Application context creation failure for bundle
>> 'com.example.neo4j.domain' version '0.0.1.BUILD-SNAPSHOT'.
>> java.lang.IllegalStateException: Cannot load configuration class:
>> org.springframework.data.graph.neo4j.config.Neo4jConfiguration
>>         at 
>> org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:246)
>>         at 
>> org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:160)
>>         at 
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:479)
>>         at 
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:467)
>>         at 
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:395)
>>         at 
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:281)
>>         at 
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>>         at 
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)
>>         at 
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:214)
>>         at 
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:169)
>>         at 
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)
>>         at 
>> org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)
>>         at 
>> org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95)
>>         at 
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>         at 
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>
>>
>>
>> 2011/5/13 Nicolas Jouanin<nicolas.joua...@gmail.com>
>>> Well, at the minimum, it's only a question of adding some extra headers
>>> (Bundle-Symbolic, Export-Package; ...) in the package MANIFEST and this can
>>> be done automatically using the maven-bundle-plugin.
>>> You can have a look at Neo4j pom file or this second article :
>>> http://wiki.escapek.org/display/DEV/Create+OSGi+bundle+from+regular+jar+archive
>>>
>>>
>>>
>>> 2011/5/13 Michael Hunger<michael.hun...@neotechnology.com>
>>>
>>>> The issue is about Spring Data Graph not being correctly packaged as OSGi
>>>> bundle / compatible jar.
>>>>
>>>> And I have neither the knowledge nor the resources at the moment to fix
>>>> that.
>>>>
>>>> So if any one of you can help out with that, this would be most welcome.
>>>>
>>>> Thanks
>>>>
>>>> Michael
>>>>
>>>> Am 13.05.2011 um 11:42 schrieb Nicolas Jouanin:
>>>>
>>>>> Hi,
>>>>>
>>>>> I've written an article [1] showing how to run neo4j embedded database
>>>>> inside an OSGi container. Starting from that I think you can create a
>>>> bundle
>>>>> which uses this database to create the appropriate Spring data
>>>>> configuration. I suppose that spring-data-graph is packaged as a OSGi
>>>>> compatible jar, so using spring-dm too should do it.
>>>>>
>>>>>
>>>>> [1]
>>>> http://wiki.escapek.org/display/DEV/Neo4j+community+edition+installation
>>>>> 2011/5/13 Michael Hunger<michael.hun...@neotechnology.com>
>>>>>
>>>>>> I'm no expert in OSGi so I did just the minimal thing, adding bundlor
>>>>>> information to the maven build. This is obviously not successful enough.
>>>>>>
>>>>>> So I would be very happy I someone would pull spring data graph put in
>>>> the
>>>>>> correct OSGi information and send me a pull request.
>>>>>>
>>>>>> Cheers
>>>>>>
>>>>>> Michael
>>>>>>
>>>>>> Am 13.05.2011 um 11:26 schrieb Jean-Pierre Bergamin:
>>>>>>
>>>>>>> Dear neo4j community
>>>>>>>
>>>>>>> I'm so free to cross post a question to this list that I already posted
>>>>>> in
>>>>>>> the spring forum (
>>>>>>>
>>>> http://forum.springsource.org/showthread.php?109267-Spring-Data-Graph-in-OSGi-environment
>>>>>> ),
>>>>>>> since most of the SDG experts probably are subscribed to this list. ;-)
>>>>>>> Could anyone get spring data graph successfully up and running in an
>>>> OSGi
>>>>>>> container?
>>>>>>>
>>>>>>>
>>>>>>> Best regards,
>>>>>>> James

_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to