The answer to your IT questions
 

Advanced search  • Search tips
My QUESTIONS & ANSWERS
 Question:

Multiple hosts on Jboss

User Asked by: james73
Published on: 12:01/21.11.2007
Status: OPEN
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?
 Answers: 1
Sort by: /\ date | rating
Image Answer by: xpert
Posted on: 12:01/21.11.2007
Rating: 2.6 from possible 5 with 7 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
  
| Home | Hall of fame | Register | Log in | Terms of service | Help | Contacts |