Results 1 to 5 of 5

Thread: Spring-OSGi : How to get a bean factory

  1. #1

    Unhappy 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 :

    Code:
    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:

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

    Thank you !

  2. #2

    Default

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

  3. #3
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I don't know if it will help, but there is a SpringOSGI google group, that seems to be pretty active (at last glance).
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  5. #5
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    See the newly created Spring-DM forum:http://forum.springframework.org/forumdisplay.php?f=43.
    I recommend you read the Spring-DM documentation - http://static.springframework.org/os...eference/html/.
    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,
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •