You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Colin Hawkett <Co...@aetas.com.au> on 2001/07/04 09:19:15 UTC

Apache - Tomcat - Servlet Mapping

Hi all,

    This question seems to be popping up pretty regularly, but I couldn't
extract a solution to my problem - namely: getting apache to recognise
servlet-mappings. I am running tomcat 3.2.2 and apache 1.3.11 on win98.

I have a web application packaged up as a war file and deployed to the
webapps directory.  The web.xml file contains (among other things)

<servlet>
    <servlet-name>theServlet</servlet-name>
    <servlet-class>com.myco.test.TheServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>theServlet</servlet-name>
    <url-pattern>/myServlet</url-pattern>
</servlet-mapping>

Now, I've confirmed that the mapping is correct by accessing it using the
URL

http://myserver:8080/<context_path>/myServlet    - This is fine, no problems

As I understand it, this is connecting to the tomcat web server (on port
8080), which is aware of the servlet mapping because it has read the web.xml
file for application.  And this is how I would expect it to work.  Cool.

However, I don't want Tomcat to be my web server.  I want apache to be my
webserver.  So I try to access the application using the URL

http://myserver/<context_path>/myServlet    -  This fails!

everything about the web-app works with apache except the servlet mapping,
so I assume Apache is unaware of it.  The closest thing to a solution I have
found is that I need to add a line to 'tomcat-apache.conf' that looks
something like -

ApJServMount    /<context_path>/myServlet
/<context_path>/servlet/theServlet

which seems like a really annoying thing to have to do.  The whole point of
web-apps is that you define everything you need to in web.xml, so that you
don't have to change configuration files on the deployment system.  If this
is necessary, then what is the point of the servlet-mapping?  Surely tomcat
should generate the necessary ApJServMount lines in
"tomcat-apache.conf" when it starts up and reads web.xml?

So, the big question is -

* Is it possible to get apache to recognise servlet mappings defined in a
web-app's web.xml without explicitly making a modification to an apache
config file? If so, how?

* If not can someone give a concrete example of a servlet mapping, and the
corresponding ApJServMount line that will get apache to recognise that
mapping?

I hope this all makes sense - appreciation in advance,

Colin



Re: Starting Tomcat Programmatically

Posted by Dmitri Colebatch <di...@nuix.com.au>.
On Wed,  4 Jul 2001 18:22, you wrote:
> What are the steps required to start programmatically from a java program
Start what?  Tomcat?

org.apache.tomcat.startup.Tomcat.Main(new String[]);

should do the trick.

cheers
dim

Starting Tomcat Programmatically

Posted by Neeraj Kumar <ne...@hotmail.com>.
Hi

What are the steps required to start programmatically from a java program

regards
Neeraj


Re: Apache - Tomcat - Servlet Mapping

Posted by Dmitri Colebatch <di...@nuix.com.au>.
On Wed,  4 Jul 2001 17:19, you wrote:
> ApJServMount    /<context_path>/myServlet
> /<context_path>/servlet/theServlet
So I assume that if you request 
http://myserver/<context_path>/servlet/myServlet it works too?  This isn't 
the point though - you're right, you shouldn't (and dont) have to do that.

> * If not can someone give a concrete example of a servlet mapping, and the
> corresponding ApJServMount line that will get apache to recognise that
> mapping?
see below (o:

--- snippet from web.xml ---

    <servlet>
        <servlet-name>australian3quiz-results</servlet-name>
        <servlet-class>com.coxless.quizzes.QuizResultServlet</servlet-class>
        <init-param>
            <param-name>quiz-file</param-name>
            <param-value>australian3.xml</param-value>
        </init-param>
        <init-param>
            <param-name>results-file</param-name>
            <param-value>australian3-results.xml</param-value>
        </init-param>
        <init-param>
            <param-name>jsp</param-name>
            <param-value>/jsp/quiz-results.jsp</param-value>
        </init-param>
        <init-param>
            <param-name>error-jsp</param-name>
            <param-value>/jsp/error.jsp</param-value>
        </init-param>
        <init-param>
            <param-name>quizLink</param-name>
            <param-value>/servlet/australian3quiz</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>australian3quiz-results</servlet-name>
        <url-pattern>/australian3quiz-results</url-pattern>
    </servlet-mapping>

--- end snippet from web.xml ---

--- snippet from httpd.conf ---

Include /var/local/apache/conf/mod_jk.conf

<VirtualHost *:80>
    ServerAdmin dim@coxless.com
    DocumentRoot /projects/coxless/live/htdocs
    ErrorDocument 400 /404.shtml
    ErrorDocument 500 /500.shtml
    ServerName dev.coxless.com
    ErrorLog logs/dev-coxless.com-error_log
    CustomLog logs/dev-coxless.com-access_log common

    JkMount /*.jsp ajp12
    JkMount /*.do ajp12
    JkMount /servlet/* ajp12

</VirtualHost>

--- end snippet from httpd.conf

--- snippet from mod_jk.conf ---

LoadModule jk_module /packages/apache/libexec/mod_jk.so

JkWorkersFile /var/local/apache/conf/tomcat-workers.properties
JkLogFile /var/local/apache/logs/tomcat-mod_jk.log

#
# Log level to be used by mod_jk
#
JkLogLevel error

--- end snippet from mod_jk.conf ---


I hope this helps... if you still have problems, post yours and I'll see what 
I can do (o:

cheesr
dim

mod_jk build on Solaris 2.6

Posted by kun yan <ku...@students.uiuc.edu>.
Hi,

I installed

Apache 1.3.20
Tomcat 3.2.2

on Solaris.

I tried to build mod_jk.so but get the following error.

gcc -DSOLARIS2=270 -DUSE_EXPAT -I../lib/expat-lite -DNO_DL_NEEDED
-I/mnt/sdt/kunyan/apache/include -I/usr/java1.2/include/solaris -I../jk
-I/usr/java1.2/include -DSOLARIS  -c mod_jk.c
:
:
gcc -DSOLARIS2=270 -DUSE_EXPAT -I../lib/expat-lite -DNO_DL_NEEDED
-I/mnt/sdt/kunyan/apache/include -I/usr/java1.2/include/solaris -I../jk
-I/usr/java1.2/include -DSOLARIS  -c ../jk/jk_worker.c
  -o mod_jk.so jk_worker.o jk_util.o jk_uri_worker_map.o jk_sockbuf.o
jk_pool.o jk_nwmain.o jk_msg_buff.o jk_map.o jk_lb_worker.o
jk_jni_worker.o jk_connect.o jk_ajp13_worker.o jk_ajp13.o
jk_ajp12_worker.o mod_jk.o -lposix4
apxs:Break: Command failed with rc=16777215

The command is:
apxs -o mod_jk.so -DSOLARIS
-I/usr/java1.2/include/solaris -I..
/jk -I/usr/java1.2/include -l posix4 -c *.c ../jk/*.c

Does anyone have faced the same problem? How did you solve it?

Any help or hint will be really appreciated.

Regards,

Kun


Apache-Tomcat-mod_jk integration

Posted by kun yan <ku...@students.uiuc.edu>.
I am new to tomcat. When I tried to build mod_jk from tomcat souce code, I
got the following error:
apxs:Break: Command failed with rc=16777215
after all the *.c compiled.

Anyone know why and how could I get mod_jk.so?

Thanks in advance!

Regards,

Kun



RE: Apache - Tomcat - Servlet Mapping

Posted by "Bruce A. Carson" <ba...@world.std.com>.
I think that the more recent mod_jk's use ajpv13.  My mod_jk.conf-auto ends up with lines like:

#
# The following line mounts all JSP files and the /servlet/ uri to tomcat
#
JkMount /examples/servlet/* ajp13
JkMount /examples/*.jsp ajp13

I am using jakarta 3.3 M3

Bruce


> -----Original Message-----
> From: Sam Newman [mailto:sam.newman@stamplets.com]
> Sent: Wednesday, July 04, 2001 4:19 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Apache - Tomcat - Servlet Mapping
> 
> 
> Right - firstly, don't use JServ, use mod_jk. The file 'tomcat-apache.conf'
> is generating directives for the old jserv module and its quite possible
> this isn't complete. Secondly, Tomcat automatically generates the apache
> directives based on your tomcat config for mod_jk (server.xml and web.xml's)
> and puts it in a file called mod_jk.conf-auto, which you can include in your
> httpd.conf for apache. For more in-depth information check the docs that
> come with the tomcat distro - namely the mod_jk howto. The only thing to
> watch when using mod)jk.conf-auto is that it only uses ajpv12, which is
> slower than ajpv13 (and has a few bugs), so you'd probably want to mount
> using the newer ajpv13.
> 
> sam
> ----- Original Message -----
> From: "Colin Hawkett" <Co...@aetas.com.au>
> To: <to...@jakarta.apache.org>
> Sent: Wednesday, July 04, 2001 8:19 AM
> Subject: Apache - Tomcat - Servlet Mapping
> 
> 
> > Hi all,
> >
> >     This question seems to be popping up pretty regularly, but I couldn't
> > extract a solution to my problem - namely: getting apache to recognise
> > servlet-mappings. I am running tomcat 3.2.2 and apache 1.3.11 on win98.
> >
> > I have a web application packaged up as a war file and deployed to the
> > webapps directory.  The web.xml file contains (among other things)
> >
> > <servlet>
> >     <servlet-name>theServlet</servlet-name>
> >     <servlet-class>com.myco.test.TheServlet</servlet-class>
> > </servlet>
> >
> > <servlet-mapping>
> >     <servlet-name>theServlet</servlet-name>
> >     <url-pattern>/myServlet</url-pattern>
> > </servlet-mapping>
> >
> > Now, I've confirmed that the mapping is correct by accessing it using the
> > URL
> >
> > http://myserver:8080/<context_path>/myServlet    - This is fine, no
> problems
> >
> > As I understand it, this is connecting to the tomcat web server (on port
> > 8080), which is aware of the servlet mapping because it has read the
> web.xml
> > file for application.  And this is how I would expect it to work.  Cool.
> >
> > However, I don't want Tomcat to be my web server.  I want apache to be my
> > webserver.  So I try to access the application using the URL
> >
> > http://myserver/<context_path>/myServlet    -  This fails!
> >
> > everything about the web-app works with apache except the servlet mapping,
> > so I assume Apache is unaware of it.  The closest thing to a solution I
> have
> > found is that I need to add a line to 'tomcat-apache.conf' that looks
> > something like -
> >
> > ApJServMount    /<context_path>/myServlet
> > /<context_path>/servlet/theServlet
> >
> > which seems like a really annoying thing to have to do.  The whole point
> of
> > web-apps is that you define everything you need to in web.xml, so that you
> > don't have to change configuration files on the deployment system.  If
> this
> > is necessary, then what is the point of the servlet-mapping?  Surely
> tomcat
> > should generate the necessary ApJServMount lines in
> > "tomcat-apache.conf" when it starts up and reads web.xml?
> >
> > So, the big question is -
> >
> > * Is it possible to get apache to recognise servlet mappings defined in a
> > web-app's web.xml without explicitly making a modification to an apache
> > config file? If so, how?
> >
> > * If not can someone give a concrete example of a servlet mapping, and the
> > corresponding ApJServMount line that will get apache to recognise that
> > mapping?
> >
> > I hope this all makes sense - appreciation in advance,
> >
> > Colin
> >
> >
> 

Re: Apache - Tomcat - Servlet Mapping

Posted by Sam Newman <sa...@stamplets.com>.
Right - firstly, don't use JServ, use mod_jk. The file 'tomcat-apache.conf'
is generating directives for the old jserv module and its quite possible
this isn't complete. Secondly, Tomcat automatically generates the apache
directives based on your tomcat config for mod_jk (server.xml and web.xml's)
and puts it in a file called mod_jk.conf-auto, which you can include in your
httpd.conf for apache. For more in-depth information check the docs that
come with the tomcat distro - namely the mod_jk howto. The only thing to
watch when using mod)jk.conf-auto is that it only uses ajpv12, which is
slower than ajpv13 (and has a few bugs), so you'd probably want to mount
using the newer ajpv13.

sam
----- Original Message -----
From: "Colin Hawkett" <Co...@aetas.com.au>
To: <to...@jakarta.apache.org>
Sent: Wednesday, July 04, 2001 8:19 AM
Subject: Apache - Tomcat - Servlet Mapping


> Hi all,
>
>     This question seems to be popping up pretty regularly, but I couldn't
> extract a solution to my problem - namely: getting apache to recognise
> servlet-mappings. I am running tomcat 3.2.2 and apache 1.3.11 on win98.
>
> I have a web application packaged up as a war file and deployed to the
> webapps directory.  The web.xml file contains (among other things)
>
> <servlet>
>     <servlet-name>theServlet</servlet-name>
>     <servlet-class>com.myco.test.TheServlet</servlet-class>
> </servlet>
>
> <servlet-mapping>
>     <servlet-name>theServlet</servlet-name>
>     <url-pattern>/myServlet</url-pattern>
> </servlet-mapping>
>
> Now, I've confirmed that the mapping is correct by accessing it using the
> URL
>
> http://myserver:8080/<context_path>/myServlet    - This is fine, no
problems
>
> As I understand it, this is connecting to the tomcat web server (on port
> 8080), which is aware of the servlet mapping because it has read the
web.xml
> file for application.  And this is how I would expect it to work.  Cool.
>
> However, I don't want Tomcat to be my web server.  I want apache to be my
> webserver.  So I try to access the application using the URL
>
> http://myserver/<context_path>/myServlet    -  This fails!
>
> everything about the web-app works with apache except the servlet mapping,
> so I assume Apache is unaware of it.  The closest thing to a solution I
have
> found is that I need to add a line to 'tomcat-apache.conf' that looks
> something like -
>
> ApJServMount    /<context_path>/myServlet
> /<context_path>/servlet/theServlet
>
> which seems like a really annoying thing to have to do.  The whole point
of
> web-apps is that you define everything you need to in web.xml, so that you
> don't have to change configuration files on the deployment system.  If
this
> is necessary, then what is the point of the servlet-mapping?  Surely
tomcat
> should generate the necessary ApJServMount lines in
> "tomcat-apache.conf" when it starts up and reads web.xml?
>
> So, the big question is -
>
> * Is it possible to get apache to recognise servlet mappings defined in a
> web-app's web.xml without explicitly making a modification to an apache
> config file? If so, how?
>
> * If not can someone give a concrete example of a servlet mapping, and the
> corresponding ApJServMount line that will get apache to recognise that
> mapping?
>
> I hope this all makes sense - appreciation in advance,
>
> Colin
>
>