2010-01-07 43 views

回答

0

很模糊的問題,所以是很模糊的答案...這裏是如何獲得Context

Context ctx = null; 
    Hashtable ht = new Hashtable(); 
    ht.put(Context.INITIAL_CONTEXT_FACTORY, 
     "weblogic.jndi.WLInitialContextFactory"); 
    ht.put(Context.PROVIDER_URL, 
     "t3://localhost:7001"); 

    try { 
    ctx = new InitialContext(ht); 
    // Use the context in your program 
    } 
    catch (NamingException e) { 
    // a failure occurred 
    } finally { 
    try { 
     ctx.close(); 
    } catch (Exception e) { 
     // a failure occurred 
    } 
    } 

你需要在類路徑wl-client.jar。更多詳情請參見Programming WebLogic JNDI

PS:我沒有吞嚥異常,文檔樣本:)