how to configure multiple virtual hosts for the same context root /

Hi,

I am using Glassfish V1 U1 - b14 on Solaris.

I am trying to configure two applications to be mapped to the / root context, each one in its own virtual host.

Two things I have noticed:

1. I have to manually add virtual-hosts="hostId" in domain.xml/application-ref ... looks like just simply deploying the app does not do that although the application is set as default for its particular virtual host. Is this a bug?

2. Although I have set for each virtual host the default web-app correctly, and they both respond fine, I cannot map both of them to the / context. The second application (chronologically deployed) does not respond when called with the / context ....

Any ideas? Is this a bug again?

Regards,

Rares

Message was edited by:

raresp

[815 byte] By [rarespa] at [2007-11-14]
# 1
actually when the server starts I am given this ERRORError looking up the configuration information of the default web module [axz#axz-war.war] of virtual server [wwwt.axz.ro]quite strange since the configuration is there, and there is nothing wrong with it.
rarespa at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 2

Do you have separate and distinct HTTP Listeners for each virtual server? Another words, HTTP Listener one go only to virtual server one and HTTP Listener two go only to virtual server two?

If you have one HTTP Listener that goes to two virtual servers, then the context is ambiguious.

Mike

mbrown36a at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 3
Thanks for the answer. I didn't know it was possible to define multiple listeners for the same port number. I will try and see if it works...
rarespa at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 4
Looks like it is not possible to bind two listeners to the same port (I have also read this somewhere).At startup this exception is thrown java.net.BindException: already bound 80...
rarespa at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 5

No, I am not saying two listener listening to the same port. Virtual servers have can listen to multiple HTTP listeners. If you have two virtual servers associated with the same HTTP listener, you can not have different apps with the same context root.

In the admin open up Configuration | HTTP Service | Virtual Servers. When you click on your virtual servers there is a field called "HTTP Listeners:". You can have multiple HTTP Listeners here.

Mike

mbrown36a at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 6

Wow, that's a shame. All mighty Application Server and two different apps on two different virtual hosts are considered ambiguous to have the same context root definition.... Fair play to Tomcat and 90% of the rest of servlet containers!

In my case I have the same EAR we are planning to deploy to many (up to 30) virtual hosts. Faking different context roots for each deployment will bring unnecessary overheads...

Should I file a bug or feature request?

Thanks again for your answer, although you're basically saying it is not possible I will wait and look a while for a possible solution before bringing this topic to a conclusion.

rarespa at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 7

I don't think that you understand what I am saying. If you have two HTTP Listeners 1 and 2. 1 listens on port 8080 and 2 listens on port 8081. Now you have two virtural servers 1 and 2. Virtual server one listens to HTTP Listener 1 and 2. Virtural server two listens to HTTP Listener 2.

Now you deploy 2 apps we with context root abc to each virtual servers. If someone does http://localhost:8081/abc, what application should it run? Two virtual servers are listening to HTTP Listener 2. If the context roots are the same, it won't know which one to you.

I am saying, check to make sure that this is what you have set up.

Mike

mbrown36a at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 8
Mike thanks for answering again. I understood completely what you said with the listeners and their corresponding ports. It is just not an option for me. I need to deploy the same EAR to many virtual hosts, up to 50. Allocating a port for each one is not an option, I need them all on port
rarespa at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 9
Do you have different Network Addresses for these 50 different versions of the applicatoin? An HTTP Listener is unique for Port and Network Address. Make 50 HTTP Listeners with different Network Addresses all listening on port 80.
mbrown36a at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 10
that would bring to much overheads and would consume to many resources ( I will need 50 IP aliases, 50 listeners each one with 50 acceptor threads)....Sun recommends using the URL based virtual servers http://docs.sun.com/source/817-3652-10/images/vsurl3.gif
rarespa at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...
# 11

Hello,

I guess the concept lets you define multiple virtual servers that listen to the same "Listener". You can separate them entering different hosts. For e.g. webapp1.yourdomain.com for webapp1, webapp2.yourdomain.com for webapp2 and so on.

Unfortunately it fails with Sun Java System Application Server Platform Edition 9.0_01

Igor.Katrayeva at 2007-7-7 > top of java,Application & Integration Servers,Application Servers...