You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Marek Podmaka <ma...@onee.sk> on 2004/11/25 14:06:21 UTC

servlet config on apache 1.3 & tomcat 3.3

Hi!

I'm trying to set up servlet access on one virtual host using apache 1.3.26,
tomcat 3.3 and mod_jk 3.3, all on debian stable. Myself I don't use jsp or
servlets, so I'm little confused with all those java-specific terms. I was
trying to get it to work using many howtos (found by google), but there is
still something wrong.

*** OK, so this is how my httpd.conf looks like:
<IfModule mod_jk.c>
# The following line is for apacheconfig - DO NOT REMOVE!
JkWorkersFile /etc/tomcat/jk/workers.properties
JkLogFile "/usr/share/tomcat/logs/mod_jk.log"
JkLogLevel info
JkMount /*.jsp vhosts
JkMount /servlet/* vhosts
</IfModule>

<VirtualHost *:80>
  ServerName   www.example.com
  DocumentRoot /home/web/example.com/www
</VirtualHost>


*** File /etc/tomcat/jk/workers.properties:
worker.list=vhosts
worker.vhosts.port=8009
worker.vhosts.host=localhost
worker.vhosts.type=ajp13
worker.vhosts.lbfactor=1
worker.vhosts.socket_timeout=60

*** File /etc/tomcat/apps-vhosts.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<Server>
    <Host name="www.example.com">
      <Context path="/servlet" docBase="/home/web/example.com/www/servlet"
debug="1"/>
    </Host>
</Server>

*** File /etc/tomcat/server.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<Server>
 <ContextManager workDir="work" >
        <LoaderInterceptor11  useApplicationLoader="true"
                              use11Loader="true" />
        <TrustedLoader />
        <LogSetter name="tc_log" timestamps="true"
                   verbosityLevel="INFORMATION"  />
        <LogEvents enabled="false" />
        <!-- Backward compat: read the Context declarations from server.xml-->
        <ContextXmlReader config="conf/server.xml" />
        <!-- Separated Context -->
        <ContextXmlReader config="conf/apps.xml" />
        <AutoDeploy source="modules" target="modules"
                    redeploy="true" />
        <AutoWebApp dir="modules" host="DEFAULT" trusted="true"/>
        <AutoDeploy source="webapps" target="webapps" />
        <AutoWebApp dir="webapps" host="DEFAULT" />
        <PolicyLoader securityManagerClass="java.lang.SecurityManager"
                      policyFile="conf/tomcat.policy" />
        <SimpleMapper1 />
        <SessionExpirer checkInterval="60" />
        <!-- For development you can use randomClass="java.util.Random" -->
        <SessionIdGenerator randomClass="java.security.SecureRandom"
                            randomFile="/dev/urandom" />
        <LogSetter name="servlet_log"
                   timestamps="true"
                   verbosityLevel = "INFORMATION"
                   path="logs/servlet.log"
                   />
        <LogSetter  name="JASPER_LOG"
                   timestamps="true"
                   path="logs/jasper.log"
                   verbosityLevel = "INFORMATION"  />
        <WebXmlReader validate="true" />
        <ErrorHandler showDebugInfo="true" />
        <WorkDirSetup cleanWorkDir="false" />
        <Jdk12Interceptor />
        <!-- Non-standard invoker, for backward compat. ( /servlet/* ) -->
        <InvokerInterceptor />
        <!-- you can add javaCompiler="jikes" -->
        <JspInterceptor keepGenerated="true"
                        largeFile="false"
                        useJspServlet="false"
                        javaCompiler="jikes"
                        />
        <StaticInterceptor listings="true" />
        <ReloadInterceptor fullReload="true" />
        <SimpleSessionStore maxActiveSessions="-1" />
        <AccessInterceptor />
        <CredentialsInterceptor />
        <SimpleRealm  filename="conf/users/global-users.xml" />

        <LoadOnStartupInterceptor />
        <Servlet22Interceptor />
        <DecodeInterceptor />
        <SessionId cookiesFirst="true" noCookies="false" />

        <JniConnector />
        <Ajp13Connector port="8009" address="127.0.0.1" pools="true" />
 </ContextManager>
</Server>

*** File /home/web/example.com/www/servlet/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>HelloServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/servlet/helloservlet</url-pattern>
  </servlet-mapping>
</web-app>


OK, so tomcat and apache are running, request to
http://www.example.com/servlet/hello.jsp is correctly processed by tomcat. But
trying to access http://www.example.com/servlet/helloservlet gives out 404
error:
Original request: /servlet/helloservlet
Not found request: /servlet/helloservlet

and I don't know why. I have file HelloServlet.class in classes subdir of
WEB-INF. All tomcat-related logs are silent. I have also tried <url-pattern>
without the initial /servlet, but result was the same. Is there anything else I
have to configure?

   many thanks


-- 
  bYE, Marki

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: servlet config on apache 1.3 & tomcat 3.3

Posted by Bill Barker <wb...@wilshire.com>.
Since your context is called '/servlet', the correct URL is 
http://www.example.com/servlet/servlet/HelloServlet (without a 
servlet-mapping) or http://www.example.com/servlet/servlet/helloservlet 
(with a servlet-mapping).  You probably want to change your servlet-mapping 
to have:  <url-pattern>/helloservlet</url-pattern>.

"Marek Podmaka" <ma...@onee.sk> wrote in message 
news:1101387981.41a5d8cd248f3@admin.mojhosting.sk...
> Hi!
>
> I'm trying to set up servlet access on one virtual host using apache 
> 1.3.26,
> tomcat 3.3 and mod_jk 3.3, all on debian stable. Myself I don't use jsp or
> servlets, so I'm little confused with all those java-specific terms. I was
> trying to get it to work using many howtos (found by google), but there is
> still something wrong.
>
> *** OK, so this is how my httpd.conf looks like:
> <IfModule mod_jk.c>
> # The following line is for apacheconfig - DO NOT REMOVE!
> JkWorkersFile /etc/tomcat/jk/workers.properties
> JkLogFile "/usr/share/tomcat/logs/mod_jk.log"
> JkLogLevel info
> JkMount /*.jsp vhosts
> JkMount /servlet/* vhosts
> </IfModule>
>
> <VirtualHost *:80>
>  ServerName   www.example.com
>  DocumentRoot /home/web/example.com/www
> </VirtualHost>
>
>
> *** File /etc/tomcat/jk/workers.properties:
> worker.list=vhosts
> worker.vhosts.port=8009
> worker.vhosts.host=localhost
> worker.vhosts.type=ajp13
> worker.vhosts.lbfactor=1
> worker.vhosts.socket_timeout=60
>
> *** File /etc/tomcat/apps-vhosts.xml
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <Server>
>    <Host name="www.example.com">
>      <Context path="/servlet" docBase="/home/web/example.com/www/servlet"
> debug="1"/>
>    </Host>
> </Server>
>
> *** File /etc/tomcat/server.xml
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <Server>
> <ContextManager workDir="work" >
>        <LoaderInterceptor11  useApplicationLoader="true"
>                              use11Loader="true" />
>        <TrustedLoader />
>        <LogSetter name="tc_log" timestamps="true"
>                   verbosityLevel="INFORMATION"  />
>        <LogEvents enabled="false" />
>        <!-- Backward compat: read the Context declarations from 
> server.xml-->
>        <ContextXmlReader config="conf/server.xml" />
>        <!-- Separated Context -->
>        <ContextXmlReader config="conf/apps.xml" />
>        <AutoDeploy source="modules" target="modules"
>                    redeploy="true" />
>        <AutoWebApp dir="modules" host="DEFAULT" trusted="true"/>
>        <AutoDeploy source="webapps" target="webapps" />
>        <AutoWebApp dir="webapps" host="DEFAULT" />
>        <PolicyLoader securityManagerClass="java.lang.SecurityManager"
>                      policyFile="conf/tomcat.policy" />
>        <SimpleMapper1 />
>        <SessionExpirer checkInterval="60" />
>        <!-- For development you can use randomClass="java.util.Random" -->
>        <SessionIdGenerator randomClass="java.security.SecureRandom"
>                            randomFile="/dev/urandom" />
>        <LogSetter name="servlet_log"
>                   timestamps="true"
>                   verbosityLevel = "INFORMATION"
>                   path="logs/servlet.log"
>                   />
>        <LogSetter  name="JASPER_LOG"
>                   timestamps="true"
>                   path="logs/jasper.log"
>                   verbosityLevel = "INFORMATION"  />
>        <WebXmlReader validate="true" />
>        <ErrorHandler showDebugInfo="true" />
>        <WorkDirSetup cleanWorkDir="false" />
>        <Jdk12Interceptor />
>        <!-- Non-standard invoker, for backward compat. ( /servlet/* ) -->
>        <InvokerInterceptor />
>        <!-- you can add javaCompiler="jikes" -->
>        <JspInterceptor keepGenerated="true"
>                        largeFile="false"
>                        useJspServlet="false"
>                        javaCompiler="jikes"
>                        />
>        <StaticInterceptor listings="true" />
>        <ReloadInterceptor fullReload="true" />
>        <SimpleSessionStore maxActiveSessions="-1" />
>        <AccessInterceptor />
>        <CredentialsInterceptor />
>        <SimpleRealm  filename="conf/users/global-users.xml" />
>
>        <LoadOnStartupInterceptor />
>        <Servlet22Interceptor />
>        <DecodeInterceptor />
>        <SessionId cookiesFirst="true" noCookies="false" />
>
>        <JniConnector />
>        <Ajp13Connector port="8009" address="127.0.0.1" pools="true" />
> </ContextManager>
> </Server>
>
> *** File /home/web/example.com/www/servlet/WEB-INF/web.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
> 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
>  <servlet>
>    <servlet-name>HelloServlet</servlet-name>
>    <servlet-class>HelloServlet</servlet-class>
>  </servlet>
>  <servlet-mapping>
>    <servlet-name>HelloServlet</servlet-name>
>    <url-pattern>/servlet/helloservlet</url-pattern>
>  </servlet-mapping>
> </web-app>
>
>
> OK, so tomcat and apache are running, request to
> http://www.example.com/servlet/hello.jsp is correctly processed by tomcat. 
> But
> trying to access http://www.example.com/servlet/helloservlet gives out 404
> error:
> Original request: /servlet/helloservlet
> Not found request: /servlet/helloservlet
>
> and I don't know why. I have file HelloServlet.class in classes subdir of
> WEB-INF. All tomcat-related logs are silent. I have also tried 
> <url-pattern>
> without the initial /servlet, but result was the same. Is there anything 
> else I
> have to configure?
>
>   many thanks
>
>
> -- 
>  bYE, Marki
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program. 




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org