glassfish
  1. glassfish
  2. GLASSFISH-11727

[Embedded] Injected habitat is stale in instances created by the 2nd embedded server in the same VM

    Details

    • Issuezilla Id:
      11,727

      Description

      I've done a simple test project to inspect this and the results a rather
      interesting.

      [code]
      @Stateless
      @TransactionManagement(TransactionManagementType.CONTAINER)
      public class AnBean {

      @PersistenceContext(unitName="testPU")
      private EntityManager em;

      public void addAnEntity(String someData)

      { AnEntity e = new AnEntity(); e.setSomeData(someData); em.persist(e); }

      public AnEntity getAnEntity(String someData)

      { Query q = em.createNamedQuery("AnQuery"); q.setParameter("data", someData); return (AnEntity) q.getSingleResult(); }

      }
      [/code]

      [code]
      @Entity
      @NamedQuery(name="AnQuery", query="select e from AnEntity e where e.someData =
      :data")
      public class AnEntity implements Serializable {

      @Id
      @GeneratedValue
      private Long id;
      private String someData;

      public String getSomeData()

      { return someData; }

      public void setSomeData(String someData)

      { this.someData = someData; }

      public Long getId()

      { return id; }

      public void setId(Long id)

      { this.id = id; }

      }
      [/code]

      [code]
      public class AnBeanTest {

      static EJBContainer ejbCon;

      private AnBean bean;

      @Before
      public void initEjb() throws Exception

      { ejbCon = EJBContainer.createEJBContainer(); Context ctx = ejbCon.getContext(); bean = (AnBean) ctx.lookup("java:global/classes/AnBean"); }

      @Test
      public void beanTestA()

      { //this one is successfull bean.addAnEntity("xxx"); bean.getAnEntity("xxx"); }

      @Test
      public void beanTestB()

      { //this one faild bean.addAnEntity("xxx"); bean.getAnEntity("xxx"); }

      @After
      public void closeEjb()

      { bean = null; ejbCon.close(); }

      }
      [/code]

      Test A is successful and the exactly same test B fails with NoResultException.

      This is reproducible on project's created both in netbeans and eclipse.

      A more detail discussion about this is on:
      http://forums.java.net/jive/thread.jspa?messageID=393436

        Activity

        Hide
        Alexis MP added a comment -

        Can you explain the keyword to the reporter and CC list?

        Show
        Alexis MP added a comment - Can you explain the keyword to the reporter and CC list?
        Hide
        Pavel Bucek added a comment -

        I'd like to know the explanation too, this issue prevents us to use embedded glassfish in unit and/or
        integration test. I think this is (or should be) important usecase for embedded.

        Show
        Pavel Bucek added a comment - I'd like to know the explanation too, this issue prevents us to use embedded glassfish in unit and/or integration test. I think this is (or should be) important usecase for embedded.
        Hide
        Bhavanishankar added a comment -

        Based on the demands for this issue, reconsidering this for ms7.

        Show
        Bhavanishankar added a comment - Based on the demands for this issue, reconsidering this for ms7.
        Hide
        Bhavanishankar added a comment -

        This issue has been fixed.

        Show
        Bhavanishankar added a comment - This issue has been fixed.
        Hide
        Bhavanishankar added a comment -

        Fix available in ms7.

        Show
        Bhavanishankar added a comment - Fix available in ms7.

          People

          • Assignee:
            Bhavanishankar
            Reporter:
            walec51
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: