in Advanced 

Question preview

HomeQuestion preview:
Log in

Multiple hosts on Jboss

Hi,

I use Apache with modkj and Jboss 4.0.4 with Tomcat as application server. My question is how can I tell that each EAR on Jboss represents different host? I want to host multiple sites on one machine. I already configured DNS records, what is next step?
Do you know someone who could answer? Ask him for help
Answers: 1
Sort by: date rating
image xpert
14:01/21.11.2007
3.1 from possible 5 with 10 votes
When you build your EAR, in application EAR you have to tell jboss that context path starts from root:

application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
		http://java.sun.com/xml/ns/javaee/application_5.xsd"
             version="5">
<display-name>MyApp</display-name>
    <module>
        <web>
            <web-uri>myweb.war</web-uri>
            <context-root>/</context-root>
        </web>
    </module>
</application>


Then you have to include in your WAR a special file for jboss which will contain
mapping between your web application and virtual host for jboss tomcat:
META-INF/jboss-web.xml
<jboss-web>
	<context-root>/</context-root>  <!--Make what ever context root you want -->
	<virtual-host>mywebhost1</virtual-host>
</jboss-web>


Final step is to tell tomcat inside jboss that you have multiple virtual hosts and map each of them to real domain names.
Add corresponding <Host> tags:

jboss-4.0.4.GA\server\default\deploy\jbossweb-tomcat55.sar\server.xml
<Server>
<...>
   <Service name="jboss.web"
      className="org.jboss.web.tomcat.tc5.StandardService">

      <!-- A AJP 1.3 Connector on port 8009 -->
      <Connector port="8009" address="${jboss.bind.address}"
         emptySessionPath="true" enableLookups="false" redirectPort="8443" 
         protocol="AJP/1.3"/>

      <Engine name="jboss.web" defaultHost="localhost">

         <Host name="localhost"
            autoDeploy="false" deployOnStartup="false" deployXML="false">

         <Host name="mywebhost1"
            autoDeploy="false" deployOnStartup="false" deployXML="false">
			<Alias>mydomain1.com</Alias>
			<Alias>www.mydomain1.com</Alias>
         </Host>
      </Engine>

   </Service>

</Server>



For all ears create vurtual hosts like mywebhost1, mywebhost2 ... and then map virtual hosts to real aliases.
Vote:
Please vote! Your opinion matters!
If you haven't found what you've looking for, post a question
Ask question
Related questions:
| Home | Hall of fame | Registration | Log in | Terms of service | Privacy policy | Help | Contacts | RSS |