Announcement Announcement Module

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
Spring-OSGi : How to get a bean factory Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring-OSGi : How to get a bean factory

    Hi every one !

    I'm testing OSGi currently with Equinox and hopefully Spring-OSGi.

    I'm trying to put a database accessor into my main bundle class, and for this, i want to use Spring-OSGi.

    What I'm trying to achieve is to get the Spring BeanFactory and use it to load my database access bean, configured in the bundle-context.xml file, under the spring folder of the META-INF folder.

    I figured out by myself that I was supposed to use an OsgiBundleXmlApplicationContext object to get my factory and here is how i do it :

    String[] configLocations = new ApplicationContextConfiguration(context.getBundle()).getConfigurationLocations();
    bundleApplicationContext = new OsgiBundleXmlApplicationContext(context,configLocations);
    factory = bundleApplicationContext.getBeanFactory();
    But this always give me an exception when i call the getBeanFactory() method:

    java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
    Any idea someone?

    Thank you !

  • #2
    No one?
    I was expecting Spring community to be more helpful...
    I'm a little bit surprized.


    • #3
      I don't know if it will help, but there is a SpringOSGI google group, that seems to be pretty active (at last glance).


      • #4
        Also noticed this thread.


        • #5
          See the newly created Spring-DM forum:
          I recommend you read the Spring-DM documentation -
          In OSGi, there is no need to create the application context yourself - rather you rely on Spring-DM to create it for you.
          The problem in your case is that you haven't set up everything that the context needs.

          Hope this helps,