You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Simon Oldeboershuis <so...@outermedia.de> on 2000/08/28 19:21:33 UTC

Virtual Hosts and Tomcat

Hi,

I have a problem with virtual hosts and Tomcat! 

I want that every *.jsp from virtual host ONE is mapped to context ONE
and every *.jsp from virtual host TWO is mapped to context TWO

I tried the following...

<IfModule mod_jserv.c>
    ApJServManual on
    ApJServDefaultProtocol ajpv12
    ApJServSecretKey DISABLED
    ApJServMountCopy on
    ApJServLogLevel notice
    ApJServDefaultPort 8007
</IfModule>
<VirtualHost ONE>
	DocumentRoot /usr/local/tomcat/webapps/ONE/
	ServerName ONE
	AddType      text/jsp .jsp
	AddHandler   jserv-servlet .jsp
</VirtualHost> 
<VirtualHost TWO>
	ServerName TWO
	DocumentRoot /usr/local/tomcat/webapps/TWO/
	AddType      text/jsp .jsp
	AddHandler   jserv-servlet .jsp
</VirtualHost> 

if I am accessing http://ONE/index.jsp I am getting 
document contains no data alert box..

Thanks in advance!
	Simon

500 Internal Server Error?!?!?

Posted by David Epstein <de...@columbia.edu>.

I have Tomcat up and running on my Win98 machine (thanks to Jim Rudnicki's
launcher!). It can serve html pages and all the sample jsp pages and
servlets.

I tried to copy over an application that I have running successfully under
Tomcat on another machine. I think I got all the same files into the same
directories, but when I try to load the URL I get the following 500 Internal
Server error. Anyone know what might be going on? It seems like Tomcat just
can't find my com.datavine.* files.

Thanks for any help,

David Epstein



Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for
JSPD:\tomcat\work\localhost_8080%2Fdatavine\_0002fMainFrameSet_0002ejspMainF
rameSet_jsp_0.java:13: Package com.datavine not found in import.
import com.datavine.*;
       ^
1 error

	at org.apache.jasper.compiler.Compiler.compile(Compiler.java, Compiled
Code)
	at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspSe
rvlet.java:149)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:161)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java, Compiled
Code)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
	at java.lang.Thread.run(Thread.java:479)


Re: Virtual Hosts and Tomcat

Posted by frank <ve...@canasoft.net>.
  I think I got it going. Well I got it so that all my sites are
split up. I even got SSL and the vitual hosting going for different
contexts. You have to have a JVM running for each virtual host.
And for SSL you have to have a different IP address for each host.
I will explain just the virtual host stuff and leave out the SSL
stuff.

The tricky points:

The virtual hosts for jsp files go into tomcat.conf. I tried
putting it all into the httpd.conf and got all confused :-)
It will work but is very comfusing. 
 
All the virtual hosts have to go in tomcat.conf because the 
tomcat-apache.conf gets overwritten each time tomcat starts.

You have to configure each virtual host on a seperate port.

I also took out the automatic loader.

Also I found this site to be extremely valuable. Thanks for 
having it.

http://fuzz.cx/~rslifka/tomcat-apache-howto.html

Here are my files:

The tomcat-conf file:

LoadModule jserv_module libexec/mod_jserv.so
ApJServManual on
ApJServDefaultProtocol ajpv12
ApJServSecretKey DISABLED
ApJServMountCopy on
ApJServLogLevel notice

ApJServDefaultPort 8007

NameVirtualHost 216.221.207.131:80

<VirtualHost mach1.canasoft.net:80>
    DocumentRoot /home/mach1/www
    ServerName mach1.canasoft.net

AddType test/jsp .jsp
AddHandler jserv-servlet .jsp
Alias /examples /home/mach1/examples
<Directory "/home/mach1/www/examples">
    Options Indexes FollowSymLinks
</Directory>
ApJServMount /examples ajpv12://localhost:8007/examples
<Location /response/WEB-INF/ >
    AllowOverride None
    allow from all
</Location>

</VirtualHost>


<IfDefine SSL>

##
## SSL Virtual Host Context
##

NameVirtualHost 216.221.207.239:443

#  General setup for the virtual host
<VirtualHost mach7.canasoft.net:443>
DocumentRoot "/home/mach7/ssl"
ServerName mach7.canasoft.net
ServerAdmin root@mach7.canasoft.net
ErrorLog /usr/share/apache-1.3.12/logs/error_log
TransferLog /usr/share/apache-1.3.12/logs/access_log

AddType test/jsp .jsp
AddHandler jserv-servlet .jsp
Alias /examples /home/mach7/response
<Directory "/home/mach7/ssl/response">
    Options Indexes FollowSymLinks
</Directory>
ApJServMount /response ajpv12://localhost:8009/response
<Location /response/WEB-INF/ >
    AllowOverride None
    allow from all
