tomcat+安全

05-10-25 luowei
我在jb+tomcat中实现安全,jdbc也加进去了,但是总是报错,

javax.naming.NameNotFoundException: Name TestDB is not bound in this Context

配置如下

<?xml version="1.0" encoding="UTF-8"?>
<Server debug="0" port="8084" shutdown="SHUTDOWN">
  <Service name="Catalina">
    <Connector acceptCount="10" connectionTimeout="60000" debug="0" maxThreads="75" minSpareThreads="5" port="8083"/>
    <Engine debug="0" defaultHost="localhost" name="Catalina">
      <Host appBase="D:\myjava\jaastest\Tomcat\webapps" autoDeploy="false" debug="0" deployXML="false" name="localhost" unpackWARs="false">
        <Context debug="0" docBase="D:\myjava\jaastest\jaastest" path="/jaastest" reloadable="true" workDir="D:\myjava\jaastest\Tomcat\work\jaastest">
				  <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"/>
  <ResourceParams name="jdbc/TestDB">
    <parameter>
      <name>factory</name>
      <!--DBCP Basic Datasource Factory -->
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>  
    <parameter>
      <name>driverClassName</name>
      <!-- Database Driver Class Name -->
      <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <!-- Database Address -->
      <value>jdbc:oracle:thin:@localhost:1521:LUOPAN</value>
    </parameter>
    <parameter>
      <name>username</name>
      <!-- Database User Name -->
      <value>LUOWEI</value>
    </parameter>
    <parameter>
      <name>password</name>
      <!-- User Password -->
      <value>131421</value>
    </parameter>  
    <parameter>
      <name>maxActive</name>
      <!-- Maximum number of DB connections in pool.Set to 0 for no limit. -->
      <value>20</value>
    </parameter>
    <parameter>
      <name>maxIdle</name>
      <!-- Maximum number of idle DB connections to retain in pool.Set to 0 for no limit. -->
      <value>100</value>
    </parameter>
    <parameter>
      <name>maxWait</name>
      <!-- Maximum time to wait for a DB connection to become available in ms.An exception is thrown if this timeout is exceeded.Set to -1 to wait indefinitely. -->
      <value>20</value>
    </parameter> 
    
  </ResourceParams>

<Realm className="org.apache.catalina.realm.DataSourceRealm" debug="99" dataSourceName="jdbc/TestDB"          userTable="MYUSER" userNameCol="USERID" userCredCol="PASSWORD" userRoleTable="MYROLE" roleNameCol="ROLENAME"/>
        </Context>
      </Host>
    </Engine>
  </Service>
</Server>
<p>

banq
2005-10-25 15:42
你的JNDI配置是jdbc/TestDB,而不是TestDB

猜你喜欢