Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
5 replies Latest Post - ‏2013-03-15T21:49:12Z by Jacek_Laskowski
Jacek_Laskowski
Jacek_Laskowski
133 Posts
ACCEPTED ANSWER

Pinned topic Is blueprint:comp namespace lookup supported?

‏2012-09-27T22:18:11Z |
Hi,

I wonder whether blueprint:comp is supported in Liberty Profile? Can I use @Resource for Blueprint-managed beans and/or services? Is there any other way than via osgi-bundlecontext?

Jacek
Japila :: verba docent, exempla trahunt
  • Jacek_Laskowski
    Jacek_Laskowski
    133 Posts
    ACCEPTED ANSWER

    Re: Is blueprint:comp namespace lookup supported?

    ‏2012-09-29T19:29:09Z  in response to Jacek_Laskowski
    Hi,

    I've been studying the topic and found that the following works in a servlet:
    
    ctx = 
    
    new InitialContext(); MyBlueprintBean mbb = (MyBlueprintBean) ctx.lookup(
    "blueprint:comp/MyBlueprintBeanBean");
    

    When I however use the following @Resource-annotated field, the injection doesn't work.
    
    @Resource(lookup = 
    "blueprint:comp/MyBlueprintBeanBean") MyBlueprintBean myBlueprintBean;
    

    Why?! It works fine in WAS (see Developing OSGi applications with Java EE 6 - Web Application Bundles in IBM WebSphere Application Server V8). I guess that @Resource and the lookup in the code are handled by the same code (although I can understand the processing happens in different stages of the servlet lifecycle).

    I desperately need any help or pointers to let me carry on.

    Jacek
    Japila :: verba docent, exempla trahunt
    • MarkN
      MarkN
      10 Posts
      ACCEPTED ANSWER

      Re: Is blueprint:comp namespace lookup supported?

      ‏2012-10-01T12:51:03Z  in response to Jacek_Laskowski
      Hi Jacek,
      Thank you for your notes and questions. You're quite right in that the direct JNDI lookup form works, and the @Resource(lookup=blueprint:comp/compID) form does not work correctly in the Liberty profile. I've raised a defect to track this. Many thanks again,

      Regards,
      Mark Nuttall
      • Jacek_Laskowski
        Jacek_Laskowski
        133 Posts
        ACCEPTED ANSWER

        Re: Is blueprint:comp namespace lookup supported?

        ‏2012-10-01T13:37:13Z  in response to MarkN
        Hi Mark,

        It's so nice to find your answer! I've been spending days trying to nail it down and even used instance initialization blocks before and after the @Resource field to see when the reference to the Blueprint container changes. It didn't, but the code kept failing. I think I'd have spent more days on it if you had not responded. You saved me a lot of time! :) Thanks!

        Jacek
        Japila :: verba docent, exempla trahunt
      • Jacek_Laskowski
        Jacek_Laskowski
        133 Posts
        ACCEPTED ANSWER

        Re: Is blueprint:comp namespace lookup supported?

        ‏2013-02-11T20:44:27Z  in response to MarkN
        Hi,

        Has this been fixed in the latest Beta?

        Jacek
        Japila :: verba docent, exempla trahunt
        • Jacek_Laskowski
          Jacek_Laskowski
          133 Posts
          ACCEPTED ANSWER

          Re: Is blueprint:comp namespace lookup supported?

          ‏2013-03-15T21:49:12Z  in response to Jacek_Laskowski
          Hi,

          Just to bring it up again for your consideration to cook a fix for the next release. I'd be so much happier with the feature available. Possible?

          Jacek
          Japila :: verba docent, exempla trahunt