WEB-INF/jboss-web.xml
In your web application you’ll want to add an xml file named “jboss-web.xml” to your WEB-INF folder. This is the file that’s going to map both the web application’s context and host in jboss.
jbossweb.sar/server.xml
Now we need to edit jboss’ server.xml file, adding the virtual host mappings:
[CODE="JAVA"]
<Server>
<Service name="jboss.web"
className="org.jboss.web.tomcat.tc5.StandardService">
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector port="8080" address="${jboss.bind.address}"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"/>
<Engine name="jboss.web" defaultHost="www.first-application.com">
<Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
/>
<Logger className="org.jboss.web.tomcat.Log4jLogger"
verbosityLevel="WARNING"
category="org.jboss.web.localhost.Engine"/>
<Host name="www.first-application.com" autoDeploy="false"
deployOnStartup="false" deployXML="false">
<Alias>dev.first-application.com</Alias>
<Alias>qa.first-application.com</Alias>
<Alias>test.first-application.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="localhost_access_log."
suffix=".log"
pattern="common"
directory="${jboss.server.log.dir}"
resolveHosts="false" />
</Host>
<Host name="www.second-application.com" autoDeploy="false"
deployOnStartup="false" deployXML="false">
<Alias>dev.second-application.com</Alias>
<Alias>qa.second-application.com</Alias>
<Alias>test.second-application.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="localhost_access_log."
suffix=".log"
pattern="common"
directory="${jboss.server.log.dir}"
resolveHosts="false" />
</Host>
</Engine>
</Service>
</Server>
[/CODE]
上面是官方的host配置文档。我发现host name必须为www.**.com的形式,不能没有www,要不然,JBOSS识别不了。目前就发现这个问题,不知为什么。配置Tomcat时,并没有这个闻听出现。
还有,当遇到,什么ROOT.WAR已经存在的问题,可以把web.xml中的 <context-root>/</context-root> 改成你,当前部署的war名字,就行了。
In your web application you’ll want to add an xml file named “jboss-web.xml” to your WEB-INF folder. This is the file that’s going to map both the web application’s context and host in jboss.
<jboss-web>
<context-root>/</context-root>
<virtual-host>www.first-application.com</virtual-host>
</jboss-web>
jbossweb.sar/server.xml
Now we need to edit jboss’ server.xml file, adding the virtual host mappings:
[CODE="JAVA"]
<Server>
<Service name="jboss.web"
className="org.jboss.web.tomcat.tc5.StandardService">
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector port="8080" address="${jboss.bind.address}"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"/>
<Engine name="jboss.web" defaultHost="www.first-application.com">
<Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
/>
<Logger className="org.jboss.web.tomcat.Log4jLogger"
verbosityLevel="WARNING"
category="org.jboss.web.localhost.Engine"/>
<Host name="www.first-application.com" autoDeploy="false"
deployOnStartup="false" deployXML="false">
<Alias>dev.first-application.com</Alias>
<Alias>qa.first-application.com</Alias>
<Alias>test.first-application.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="localhost_access_log."
suffix=".log"
pattern="common"
directory="${jboss.server.log.dir}"
resolveHosts="false" />
</Host>
<Host name="www.second-application.com" autoDeploy="false"
deployOnStartup="false" deployXML="false">
<Alias>dev.second-application.com</Alias>
<Alias>qa.second-application.com</Alias>
<Alias>test.second-application.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="localhost_access_log."
suffix=".log"
pattern="common"
directory="${jboss.server.log.dir}"
resolveHosts="false" />
</Host>
</Engine>
</Service>
</Server>
[/CODE]
上面是官方的host配置文档。我发现host name必须为www.**.com的形式,不能没有www,要不然,JBOSS识别不了。目前就发现这个问题,不知为什么。配置Tomcat时,并没有这个闻听出现。
还有,当遇到,什么ROOT.WAR已经存在的问题,可以把web.xml中的 <context-root>/</context-root> 改成你,当前部署的war名字,就行了。