Static content is not being loaded for multiple war with same context path inside single jboss instance

482 views Asked by At

I've deployed two war STORE_ABC.war and STORE_DEF.war file with same context path using virtual hosts in jboss 4. STORE_ABC.war is accessible with URL http://localhost:8080/home and STORE_DEF.war is accessible with URL http://testsite1:8080/home.Configuration of server.xml is shown below.

<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>

STORE_ABC.war's jboss-web.xml

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

STORE_DEF.war's jboss-web.xml

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

And I had a third static.war inside deploy folder of jboss parallel to STORE_ABC.war and STORE_DEF.war which is to serve the static content(css and images). Now the problem is that static content from static.war is not being loaded for STORE_DEF.war whereas it is working fine for STORE_ABC.war.

1

There are 1 answers

0
Sumit Kamboj On BEST ANSWER

I figured out myself the problem was in static.war. I need to create a folder WEB-INF inside static.war and put a jboss-web.xml as follows:

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

and a correction needs to be done in jboss-web.xml of STORE_ABC.war

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

after doing all above changes it start working fine.