1 Reply Latest reply on Jan 16, 2009 7:06 PM by 800409

    InitialContext Lookups

    800409
      I have a new application that I can't get an InitialContext.lookup to work for.

      I've copied the code identically from another application that runs on the same server using the same variables in the lookup. The only difference is that the original one that works extends the LookupDispatchAction and the new one extends javax.servlet.http.HttpServlet

      The code from both is
      c = ((DataSource) (new InitialContext().lookup("java:comp/env/"
                          + servlet.getServletContext().getInitParameter(
                                  "DB2_JNDI_NAME")))).getConnection(userName,
                          password);
      except for the one that doesn't work the servlet variable is not available so I use this. or nothing at all.

      If I break it appart the getInitParameter works for both, it is just the .lookup method that fails with
       javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
      [1/16/09 9:49:13:131 CST] 00000026 SystemErr     R      at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1767)
      [1/16/09 9:49:13:131 CST] 00000026 SystemErr     R      at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1083)
      [1/16/09 9:49:13:131 CST] 00000026 SystemErr     R      at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:991)
      [1/16/09 9:49:13:131 CST] 00000026 SystemErr     R      
      I've copied all the context-param, init-param, and resource-ref's from the web.xml, so I'm at a loss as to why this won't work.

      O yea, the following line of code also does not work the same. Returns a string in the original one, returns null in the new one.

      String racf_resource = servlet.getInitParameter("RACF_GROUP_MAINT");