-
1. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
am2605 Mar 6, 2012 6:56 AM (in response to mr-678)I would also like to know the answer to this.
Also, are we limited to just one web app per host? Is there an example of a setup such as this?
server1/ <-- default web app is ROOT.war
server2/foo <-- web app is foo.war
server2/bar <-- web app is bar.war
Can this be done?
Many thanks,
Andrew.
-
2. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
ctomc Mar 6, 2012 9:54 AM (in response to am2605)Hi guys,
both options are possible
you can add context root and don't use
default-web-module="myapp"
i would recommend you to add <context-root>/</context-root> in your jboss-web.xml and that will take care of your deployment on localhost in eclipse as this will bind it to / context (aka root context)
as for many apps on one virtual host it is not a problem as long as context-root is diffrent.
by default context-root is generated from war name.
--
tomaz
-
3. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
mr-678 Mar 6, 2012 8:18 PM (in response to mr-678)based on Tomaz answer (#2) I document the solutions that works for me:
On server:
standalone.xml
<subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host"> <connector name="http" protocol="HTTP/1.1" socket-binding="http" scheme="http"/> <virtual-server name="default-host" enable-welcome-root="true"> <alias name="localhost"/> <alias name="example.com"/> </virtual-server> <virtual-server name="mydomain1" > <alias name="mydomain1.de"/> <alias name="www.mydomain1.de"/> </virtual-server> </subsystem>
jboss-web.xml inside project myapp:
<?xml version="1.0" encoding="UTF-8"?> <jboss-web xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd"> <context-root>/</context-root> <virtual-host>mydomain1</virtual-host> </jboss-web>
On localhost (development with ide):
standalone.xml:
<subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host"> <connector name="http" protocol="HTTP/1.1" socket-binding="http" scheme="http"/> <virtual-server name="default-host" enable-welcome-root="true"> <alias name="example.com"/> </virtual-server> <virtual-server name="mydomain1"> <alias name="localhost"/> </virtual-server> </subsystem>
jboss-web.xml:
no modifications
If you have to configure more virtual servers:
server-side:
you can add easily more virtual-server
local:
you have to add also the virtual-server in standalone.xml.
you can only use once the alias name "localhost" <alias name="localhost"/>
I think for local development this is ok.
-
4. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
mr-678 Mar 6, 2012 7:51 PM (in response to ctomc)Hi Tomaz,
thanks alot for your helpful answer!
Your tip work's for me (see answer #3).
Summarized I think on Glassfish this works a litte bit 'smarter'... There you can assign a webapp to a webdomain only in the server configuration (without to add special deployment information inside the webproject).
Inside the web project (jboss-web.xml) knowledge about the name of the "virtual-host" is always necessary , or?
-
5. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
madhuy Sep 6, 2012 7:02 AM (in response to mr-678)Hi,
I am using my local PC for launching the application.
jboss-web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<context-root>/</context-root>
<virtual-host>sampletest</virtual-host>
</jboss-web>
standalone.xml :
<virtual-server name="sampletest" default-web-module="Sample">
<alias name="localhost"/>
</virtual-server>
<deployments>
<deployment name="Sample.war" runtime-name="Sample.war">
<content sha1="cf1619ae229f7fb9a8b9b45b42f10c1b5df7168f"/>
</deployment>
</deployments>
But I am unable to lauch my application from browser
My war file looks like
Sample.war
-->WEB-INF
---> jboss-web.xml
---> web.xml
---> index.jsp
-->META-INF
---> MANIFEST.MF
Can you let me know what could be the problem?
Thanks and REgards,
Madhu
-
6. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
mr-678 Sep 6, 2012 8:27 AM (in response to madhuy)Hi Madhu Y,
inside jboss-web.xml you defined your context-root as '/'. So your application should be available as 'root' application directly under http://localhost:8080
Regards, matthias
-
7. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
madhuy Sep 6, 2012 8:34 AM (in response to mr-678)Hi Matthias,
How should my link address should be.
I tried with the following and unsuccessful.
http://localhost:8080/Sample/index.jsp
http://localhost:8080/index.jsp
Regards,
Madhu
-
8. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
mr-678 Sep 6, 2012 8:40 AM (in response to madhuy)Hi Madhu,
I just see that you placed your index.jsp in your WEB-INF folder. Try to move your index.jsp to root folder (Sample.war --> index.jsp). Content from the WEB-INF folder can only be accessed from the web-container ifself (if needed by a servlet).
Regards, matthias
-
9. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
madhuy Sep 6, 2012 8:48 AM (in response to mr-678)Hi,
Sorry. Still I am not able to launch the application from browser
REgards,
Madhu
-
10. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
mr-678 Sep 6, 2012 9:03 AM (in response to madhuy)Hi Madhu,
I've tried your config on a local project for me:
When I use your config I get also no result from browser...
Try to use following setup:
<virtual-server name="sampletest" >
<alias name="localhost"/>
</virtual-server>
Without default-web-module="Sample"
This works in my test-seupt.
Regards, matthias
-
11. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
madhuy Sep 6, 2012 9:15 AM (in response to mr-678)Hi,
Somehow it is not working in my case.
When I deploy the war file standalone is getting updated as shown below
<virtual-server name="Sample" default-web-module="Sample.war">
<alias name="localhost"/>
</virtual-server>
Can you tell me the link addresss you used?
Regards,
Madhu
-
12. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
mr-678 Sep 6, 2012 9:22 AM (in response to madhuy)Hi Madhu,
when you modify standalone.xml it's important that your server is stopped! Else your modification is lost because during server shutdown the standalone.xml is updated by the server.
Stop your server -> modify your standalone.xml : remove default-web-module -> start your server.
With the configuration above you can reach your webapp as root-app (url: http://localhost:8080/index.jsp http://localhost:8080 should also work - index.jsp is a default page)
Regards, matthias
-
13. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
madhuy Sep 6, 2012 9:34 AM (in response to mr-678)Hi Matthias,
Somehow it is still not working on our side.
I am failing to understand how it is working for you.
I stopped jboss server and updated xml file and now it looks like
<virtual-server name="default-host" enable-welcome-root="false">
<alias name="localhost"/>
<alias name="example.com"/>
</virtual-server>
<virtual-server name="Sample">
<alias name="localhost"/>
</virtual-server>
I am attaching the sample.war and standalone.xml file which I am using.
Can you let me know what is the error in my small application?
Regards,
Madhu
-
Sample.war 3.1 KB
-
standalone.xml 15.1 KB
-
-
14. Re: Interaction between virtual-server (in standalone.xml) and virtual-host (in jboss-web.xml)
mr-678 Sep 6, 2012 12:32 PM (in response to madhuy)Hey Madhu,
I've loaded your project into my eclipse and was also surprised that it didn't work.
I changed the virtual host to "sample-domain"
jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?> <jboss-web > <context-root>/</context-root> <virtual-host>sample-domain</virtual-host> </jboss-web>
standalone.xml:
<virtual-server name="sample-domain"> <alias name="localhost"/> </virtual-server>
Now the App is avaiable under http://localhost:8080
May be the virtual-host/virtual-server name have not to be identical to the war-file name...
kind regards,
matthias
p.s. your index.jsp will not work correctly / hard coded post-path. May be it's useful you check out a jboss sample project