Uploaded image for project: 'OpenEJB'
  1. OpenEJB
  2. OPENEJB-1103

Inject fields in subclasses that extend class with LocalClient annotation.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.1.2
    • None
    • None
    • None
    • openejb-core 3.1.2
      Maven version: 2.0.9
      Java version: 1.5.0_12
      OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
      testng 5.8

    Description

      I am not sure whether this is an improvement or a bug. The method org.apache.openejb.client.inject(Object) will detect whether a class or super class has the annotation LocalClient. In case only the super class is annotated the fields of the subclass are not injected.

      @LocalClient
      public abstract class MyBaseClass {
      Context context;

      @BeforeClass
      public void initContainer()

      { //do stuff Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); context = new InitialContext(props); }

      }

      public class MyTest extends MyBaseClass {
      @EJB
      MyEjbLocal myEjbBean;

      @Test
      public void testMyEjb()

      { Assert.assertNotNull(myEjbBean, "Expected a MyEjbLocal"); }

      }

      The above test will fail. I am using testng but this will also work with junit 4. My first though was that this mechanism should be working, but either my assumptions are wrong or the code could be improved.

      Attachments

        Activity

          People

            Unassigned Unassigned
            vdweij Aede van der Weij
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: