Just wanted to update others on the successful progress I have made. Now the Approach #1 that I listed works. In the deploy directory, I have 2 subdirectories:
abc.war and xyz.war
in each of those directories, I have an index.jsp file to identify each home page for each host uniquely, and I have a WEB-INF directory with a jbos-web.xml file that only contains the following data:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_0.dtd">
the above file is in abc.war/WEB-INF/jboss-web.xml
In the same file under xyz.war/WEB-INF, the "abc.com" reads "xyz.com" - everything else is the same.
when I go to http://abc.com, I get the abc.war/index.jsp page
when I go to http://xyz.com, I get the xyz.war/index.jsp page
I still have not figured out how to do the multiple root contexts for virtual servers within (an) ear file(s). If anyone knows how to do this, I would still like to know.
Not sure if this is what you were asking, but I have been able to get virtual hosts working from within EAR files.
I am using JBoss 3.2.1, and have two EAR files set for virtual hosts. I have the jboss-web.xml configured exactly the way that you have it listed in your post. As far as the EAR, I have an entry like below:
I found that making the context-root "/" was the key. JBoss accepts multiple EAR files configured this way, since each EAR that wants to be a virtual host must be configured the same.
reviving an old thread here . . .
I'm using jboss 4.0, deploying multiple WARs inside of an EAR. Setting the virtual host inside of the jboss-web.xml seems to cause the war to be deployed twice.
Anyone else experienced this problem or found a workaround?
Here is an piece of the jboss log:
7:00:28,407 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl= ... 17:00:28,847 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=file: ...
The structure is like this:
someear.ear META-INF application.xml site1.war WEB-INF web.xml jboss-web.xml site2.war . . .
<application> <display-name>My Site</display-name> <module> <web> <web-uri>site1.war</web-uri> <context-root>/</context-root> </web> </module> </application>
<jboss-web> <context-root>/</context-root> <virtual-host>www.site1.com</virtual-host> <virtual-host>site1.com</virtual-host> </jboss-web>