0

我很常见java naming exception,但是,很明显hashtable是空{},这意味着什么?

 javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {} [Root exception is java.lang.NullPointerException]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:243)
at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:318)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:348)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:428)
at javax.naming.InitialContext.lookup(InitialContext.java:436)
......
Caused by: java.lang.NullPointerException
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
... 16 more

应用程序是坐着的Websphere 7,JNDI with v4datasource 代码是这样的,没什么特别的

    InitialContext ctx = null;

    if(someCondition==true){
        ctx=new InitialContext();
    }

if( ctx != null ) {
    try {
        String jdbcDsName = getJdbcDSName();
        ds = (DataSource) ctx.lookup(jdbcDsName);
    } catch ( NamingException ne) {
        e.printStackTrace();
    }
}
4

0 回答 0