在配置tomcat6.0连接池时:出现了javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as  an applet parameter, or in an application resource file:  java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.dbUtil.DbUtil.getcon(DbUtil.java:21)
at com.dbUtil.T.main(T.java:11)
的错误:
下面是关于tomcat/conf/context.xml的配置:
    <Resource
name="jdbc/sqlserver" 
auth="Container" 
type="javax.sql.DataSource"
maxActive="50"
maxIdle="30" 
maxWait="10000" 
logAbandoned="true" 
username="sa" 
password="SQL2005" 
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://localhost:1433;databasename=blog"/>然后是web。xml的配置:
<description>DBConnection</description>
<res-ref-name>jdbc/sqlserver</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref> 然后是使用:
Context ctx = new InitialContext();
//获取连接池对象
DataSource dSource = (DataSource) ctx.lookup("java:comp/env/jdbc/sqlserver");
con = dSource.getConnection();
出错是DataSource dSource = (DataSource) ctx.lookup("java:comp/env/jdbc/sqlserver");
这行代码