2 Replies Latest reply on Jan 2, 2008 5:09 AM by eoinbyrne

    Using @In to inject a reference to a bean in a different Jar

    eoinbyrne

      Hi guys

      I have an ear file containing 2 jars as ejb modules. In jar A I have a bean which extends a pojo in Jar B and uses the @In tag to inject a reference to an ejb in jar b. It seems that the reference is comming out as null.

      For the In tag itself I am specifiing create=true and required=true.

      Is there some way to inject a reference to a bean in a different jar while still using annotations?

      Thanks
      Eoin

        • 1. Re: Using @In to inject a reference to a bean in a different
          thejavafreak

          Have you annotated your bean B with @Name yet?

          During initialization Seam will make beans with @Name as components and you should be able to inject it eventhough it is on several jars. Although I havent been in your situation before and haven't tried it yet.

          • 2. Re: Using @In to inject a reference to a bean in a different
            eoinbyrne

            Sorry for the late responce - just got back from the holiday break.

            I have both beans annotated with @Name however the pojo is not. Looking over the initial post it looks a little cryptic so I'll try to clarify it a little

            In Jar A:
            Pojo containing common code
            Bean 1 - Stateless Bean using the @Name annotation

            In Jar B:
            Bean 2 extends Pojo - its stateful and named, it contains an instance var (Bean 1) which is injected using the @In annotation but the refrence is null at runtime.

            Initially everything was in one jar and Bean 2 was stand alone and it worked fine but now I'd like to seperate out some of the common stuff so I can reuse it in another project.

            From what I can see in the documentation what I am trying to do should work fine, both beans should be in the same application scope because they are both living in the same ear file.