webSphere上新建了一个数据源并且测试成功,但应用程序中却报错Could not initalize DataSource java.lang.NullPointerException,详细信息如下:
[08-4-2 15:38:52:570 CST] 2ffb7dff SystemOut O [excuteProcess begin...]
[08-4-2 15:38:52:571 CST] 2ffb7dff SystemOut O 开始处理......
[08-4-2 15:38:52:571 CST] 2ffb7dff SystemOut O select ssdept.dptlevel,ssdept.dptname as inst_name, ssuser.usrname as tlr_name, ssuser.passwd as tlr_pwd, ssuser.status as tlr_stat, ssdptusr.dptid as instno from ssuser,ssdptusr,ssdept where ssdept.dptid = ssdptusr.dptid and ssuser.usrid = ssdptusr.usrid and ssuser.usrid = 'sup'
[08-4-2 15:38:52:587 CST] 2ffb7dff ConnectionFac I J2CA0122I: ÎÞ·¨¶¨Î»×ÊÔ´ÒýÓà jdbc/monitorPool£¬Òò´ËʹÓÃÏÂÁÐȱʡֵ£º[Resource-ref settings] res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)
[Other attributes]isCMP1_x: false (not CMP1.x)
isJMS: false (not JMS)[08-4-2 15:38:52:589 CST] 2ffb7dff SystemOut O 已经成功连接到数据源!
[08-4-2 15:38:52:595 CST] 2ffb7dff SystemOut O Could not initalize DataSourcejava.lang.NullPointerException
[08-4-2 15:38:52:596 CST] 2ffb7dff SystemOut O java.lang.NullPointerException
[08-4-2 15:38:52:596 CST] 2ffb7dff SystemOut O #####Mistake´íÎó####:½»Ò×´íÎó:java.lang.NullPointerException
[08-4-2 15:38:52:596 CST] 2ffb7dff SystemOut O #####Mistake´íÎó####:TransManager.loginResultProcess.java.lang.NullPointerException源码是这样的:
Try{
ctx = new InitialContext();
String homePath = System.getProperty("IsJBoss");
if (homePath != null
&& homePath.toUpperCase().equalsIgnoreCase("YES"))
ds = (DataSource) ctx.lookup("java:/OracleDS");
else
ds = (DataSource) ctx.lookup(JndiConfig.getJndiConfig());
if (ds == null)
System.out.println("Could Not init DataSource!");
else{
System.out.println("已经成功连接到数据源!");
conn = ds.getConnection();
}
} catch (NamingException e) {
e.printStackTrace();
pub.wExceptionLog("ConnectionFactory", e, "0000", "0000");
setMsg("Could not initalize DataSource:" + e);
setSucc(false);
return null;
} catch (Exception e) {
e.printStackTrace();
pub.wExceptionLog("ConnectionFactory", e, "0000", "0000");
setMsg("Could not initalize DataSource" + e);
setSucc(false);
return null;
}
望大虾指点迷津!
[08-4-2 15:38:52:570 CST] 2ffb7dff SystemOut O [excuteProcess begin...]
[08-4-2 15:38:52:571 CST] 2ffb7dff SystemOut O 开始处理......
[08-4-2 15:38:52:571 CST] 2ffb7dff SystemOut O select ssdept.dptlevel,ssdept.dptname as inst_name, ssuser.usrname as tlr_name, ssuser.passwd as tlr_pwd, ssuser.status as tlr_stat, ssdptusr.dptid as instno from ssuser,ssdptusr,ssdept where ssdept.dptid = ssdptusr.dptid and ssuser.usrid = ssdptusr.usrid and ssuser.usrid = 'sup'
[08-4-2 15:38:52:587 CST] 2ffb7dff ConnectionFac I J2CA0122I: ÎÞ·¨¶¨Î»×ÊÔ´ÒýÓà jdbc/monitorPool£¬Òò´ËʹÓÃÏÂÁÐȱʡֵ£º[Resource-ref settings] res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)
[Other attributes]isCMP1_x: false (not CMP1.x)
isJMS: false (not JMS)[08-4-2 15:38:52:589 CST] 2ffb7dff SystemOut O 已经成功连接到数据源!
[08-4-2 15:38:52:595 CST] 2ffb7dff SystemOut O Could not initalize DataSourcejava.lang.NullPointerException
[08-4-2 15:38:52:596 CST] 2ffb7dff SystemOut O java.lang.NullPointerException
[08-4-2 15:38:52:596 CST] 2ffb7dff SystemOut O #####Mistake´íÎó####:½»Ò×´íÎó:java.lang.NullPointerException
[08-4-2 15:38:52:596 CST] 2ffb7dff SystemOut O #####Mistake´íÎó####:TransManager.loginResultProcess.java.lang.NullPointerException源码是这样的:
Try{
ctx = new InitialContext();
String homePath = System.getProperty("IsJBoss");
if (homePath != null
&& homePath.toUpperCase().equalsIgnoreCase("YES"))
ds = (DataSource) ctx.lookup("java:/OracleDS");
else
ds = (DataSource) ctx.lookup(JndiConfig.getJndiConfig());
if (ds == null)
System.out.println("Could Not init DataSource!");
else{
System.out.println("已经成功连接到数据源!");
conn = ds.getConnection();
}
} catch (NamingException e) {
e.printStackTrace();
pub.wExceptionLog("ConnectionFactory", e, "0000", "0000");
setMsg("Could not initalize DataSource:" + e);
setSucc(false);
return null;
} catch (Exception e) {
e.printStackTrace();
pub.wExceptionLog("ConnectionFactory", e, "0000", "0000");
setMsg("Could not initalize DataSource" + e);
setSucc(false);
return null;
}
望大虾指点迷津!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货