Working with JBoss 4.0.1 & Tomcat with the 'default' server configuration.

How can I have a root-context application respond to all hostnames that resolve 
to an IP address that JBoss/Tomcat is configured to listen on?

E.g.
*.domain.name
*.domain.biz
*.domain.org

As you'll see from my detailed explanation below, I've tried the obvious way 
and ended up with errors that suggest I'm trying to use Java Server Faces when 
in fact I've just got a simple servlet that handles doGet() and doPost().

Explanation:

I am developing a web application that begins with a single "TrafficManager" 
servlet that returns a database-generated member-profile page in the following 
circumstances:

**Preferred URL** (not yet found a way to do this)
http://username1.domain.name
http://username2.domain.biz
http://username3.domain.org

**Alternate URL** (this works)
http://domain.name/username1
http://domain.biz/username2
http:/domain.org/username3

This deploys (as ROOT.war) and works for the *Alternate URL* case with a single 
servlet set as the root (/) context, where there is a WEB-INF/jboss-web.xml 
containing:

  | <?xml version="1.0"?>
  | <jboss-web>
  |  <virtual-host>domain.name</virtual-host>
  |  <virtual-host>domain.biz</virtual-host>
  |  <virtual-host>domain.org</virtual-host>
  |  <context-root>/</context-root>
  | </jboss-web>
  | 
And jboss-4.0.1\server\default\deploy\jbossweb-tomcat50.sar\server.xml contains:
      <!-- HTTP/1.1 Connector  -->
  |       <Connector port="80" address="x.y.z.245"
  |          maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
  |          enableLookups="false" redirectPort="8443" acceptCount="100"
  |          connectionTimeout="20000" disableUploadTimeout="true"/>
  | 
  |     <Host name="domain.name">
  |     <Alias>www.domain.name</Alias>
  |     </Host>
  | 
  |     <Host name="domain.org">
  |     <Alias>www.domain.org</Alias>
  |     </Host>
  |     <Host name="domain.biz">
  |     <Alias>www.domain.biz</Alias>
  |     </Host>
  | 
Note: neither the < virtual-host >, < Host > or < Alias > elements appear to 
support wildcard hostnames such as *.domain.name.

The Servlet simply contains:

  | package net.phwoarrr.servlets;
  | 
  | import java.io.IOException;
  | import java.io.PrintWriter;
  | 
  | import javax.servlet.ServletException;
  | import javax.servlet.http.HttpServlet;
  | import javax.servlet.http.HttpServletRequest;
  | import javax.servlet.http.HttpServletResponse;
  | 
  | public class TrafficManager extends HttpServlet {
  | 
  |  public TrafficManager() {   super();  }
  | 
  |  public void destroy() {  super.destroy();  }
  | 
  |  public void doGet(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException {
  | 
  |   response.setContentType("text/html");
  |   PrintWriter out = response.getWriter();
  |   out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 
Transitional//EN\">");
  |   out.println("<HTML>");
  |   out.println("<HEAD><TITLE>Member Bio for " + request.getPathInfo() + 
"</TITLE></HEAD>");
  |   out.println("<BODY>");
  |   out.println("<h1>Member Bio for " + request.getPathInfo() + "</h1>");
  |   out.print("This is ");
  |   out.print(this.getClass());
  |   out.println(", using the GET method");
  |   out.println("</BODY>");
  |   out.println("</HTML>");
  |   out.flush();
  |   out.close();
  |  }
  | 
  |  public void doPost(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException {
  | 
  |   response.setContentType("text/html");
  |   PrintWriter out = response.getWriter();
  |   out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 
Transitional//EN\">");
  |   out.println("<HTML>");
  |   out.println("<HEAD><TITLE>Member Bio for " + request.getPathInfo() + 
"</TITLE></HEAD>");
  |   out.println("<BODY>");
  |   out.println("<h1>Member Bio for " + request.getPathInfo() + "</h1>");
  |   out.print(this.getClass());
  |   out.println(", using the POST method");
  |   out.println("</BODY>");
  |   out.println("</HTML>");
  |   out.flush();
  |   out.close();
  |  }
  | 
  |  public void init() throws ServletException {
  |   // Put your code here
  |  }
  | }
  | 
However, when I aim to have the web application respond to *ALL* root-context 
HTTP-Requests (no matter what the hostname/IP is) by removing the 
<virtual-host> tags from jboss-web.xml, the JBoss/Tomcat deployer throws 
exceptions and cannot deploy the application.

As you will see from the error report below, there is a suggestion that Java 
Server Faces is being deployed in the ROOT.war when in fact the ONLY change is 
to remove the <virtual-host> entries from jboss-web.xml.

Here is a link to the http://tjworld.net/help/kb/jboss-server.log.txt which 
contains a lot more detail than I've posted here.


  | 2005-04-18 02:38:56,121 DEBUG [tomcat.localhost.ROOT.Context] Configuring 
application event listeners
  | 2005-04-18 02:38:56,121 DEBUG [tomcat.localhost.ROOT.Context]  Configuring 
event listener class 'com.sun.faces.config.ConfigureListener'
  | 2005-04-18 02:38:56,137 ERROR [org.jboss.web.localhost.Engine] 
StandardContext[]Error configuring application listener of class 
com.sun.faces.config.ConfigureListener
  | java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
  |     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
  |     at java.security.AccessController.doPrivileged(Native Method)
  |     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
  |     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
  |     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
  |     at 
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3775)
  | 
  | ...
  | 
  |     at $Proxy8.deploy(Unknown Source)
  |     at 
org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
  |     at 
org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:463)
  |     at 
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
  |     at 
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
  |     at 
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
  | 2005-04-18 02:38:56,152 ERROR [tomcat.localhost.ROOT.Context] Skipped 
