Results 1 to 3 of 3

Thread: @PostConstruct not triggered

  1. #1
    Join Date
    Jan 2009
    Location
    Frankfurt, Germany
    Posts
    18

    Default @PostConstruct not triggered

    I have a FactoryBean implementation and I use @PostConstruct to trigger off the resolution of some complex dependencies and generate a bean when required.

    This all works fine in the development environment but fails to trigger when running in the OSGi container (Equinox). Changing the bean definition to have an init-method value equal to the method name sitting under the @PostConstruct makes everything run normally in the OSGi container.

    I know that I include jsr250-api-1.0.jar in my project for the javax.annotation pacakges. I am running the OSGi container with JDK6 U11.

    Must I make some additional steps with spring related bundles to ensure @PostConstruct annotations are detected for normal Spring bean lifecycle management? Or is it just a case of turning jsr250-api-1.0.jar into a bundle and loading that into the OSGi container ... I had been thinking the container would be supplying the javax packages already?!?

  2. #2
    Join Date
    Jan 2009
    Location
    Frankfurt, Germany
    Posts
    18

    Default

    Still not making sense. The OSGi system bundle exports all the core Java packages including javax.annotation and it is successfully used by spring annotations bundle

    > packages 0
    javax.annotation; version="0.0.0"<System Bundle [0]>
    file:///C|/dev/spring-osgi-1.1.2/lib/spring-context-2.5.5.jar [1035] imports

    Looking at the spring-context-2.5.5.jar bundle MANIFEST.MF shows a manual import of javax.annotation. So I am guessing any bundle using a javax package must following the same pattern. So I am now guessing core java.* packages require no explicit import but javax.* packages do.

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

    Default

    I think there is an issue with Spring 2.5.5 artifacts in that it requires a versioned javax.annotation. The system packages have the 0.0.0 so if 1.0 is required, the two won't match.
    Try 2.5.6 and double check the imports wiring to Spring and your bundle to make sure you have the same version since otherwise the annotations won't be picked up.
    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
  •