(灰狐動力-中間件技術論壇 by huihoo.com Etre)
Jboss3.0-Tomcat4.03的虛擬主機的配置
1、 請你首先打開WINNTsystem32driversetc目錄下的hosts文件,在里面加入你想要虛擬的機器名,如我是這樣加的
127.0.0.1 www www.www.systekgz.com.cn
在這里www.systekgz.com.cn是我的域名。
www是虛擬名
而我機器的本身名字是fangm,在域中的就是fangm.www.systekgz.com.cn
2、 打開jboss-tomcat安裝目錄下的serverdefaultdeploy的目錄中的tomcat4-service.xml文件,原來的文件是這樣的
<?xml version="1.0" encoding="UTF-8"?>
<!-- Set catalina.home to the location of the Tomcat-4.x dist.
The default value is that of the JBoss/Catalina bundle where the
jakarta-tomcat-4.0.3-LE-jdk14 is included as jboss_dist/catalina
-->
<!DOCTYPE server [
<!ENTITY catalina.home "../catalina">
]>
<!-- The service configuration for the embedded Tomcat4 web container
-->
<server>
<classpath codebase="file:&catalina.home;/common/lib/" archives="*"/>
<classpath codebase="file:&catalina.home;/server/lib/" archives="*"/>
<classpath codebase="file:&catalina.home;/bin/" archives="*"/>
<classpath codebase="file:&catalina.home;/lib/" archives="*"/>
<classpath codebase="." archives="tomcat4-service.jar"/>
<mbean code="org.jboss.web.catalina.EmbeddedCatalinaServiceSX"
name="jboss.web:service=EmbeddedCatalinaSX">
<attribute name="CatalinaHome">&catalina.home;</attribute>
<attribute name="Config">
<Server>
<Service name = "JBoss-Tomcat">
<Engine name="MainEngine" defaultHost="localhost">
<Logger className = "org.jboss.web.catalina.Log4jLogger"
verbosityLevel = "trace" category = "org.jboss.web.localhost.Engine"/>
<Host name="localhost">
<Valve className = "org.apache.catalina.valves.Aclearcase/" target="_blank" >ccessLogValve"
prefix = "localhost_access" suffix = ".log"
pattern = "common" directory = "../server/default/log" />
<DefaultContext cookies = "true" crossContext = "true" override = "true" />
</Host>
</Engine>
<!-- A HTTP Connector on port 8080 -->
<Connector className = "org.apache.catalina.connector.http.HttpConnector"
port = "8080" minProcessors = "3" maxProcessors = "10" enableLookups = "true"
acceptCount = "10" debug = "0" connectionTimeout = "60000"/>
</Service>
</Server>
</attribute>
</mbean>
</server>
第一、 找到 <Engine name="MainEngine" defaultHost="localhost">處,Jboss-tomcat默認是發布在localhost下面,你改為你的機器名,在這里我改成了<Engine name="MainEngine" defaultHost="fangm.www.systekgz.com.cn">注意不是虛擬的名字。
第二、 加如下的一段<Host name="fangm.www.systekgz.com.cn">
<Alias>www.www.systekgz.com.cn</Alias>
<Logger className = "org.jboss.web.catalina.Log4jLogger" verbosityLevel = "debug" category = "org.jboss.web.Host=www"/>
<Valve className = "org.apache.catalina.valves.AccessLogValve" prefix = "www_access" suffix = ".log" pattern = "common" directory = " ../server/default/log" />
</Host>
注意這里<Logger className = "org.jboss.web.catalina.Log4jLogger" verbosityLevel = "debug" category = "org.jboss.web.Host=www"/> 和prefix = "www_access" www是虛擬的機器名
當然你也可以不修改 <Engine name="MainEngine" defaultHost="localhost">處把這里<Host name="fangm.www.systekgz.com.cn"> 改為<Host name="localhost">
改后完整的文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Set catalina.home to the location of the Tomcat-4.x dist.
The default value is that of the JBoss/Catalina bundle where the
jakarta-tomcat-4.0.3-LE-jdk14 is included as jboss_dist/catalina
-->
<!DOCTYPE server [
<!ENTITY catalina.home "../catalina">
]>
<!-- The service configuration for the embedded Tomcat4 web container
-->
<server>
<classpath codebase="file:&catalina.home;/common/lib/" archives="*"/>
<classpath codebase="file:&catalina.home;/server/lib/" archives="*"/>
<classpath codebase="file:&catalina.home;/bin/" archives="*"/>
<classpath codebase="file:&catalina.home;/lib/" archives="*"/>
<classpath codebase="." archives="tomcat4-service.jar"/>
<mbean code="org.jboss.web.catalina.EmbeddedCatalinaServiceSX"
name="jboss.web:service=EmbeddedCatalinaSX">
<attribute name="CatalinaHome">&catalina.home;</attribute>
<attribute name="Config">
<Server>
<Service name = "JBoss-Tomcat">
<Engine name="MainEngine" defaultHost="fangm.www.systekgz.com.cn">
<Logger className = "org.jboss.web.catalina.Log4jLogger"
verbosityLevel = "trace" category = "org.jboss.web.localhost.Engine"/>
<Host name="localhost">
<Valve className = "org.apache.catalina.valves.AccessLogValve"
prefix = "localhost_access" suffix = ".log"
pattern = "common" directory = "../server/default/log" />
<DefaultContext cookies = "true" crossContext = "true" override = "true" />
</Host>
<Host name="fangm.www.systekgz.com.cn">
<Alias>www.www.systekgz.com.cn</Alias>
<Logger className = "org.jboss.web.catalina.Log4jLogger" verbosityLevel = "debug" category = "org.jboss.web.Host=www"/>
<Valve className = "org.apache.catalina.valves.AccessLogValve" prefix = "www_access" suffix = ".log" pattern = "common" directory = " ../server/default/log" />
</Host>
</Engine>
<!-- A HTTP Connector on port 8080 -->
<Connector className = "org.apache.catalina.connector.http.HttpConnector"
port = "8080" minProcessors = "3" maxProcessors = "10" enableLookups = "true"
acceptCount = "10" debug = "0" connectionTimeout = "60000"/>
</Service>
</Server>
</attribute>
</mbean>
</server>
第三、 在你發布.ear應用時,在你找包.war的web應用是,請你在jboss-web.xml文件中加入如下的
<jboss-web>
<context-root>/</context-root>
<virtual-host>www.www.systekgz.com.cn</virtual-host>
</jboss-web>
你就可以通過http:// www.www.systekgz.com.cn:8080來訪問了。如果你出現
Apache Tomcat/4.0.3 - HTTP Status 500 - No Context configured to process this request那是因為你沒有發布應用.
原文轉自:http://www.anti-gravitydesign.com