TOMCAT 深入分析
TOMCAT J2EE项目连接池配置
/opt/apache-inComBOMP/conf
Server.xml 相关配置信息
<GlobalNamingResources>
<!-- 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"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource
name="jdbc/inComBOMP"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://192.168.1.30:3306/incomtemp"
maxActive="50"
maxldle="10"
maxWait="5000"
username="incomBomp"
password="comeup2012" />
</GlobalNamingResources>
XXXXXXXXX其他内容省略XXXXXXXXXX
<Context docBase="/opt/apache-inComBOMP/webapps/inComBOMP" path="">
<ResourceLink global="jdbc/inComBOMP" name="jdbc/inComBOMP" type="javax.sql.DataSource"/>
</Context>
{WEB APP NAME}/WEB-INF/web.xml
<web-app>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/inComBOMP</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
{WEB APP NAME}/WEB-INF/classes
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"
>
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/DATA_SOURCE_NAME" />
</beans>
TOMCAT 管理员账户配置
1 配置文件位置
{TOMCATHOME}\conf\ tomcat-users.xml
2 配置文件修改如下内容(解除如下内容的注释)
<role rolename="admin"/>
<role rolename="manager"/>
<user username="admin" password="admin" roles="manager"/>
<user username="tomcat" password="tomcat" roles="admin"/>
<user username="role1" password="tomcat" roles="admin"/>
3 停止TOMCAT SERVER
4 启动 TOMCAT SERVER
5 访问页面
6 点击Tomcat Manager
Administration |
7 进入Tomcat Web Application Manager
查看到所有项目的运行情况
TOMCAT 页面部署方式
1 进入Tomcat Web Application Manager
2 点击浏览从本地上传war文件部署
3 部署成功状态
Applications
Path Display Name Running Sessions Commands
/inComBOMP baseplatform-func true 2 Start Stop Reload Undeploy
=========================References ==================
http://192.168.1.110:8080/docs/html-manager-howto.html
4 如果项目在server.xml 如下标签中有定义
如下:
<Context docBase="inComTest" path="/inComTest" reloadable="true" source="org.eclipse.jst.jee.server:inComTest"/>
而用页面上传war包部署方式则会出现错误
修正:
4-1 在server.xml 文件标签中删除该项目的context元素
<!-- Context docBase="inComTest" path="/inComTest" reloadable="true" source="org.eclipse.jst.jee.server:inComTest"/-->
4-2 重新启动server
4-3 重新页面部署war包
部署成功则显示如下内容
Eclipse 内置tomcat 目录解构
项目部署在如下位置
F:\work_space_AITSoft\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
以下文件为 tomcat 配置以及说明的文件
F:\work_space_AITSoft\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps
/Servers/AIT-config/server.xml 配置文件如下
注意:path如果设置为/ 则浏览器访问localhost:8070/index.html 会显示404错误
<?xml version="1.0" encoding="UTF-8"?> <Server port="8011" shutdown="SHUTDOWN"> <Service name="LOTTESS"> <Connector URIEncoding="UTF-8" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" enableLookups="false" maxHttpHeaderSize="8192" maxSpareThreads="75" maxThreads="150" minSpareThreads="25" port="8070" redirectPort="8443"/> <Engine defaultHost="LOTTESS" name="LOTTESS"> <Host appBase="webapps" autoDeploy="true" name="LOTTESS" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false"> <Context docBase="lotte_ss_s" path="/lotte_ss_s" reloadable="true" source="org.eclipse.jst.jee.server:lotte_ss_s"/></Host> </Engine> </Service> </Server>
独立TOMCAT 目录解构
{TOMCATHOME}/webapps
其中lottes_ss_s.war为 独立的web项目
其他为tomcat内置的文件系统
以上两者均可以访问tomcat管理员界面
浏览器输入如下地址
localhost:8070/index.html