installing application listeners due to previous error(s)
  | 2005-04-18 02:38:56,152 ERROR [tomcat.localhost.ROOT.Context] Error 
listenerStart
  | 2005-04-18 02:38:56,152 ERROR [tomcat.localhost.ROOT.Context] Context 
startup failed due to previous errors
  | 2005-04-18 02:38:56,152 DEBUG [tomcat.localhost.ROOT.Context] Stopping
  | 2005-04-18 02:38:56,168 DEBUG [tomcat.localhost.ROOT.Context] Stopping 
filters
  | 2005-04-18 02:38:56,168 DEBUG [tomcat.localhost.ROOT.Context] Processing 
standard container shutdown
  | 2005-04-18 02:38:56,184 DEBUG [tomcat.localhost.ROOT.Context] Sending 
application stop events
  | 2005-04-18 02:38:56,184 DEBUG [tomcat.localhost.ROOT.Context] resetContext 
jboss.web:j2eeType=WebModule,name=//localhost/,J2EEApplication=none,J2EEServer=none
 [EMAIL PROTECTED]
  | 2005-04-18 02:38:56,184 DEBUG [tomcat.localhost.ROOT.Context] Stopping 
complete
  | 
REMEMBER - Simply adding one or more <virtual-host> elements to the 
jboss-web.xml and this web application runs perfectly.

A successful deployment when <virtual-host> elements are used, looks like this:

  | 2005-04-18 03:15:29,223 DEBUG [tomcat.domain.name.ROOT.Context] Configuring 
application event listeners
  | 2005-04-18 03:15:29,223 DEBUG [tomcat.domain.name.ROOT.Context] Sending 
application start events
  | 2005-04-18 03:15:29,223 DEBUG [tomcat.domain.name.ROOT.Context] Starting 
filters
  | 2005-04-18 03:15:29,223 DEBUG [tomcat.domain.name.ROOT.Context]  Starting 
filter 'CommonHeadersFilter'
  | 2005-04-18 03:15:29,239 DEBUG 
[org.jboss.web.tomcat.filters.ReplyHeaderFilter] Adding header name: 
X-Powered-By='Servlet 2.4; Tomcat-5.0.28/JBoss-4.0.1 (build: CVSTag=JBoss_4_0_1 
date=200412230944)'
  | 2005-04-18 03:15:29,239 DEBUG [tomcat.domain.name.ROOT.Context] Starting 
completed
  | 2005-04-18 03:15:29,239 DEBUG [tomcat.domain.name.ROOT.Context] Checking 
for 
jboss.web:j2eeType=WebModule,name=//domain.name/,J2EEApplication=none,J2EEServer=none
  | 2005-04-18 03:15:29,270 DEBUG [org.jboss.web.tomcat.tc5.TomcatDeployer] 
Initialized: {WebApplication: 
/D:/Server/Java/jboss-4.0.1/server/default/tmp/deploy/tmp50102ROOT-exp.war/, 
URL: 
file:/D:/Server/Java/jboss-4.0.1/server/default/tmp/deploy/tmp50102ROOT-exp.war/,
 classLoader: [EMAIL PROTECTED]:18034294} 
jboss.web:j2eeType=WebModule,name=//domain.name/,J2EEApplication=none,J2EEServer=none
  | 2005-04-18 03:15:29,270 DEBUG [org.jboss.web.tomcat.tc5.TomcatDeployer] 
deploy root context=/
  | 2005-04-18 03:15:29,270 INFO  [org.jboss.web.tomcat.tc5.TomcatDeployer] 
deploy, ctxPath=/, 
warUrl=file:/D:/Server/Java/jboss-4.0.1/server/default/tmp/deploy/tmp50102ROOT-exp.war/
  | 2005-04-18 03:15:29,488 DEBUG [org.jboss.web.tomcat.tc5.TomcatDeployer] 
Using session cookies default setting
  | 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3874247#3874247

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3874247


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to