</Location>

SSLEngine on
SSLCipherSuite ALL:!ADH:!EXP56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /usr/share/apache-1.3.12/conf/ssl.crt/server.crt
SSLCertificateKeyFile /usr/share/apache-1.3.12/conf/ssl.key/server.key

<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/usr/share/apache-1.3.12/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

CustomLog /usr/share/apache-1.3.12/logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

</IfDefine>



The first xml file  (for mach1 called: server_mach1.xml)


<?xml version="1.0" encoding="ISO-8859-1"?>

<Server>
    <!-- Debug low-level events in XmlMapper startup -->
    <xmlmapper:debug level="0" />

    <!-- This is quite flexible; we can either have a log file per
         module in Tomcat (example: ContextManager) or we can have
         one for Servlets and one for Jasper, or we can just have
	 one tomcat.log for both Servlet and Jasper.

	 If you omit "path" there, then stderr should be used.

	 verbosityLevel values can be: 
	    FATAL
	    ERROR
	    WARNING 
            INFORMATION
            DEBUG
         -->

    <Logger name="tc_log" 
            path="logs/tomcat.mach7.log"
            customOutput="yes" />

    <Logger name="servlet_log" 
            path="logs/servlet.mach7.log"
            customOutput="yes" />

    <Logger name="JASPER_LOG" 
	    path="logs/jasper.mach7.log"
            verbosityLevel = "INFORMATION" />

    <ContextManager debug="0" workDir="work_mach7" >
        <!-- ContextInterceptor className="org.apache.tomcat.context.LogEvents" / -->
        <ContextInterceptor className="org.apache.tomcat.context.DefaultCMSetter" />
        <ContextInterceptor className="org.apache.tomcat.context.WorkDirInterceptor" />
        <ContextInterceptor className="org.apache.tomcat.context.WebXmlReader" />
        <ContextInterceptor className="org.apache.tomcat.context.LoadOnStartupInterceptor" />
        <!-- Request processing -->
        <RequestInterceptor className="org.apache.tomcat.request.SimpleMapper" debug="0" />
        <RequestInterceptor className="org.apache.tomcat.request.SessionInterceptor" />
        <RequestInterceptor className="org.apache.tomcat.request.SecurityCheck" />
        <RequestInterceptor className="org.apache.tomcat.request.FixHeaders" />

        <Connector className="org.apache.tomcat.service.SimpleTcpConnector">
            <Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/>
            <Parameter name="port" value="8007"/>
        </Connector>

        <Context path="/examples" docBase="/home/mach1/www/examples" debug="0" reloadable="true" > 
        </Context>

    </ContextManager>
</Server>


The second xml file (for mach7 called: server_mach7.xml)


<?xml version="1.0" encoding="ISO-8859-1"?>

<Server>
    <!-- Debug low-level events in XmlMapper startup -->
    <xmlmapper:debug level="0" />

    <!-- This is quite flexible; we can either have a log file per
         module in Tomcat (example: ContextManager) or we can have
         one for Servlets and one for Jasper, or we can just have
	 one tomcat.log for both Servlet and Jasper.

	 If you omit "path" there, then stderr should be used.

	 verbosityLevel values can be: 
	    FATAL
	    ERROR
	    WARNING 
            INFORMATION
            DEBUG
         -->

    <Logger name="tc_log" 
            path="logs/tomcat.mach1.log"
            customOutput="yes" />

    <Logger name="servlet_log" 
            path="logs/servlet.mach1.log"
            customOutput="yes" />

    <Logger name="JASPER_LOG" 
	    path="logs/jasper.mach1.log"
            verbosityLevel = "INFORMATION" />

    <ContextManager debug="0" workDir="work" >
        <!-- ContextInterceptor className="org.apache.tomcat.context.LogEvents" / -->
        <ContextInterceptor className="org.apache.tomcat.context.DefaultCMSetter" />
        <ContextInterceptor className="org.apache.tomcat.context.WorkDirInterceptor" />
        <ContextInterceptor className="org.apache.tomcat.context.WebXmlReader" />
        <ContextInterceptor className="org.apache.tomcat.context.LoadOnStartupInterceptor" />
        <!-- Request processing -->
        <RequestInterceptor className="org.apache.tomcat.request.SimpleMapper" debug="0" />
        <RequestInterceptor className="org.apache.tomcat.request.SessionInterceptor" />
        <RequestInterceptor className="org.apache.tomcat.request.SecurityCheck" />
        <RequestInterceptor className="org.apache.tomcat.request.FixHeaders" />

        <Connector className="org.apache.tomcat.service.SimpleTcpConnector">
            <Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/>
            <Parameter name="port" value="8009"/>
        </Connector>

        <Context path="/response" docBase="/home/biba/www/response" debug="0" reloadable="true" > 
        </Context>

    </ContextManager>
</Server>