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

InitialContext must be created twice to be correctly initialized

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.1
    • None
    • None
    • None
    • windows 2000, java 1.5

    Description

      The following test case illustrates the problem. I must call twice new InitialContext(configuration) to be able to lookup the java:/openejb folder, otherwise a NameNotFoundException is thrown. I call OpenEJB.destroy() in order to reinitialize OpenEJB context between the two tests calls.

      @Test
      public void testJNDI_OK() throws Exception

      { Properties configuration = new Properties(); configuration.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); configuration.put("MyDatasource", "new://Resource?type=DataSource"); InitialContext context = new InitialContext(configuration); context = new InitialContext(configuration); Assert.assertNotNull(context .lookup("java:/openejb/Resource/MyDatasource")); OpenEJB.destroy();// Otherwise testJNDIFail won't fail }

      @Test
      public void testJNDI_Fail() throws Exception

      { // A NameNotFoundException is thrown Properties configuration = new Properties(); configuration.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); configuration.put("MyDatasource", "new://Resource?type=DataSource"); InitialContext context = new InitialContext(configuration); Assert.assertNotNull(context .lookup("java:/openejb/Resource/MyDatasource")); OpenEJB.destroy(); }

      Attachments

        Activity

          People

            Unassigned Unassigned
            vmathon Vincent MATHON
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: