Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-1889

@EJB injection into @Service bean leads to NullPointerException when injected bean is redepolyed

    XMLWordPrintable

Details

    • Workaround Exists
    • Hide

      Annotating the "A" interface with @LocalBinding and setting "B" injected mappedName to this value allows redeployment of "A". However, "B"'s lifecycle will no longer be tied to "A". That is, "B" will not stop when you undeploy "A"

      Show
      Annotating the "A" interface with @LocalBinding and setting "B" injected mappedName to this value allows redeployment of "A". However, "B"'s lifecycle will no longer be tied to "A". That is, "B" will not stop when you undeploy "A"

    Description

      I have two @Service jars, service "A" and "B" where "B" injects an instance of "A" using the @EJB annotation with a mappedName attribute set to the default jndi location of A ("EJBTestAService/local" in the example provided.) When deployed, they work fine. But, if "A" is redeployed, access to "B" fails due to a NullPointerException, the reference to "A" is null.

      To reproduce with the attached code:

      1.) Set jboss.home property in build.xml
      2.) Start EAP 5, beta
      3.) ant deployAll (will compile and deploy the two jars)
      4.) ant run (runs test client against "B")
      5.) ant undeployA (Should see "B" stop, then "A" stop)
      6.) ant deployA (Should see "A" start, then "B" start)
      7.) ant run (will fail with NullPointerException as root cause)

      Attachments

        Issue Links

          Activity

            People

              rhn-engineering-cdewolf Carlo de Wolf
              rhn-support-miclark Mike Clark
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: