Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two web apps on one domain with different context roots?

I have a problem. I have two web apps deployed as wars. Let's call them app1.war and app2.war.

I would like app1.war to be accessed at the URL www.website.com and I would like app2.war to be accessible as www.website.com/anotherapp. I have my domain name ready.

Virtual hosting does not seem to help here.

I am running JBoss App Server 5.1 and Seam 2.2.0. I am working on integrating a forum (deployed as a war) with my app (deployed as another war) and therefore need to use single sign on and therefore would like the URL formats described above for easy passing of sso cookies.

Thanks for any insights.

-Charles.

like image 413
donakalz Avatar asked Feb 10 '11 03:02

donakalz


2 Answers

You need to do such things:

  1. Configure your JBoss to use virtual host with the www.website.com name.

    You can do it by editing server.xml from jbossweb.sar directory. In short you have to set up another Host directive.

  2. You have to setup your war application. You can do it by creating or editing jboss-web.xml file (it should be placed in WEB-INF directory). In that file you can configure what virtual host should be used and under what context.

Example of that file for app1.war

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

Example of that file for app2.war

<jboss-web>
   <context-root>/anotherapp</context-root>
   <virtual-host>website</virtual-host>
</jboss-web>

More info you can find in that post Hosting Multiple Domains With JBoss

like image 194
Lukasz Stelmach Avatar answered Sep 28 '22 00:09

Lukasz Stelmach


Haven't used JBoss in a while or Seam at all but if it's like most application servers there will be an XML file of some description where you match URL patterns to apps. Check you docs for details but I think you want web.xml and a few servlet entries like:

<servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.seam</url-pattern>
</servlet-mapping>

Change the url-pattern and servlets accordingly.

like image 29
SpliFF Avatar answered Sep 27 '22 23:09

SpliFF