Deploye two wars with different domain name but same context-path in same jboss-4.0.3

790 views Asked by At

I've two web application wars STORE_ABC.war and STORE_DEF.war and single JBoss server running on my machine. I want to deploye both war with same context path in my jboss as follows.

http://localhost:8080/home For STORE_ABC.war

http://testsite1:8080/home For STORE_DEF.war

jboss-web.xml for STORE_ABC.war and STORE_DEF.war

<jboss-web>
   <context-root>/</context-root>
</jboss-web>

How could I achieve above configuration?

1

There are 1 answers

0
Sumit Kamboj On BEST ANSWER

I have added another host vhost2 to server.xml inside folder ${jboss-home}server\default\deploy\jbossweb-tomcat55.sar folder as follows:

<Server>
<Service name="jboss.web"
  className="org.jboss.web.tomcat.tc5.StandardService">
  <Connector port="8080" address="${jboss.bind.address}"
     maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
     emptySessionPath="true"
     enableLookups="false" redirectPort="443" acceptCount="100"
     connectionTimeout="20000" disableUploadTimeout="true"/>

  <Connector protocol="HTTP/1.1" port="8081" address="${jboss.bind.address}" 
    redirectPort="${jboss.web.https.port}" />


  <Connector port="8089" address="${jboss.bind.address}"
     emptySessionPath="true" enableLookups="false" redirectPort="443" 
     protocol="AJP/1.3"/>

  <Connector port="8445" address="${jboss.bind.address}"
       maxThreads="100" strategy="ms" maxHttpHeaderSize="8192"
       emptySessionPath="true"
       scheme="https" secure="true" clientAuth="false" 
       keystoreFile="${jboss.server.home.dir}/conf/bookstore.keystore"
       keystorePass="bookstore" sslProtocol = "TLS" allowTrace="true"/>

   <Engine name="jboss.web" defaultHost="localhost">
     <Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
        certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
        />
    <Host name="localhost"
        autoDeploy="false" deployOnStartup="false" deployXML="false">
     </Host>
    <Host name="vhost2" autoDeploy="false" 
              deployOnStartup="false" deployXML="false">
                   <Alias>testsite1</Alias>  
            <Valve className="org.apache.catalina.valves.AccessLogValve"
                   prefix="vhost2" suffix=".log" pattern="common" 
                   directory="${jboss.server.home.dir}/log"/>
            <DefaultContext cookies="true" crossContext="true" override="true"/>
        </Host>
  </Engine>
</Service>
</Server>

then I added a new file jboss-web.xml in STORE-DEF.war inside WEB-INF folder as follows:

<jboss-web>
   <context-root>/</context-root>
  <virtual-host>testsite1</virtual-host>
</jboss-web>

Now I am able to access STORE-ABC.war from URL http://localhost:8080/home and STORE-DEF.war from URL http://testsite1:8080/home.

Note- Do not forget to add 127.0.0.1 testsite1 in hosts file.