【发布时间】:2015-06-20 18:49:30
【问题描述】:
我在C:// 中解压缩了一个二进制发行版,但我很难让JDBC 和JDNI 正常工作...它没有从我的数据库中获取数据,所以我认为我没有合适的文件的配置。
奇怪的是,
<c:forEach var="cartItem" items="${cart.items}" varStatus="iter"/>可以看到数据,但<c:forEach var="product" items="${categoryProducts}" varStatus="iter"/>没有数据显示
编辑
server.xml: /conf
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<!-- TomEE plugin for Tomcat -->
<Listener className="org.apache.tomee.catalina.ServerListener"/>
<Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener"/>
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1"
redirectPort="8443"/>
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the BIO implementation that requires the JSSE
style configuration. When using the APR/native implementation, the
OpenSSL style configuration is required as described in the APR/native
documentation -->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" xpoweredBy="false" server="Apache TomEE" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
<!-- 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).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine defaultHost="localhost" name="Catalina">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/>
</Host>
</Engine>
</Service>
</Server>
context.xml: /META-INF
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/Application">
<!-- maxActive: Maximum number of database connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to -1 for no limit.
-->
<!-- maxIdle: Maximum number of idle database connections to retain in pool.
Set to -1 for no limit. See also the DBCP documentation on this
and the minEvictableIdleTimeMillis configuration parameter.
-->
<!-- maxWait: Maximum time to wait for a database connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<!-- username and password: MySQL username and password for database connections -->
<!-- driverClassName: Class name for the old mm.mysql JDBC driver is
org.gjt.mm.mysql.Driver - we recommend using Connector/J though.
Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver.
-->
<!-- url: The JDBC connection url for connecting to your MySQL database.
-->
<resources>
<jdbc-resource enabled="true" jndi-name="jdbc/application" object-type="user" pool-name="ApplicationPool">
<description/>
</jdbc-resource>
<jdbc-connection-pool allow-non-component-callers="false"
associate-with-thread="false"
connection-creation-retry-attempts="0"
connection-creation-retry-interval-in-seconds="10"
connection-leak-reclaim="false"
connection-leak-timeout-in-seconds="0"
connection-validation-method="auto-commit"
datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
fail-all-connections="false"
idle-timeout-in-seconds="300"
is-connection-validation-required="false"
is-isolation-level-guaranteed="true"
lazy-connection-association="false"
lazy-connection-enlistment="false"
match-connections="false"
max-connection-usage-count="0"
max-pool-size="32"
max-wait-time-in-millis="60000"
name="ApplicationPool"
non-transactional-connections="false"
pool-resize-quantity="2"
res-type="javax.sql.ConnectionPoolDataSource"
statement-timeout-in-seconds="-1"
steady-pool-size="8"
validate-atmost-once-period-in-seconds="0"
wrap-jdbc-objects="false">
<description>Connects to the database</description>
<property name="URL" value="jdbc:mysql://localhost:3306/application?zeroDateTimeBehavior=convertToNull"/>
<property name="User" value="root"/>
<property name="Password" value="password"/>
</jdbc-connection-pool>
</resources>
</Context>
第二次编辑
我在 $CATALINA_HOME/lib 中添加了这些 jar:
- javaee-api-6.0-6.jar
- javax.servlet.jsp.jstl-1.2.1.jar
没有 WAR 文件被分解,因为目前我在 Netbeans 8.0.2 中进行本地开发,但如果它与部署相同,服务器会自动在Web Applications 下创建一个副本(如果相同,请原谅我的无知) .
今天的日志:
WARNING: No rules found matching 'Context/resources/jdbc-resource/description'.
Jun 23, 2015 8:10:12 PM org.apache.tomcat.util.digester.Digester endElement
WARNING: No rules found matching 'Context/resources/jdbc-resource'.
Jun 23, 2015 8:10:12 PM org.apache.tomcat.util.digester.Digester endElement
WARNING: No rules found matching 'Context/resources/jdbc-connection-pool/description'.
Jun 23, 2015 8:10:12 PM org.apache.tomcat.util.digester.Digester endElement
WARNING: No rules found matching 'Context/resources/jdbc-connection-pool/property'.
Jun 23, 2015 8:10:12 PM org.apache.tomcat.util.digester.Digester endElement
WARNING: No rules found matching 'Context/resources/jdbc-connection-pool/property'.
Jun 23, 2015 8:10:12 PM org.apache.tomcat.util.digester.Digester endElement
WARNING: No rules found matching 'Context/resources/jdbc-connection-pool/property'.
Jun 23, 2015 8:10:12 PM org.apache.tomcat.util.digester.Digester endElement
WARNING: No rules found matching 'Context/resources/jdbc-connection-pool'.
Jun 23, 2015 8:10:12 PM org.apache.tomcat.util.digester.Digester endElement
WARNING: No rules found matching 'Context/resources'.
Jun 23, 2015 8:10:15 PM org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: C:\Users\PC\Documents\NetBeansProjects\Mebzone\build\web
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.PagerTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.ParamTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.ItemTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.IndexTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.FirstTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.PrevTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.PageTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.PagesTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.NextTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.LastTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.SkipTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.PagerTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.ParamTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.ItemTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.IndexTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.FirstTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.PrevTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.PageTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.PagesTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.NextTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.LastTag
Jun 23, 2015 8:10:17 PM org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans deploy
SEVERE: Unable to load tag library tag class: com.jsptags.navigation.pager.SkipTag
【问题讨论】:
标签: xml tomcat jdbc configuration jndi