补发 server.xml配置,不知道是否和这个有关, 其中 <Connector port="8080" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" /> 是新加的,其余的都是默认安装的内容server.xml<!-- Server Configuration File for Tomcat 5 on Debian You can find a more complete example in /usr/share/doc/tomcat5/examples/ --><!-- Note that component elements are nested corresponding to their parent-child relationships with each other --><!-- A "Server" is a singleton element that represents the entire JVM, which may contain one or more "Service" instances. The Server listens for a shutdown command on the indicated port. Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" or "Loggers" at this level. --><Server port="8005" shutdown="SHUTDOWN" debug="0"> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" debug="0"/> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" debug="0"/> <!-- Global JNDI resources --> <GlobalNamingResources> <!-- Test entry for demonstration purposes --> <Environment name="simpleValue" type="java.lang.Integer" value="30"/> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved"> </Resource> <ResourceParams name="UserDatabase"> <parameter> <name>factory</name> <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value> </parameter> <parameter> <name>pathname</name> <value>conf/tomcat-users.xml</value> </parameter> </ResourceParams> </GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" (and therefore the web applications visible within that Container). Normally, that Container is an "Engine", but this is not required. Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" or "Loggers" at this level. --> <!-- Define the Tomcat Stand-Alone Service --> <Service name="Tomcat-Standalone"> <Connector port="8080" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" /> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Each Connector passes requests on to the associated "Container" (normally an Engine) for processing. --> <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8180 --> <Connector className="org.apache.coyote.tomcat5.CoyoteConnector" port="8180" minProcessors="5" maxProcessors="75" enableLookups="true" acceptCount="10" debug="0" connectionTimeout="20000" useURIValidationHack="false" /> <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 --> <Connector className="org.apache.coyote.tomcat5.CoyoteConnector" port="8009" minProcessors="5" maxProcessors="75" enableLookups="true" acceptCount="10" debug="0" connectionTimeout="20000" useURIValidationHack="false" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/> <!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). --> <!-- Define the top level container in our container hierarchy The name must be Catalina for correct function of the admin webapp --> <Engine name="Catalina" defaultHost="localhost" debug="0"> <!-- Global logger unless overridden at lower levels --> <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_" suffix=".log" timestamp="true"/> <!-- Because this Realm is here, an instance will be shared globally --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" debug="0" resourceName="UserDatabase"/> <!-- Define the default virtual host --> <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- Logger shared by all Contexts related to this virtual host. --> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_" suffix=".log" timestamp="true"/> </Host> </Engine> </Service> </Server>
更正
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
....
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/DBTest</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
<ResourceLink name="jdbc/DBTest" global="jdbc/sqlserver" type="javax.sql.DataSource"/>
</Context>
而且我觉得 ResourceLink 是在Context中引用 在 server.xml配置全局Resource对象。
把这句改为<res-ref-name>java:comp/env/jdbc/DBTest</res-ref-name>试试看
试过了,还是一样的错误补充一点 同样的配置和程序,在window 下的tomcat 和 eclipse wtp环境下都是可以的,在ubuntu linux环境下就报这个错误。
其中
<Connector port="8080"
maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
是新加的,其余的都是默认安装的内容server.xml<!-- Server Configuration File for Tomcat 5 on Debian
You can find a more complete example in /usr/share/doc/tomcat5/examples/
--><!-- Note that component elements are nested corresponding to their
parent-child relationships with each other --><!-- A "Server" is a singleton element that represents the entire JVM,
which may contain one or more "Service" instances. The Server
listens for a shutdown command on the indicated port. Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
--><Server port="8005" shutdown="SHUTDOWN" debug="0"> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/> <!-- Global JNDI resources -->
<GlobalNamingResources> <!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/> <!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams> </GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" (and therefore the web applications visible
within that Container). Normally, that Container is an "Engine",
but this is not required. Note: A "Service" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
--> <!-- Define the Tomcat Stand-Alone Service -->
<Service name="Tomcat-Standalone">
<Connector port="8080"
maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" /> <!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Each Connector passes requests on to the
associated "Container" (normally an Engine) for processing.
--> <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8180 -->
<Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
port="8180" minProcessors="5" maxProcessors="75"
enableLookups="true" acceptCount="10" debug="0"
connectionTimeout="20000" useURIValidationHack="false" /> <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" acceptCount="10" debug="0"
connectionTimeout="20000" useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/> <!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host). --> <!-- Define the top level container in our container hierarchy
The name must be Catalina for correct function of the admin webapp -->
<Engine name="Catalina" defaultHost="localhost" debug="0"> <!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_" suffix=".log" timestamp="true"/> <!-- Because this Realm is here, an instance will be shared globally -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/> <!-- Define the default virtual host -->
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"> <!-- Logger shared by all Contexts related to this virtual host. -->
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_" suffix=".log"
timestamp="true"/> </Host> </Engine> </Service>
</Server>
...
<ResourceLink name="jdbc/DBTest" global="jdbc/DBTest" type="javax.sql.DataSource"/>
</Context>
绝对OK,tomcat5.5以上的版本一定要以在context.xml中加入<ResourceLink ……这句话的
http://lists.mysql.com/commits/1884
多谢各位的热心关注,马上送分