You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Craig Smithpeters <cr...@bsd.nmrcf.com> on 2001/03/08 16:31:31 UTC

A solution to the multiple calls of init problem

I have had the problem of servlets that are loaded on startup being loaded
again (init method firing again) on their first access by a client. This
issue has been discussed a lot on the list over the last year and I have not
seen a solution that would work for me.

I have found that if you set the <servlet-name> entry equal to the
<servlet-class> entry in the web app's web.xml file that it will solve the
problem.

Evidently, Tomcat is determining what servlets are loaded by checking the
servlet-name entries and not the servlet-class entries.  I think this should
be considered a bug.

Craig Smithpeters
Senior Software Engineer
Nielsen Media Research
craig@bsd.nmrcf.com



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


Re: trouble compiling mod_jk.so

Posted by Brian P Millett <bp...@ec-group.com>.
Pilho Kim wrote:

> Hi,
>
> Retry with Apache 1.3.14 or 1.3.17
>
> On Fri, 23 Mar 2001, Jim Yiu wrote:
>
> >
> > Hi,
> >   I am trying to compile the Tomcat-Apache plugin for Solaris and am unsuccessful,, I
> > am trying
> > to follow the mod_jk faq but it does not explain what to do when there are compile
> > errors.
>

[snip]

> > apxs:Break: Command failed with rc=16711680
> >
> >
> > I am running the apxs script from within the apache directory [path to
> > apache]/apache/bin  and I have Perl 5.004_04 installed, i am using
> > SunOS 5.7 with a SPARC station 20 ..
> >
> > Could someone point out the problem ?  Any help is appreciated.

The real problem here is that the apache supplied apxs is not correct.  You need to edit it and fix
the
$CFG_CFLAGS_SHLIB, $CFG_LD_SHLIB & $CFG_LDFLAGS_SHLIB variables as follows:

vlad: gdiff -Nu0 /var/tmp/bpm/apxs.~1~ /opt/apache/bin/apxs
--- /var/tmp/bpm/apxs.~1~       Fri Mar 16 09:29:33 2001
+++ /opt/apache/bin/apxs        Fri Mar 16 15:44:42 2001
@@ -77,3 +77,3 @@
-my $CFG_CFLAGS_SHLIB  = q();      # substituted via Makefile.tmpl
-my $CFG_LD_SHLIB      = q();          # substituted via Makefile.tmpl
-my $CFG_LDFLAGS_SHLIB = q(); # substituted via Makefile.tmpl
+my $CFG_CFLAGS_SHLIB  = q(-fPIC -DSHARED_MODULE);      # substituted via Makefile.tmpl
+my $CFG_LD_SHLIB      = q(ld);          # substituted via Makefile.tmpl
+my $CFG_LDFLAGS_SHLIB = q(-G); # substituted via Makefile.tmpl

--
Brian Millett
Enterprise Consulting Group   "Shifts in paradigms
(314) 205-9030               often cause nose bleeds."
bpm@ec-group.com                           Greg Glenn



Re: trouble compiling mod_jk.so

Posted by Pilho Kim <ph...@math.soongsil.ac.kr>.
Hi,

Retry with Apache 1.3.14 or 1.3.17

Regards,
Kim


On Fri, 23 Mar 2001, Jim Yiu wrote:

> 
> Hi,
>   I am trying to compile the Tomcat-Apache plugin for Solaris and am unsuccessful,, I
> am trying
> to follow the mod_jk faq but it does not explain what to do when there are compile
> errors.
> For Solaris, there is no binary available and we have to create our own shared
> object.
> 
> Here is the problem:
>  after running
> apxs -o mod_jk.so -DSOLARIS -I../jk -I/usr/java/include -I/usr/java/include/solaris
> -lposix4 -c  *.c ../jk/*.c
> 
> the object files seem to compile fine, and they exist in the directory after
> compiling,  but there seems to be a link error and the ".so" file
> is never created..
> 
> here is the error..
> 
> [top snipped]
> gcc -DSOLARIS2=251 -DUSE_EXPAT -I../lib/expat-lite -DNO_DL_NEEDED
> -I/d/d1/apache_1.3.12/include -I../jk -I/usr/java/include -I/usr/java/include/solaris
> -DSOLARIS  -c ../jk/jk_util.c
> gcc -DSOLARIS2=251 -DUSE_EXPAT -I../lib/expat-lite -DNO_DL_NEEDED
> -I/d/d1/apache_1.3.12/include -I../jk -I/usr/java/include -I/usr/java/include/solaris
> -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
> apxs:Break: Command failed with rc=16711680
> 
> 
> I am running the apxs script from within the apache directory [path to
> apache]/apache/bin  and I have Perl 5.004_04 installed, i am using
> SunOS 5.7 with a SPARC station 20 ..
> 
> Could someone point out the problem ?  Any help is appreciated.
> 
> Jim
> 
> 
> 
> 


trouble compiling mod_jk.so

Posted by Jim Yiu <Ji...@msdw.com>.
Hi,
  I am trying to compile the Tomcat-Apache plugin for Solaris and am unsuccessful,, I
am trying
to follow the mod_jk faq but it does not explain what to do when there are compile
errors.
For Solaris, there is no binary available and we have to create our own shared
object.

Here is the problem:
 after running
apxs -o mod_jk.so -DSOLARIS -I../jk -I/usr/java/include -I/usr/java/include/solaris
-lposix4 -c  *.c ../jk/*.c

the object files seem to compile fine, and they exist in the directory after
compiling,  but there seems to be a link error and the ".so" file
is never created..

here is the error..

[top snipped]
gcc -DSOLARIS2=251 -DUSE_EXPAT -I../lib/expat-lite -DNO_DL_NEEDED
-I/d/d1/apache_1.3.12/include -I../jk -I/usr/java/include -I/usr/java/include/solaris
-DSOLARIS  -c ../jk/jk_util.c
gcc -DSOLARIS2=251 -DUSE_EXPAT -I../lib/expat-lite -DNO_DL_NEEDED
-I/d/d1/apache_1.3.12/include -I../jk -I/usr/java/include -I/usr/java/include/solaris
-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
apxs:Break: Command failed with rc=16711680


I am running the apxs script from within the apache directory [path to
apache]/apache/bin  and I have Perl 5.004_04 installed, i am using
SunOS 5.7 with a SPARC station 20 ..

Could someone point out the problem ?  Any help is appreciated.

Jim




Re: Catalina vs.preServletInit et. al.

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 23 Mar 2001, T. Park wrote:

> 
> Hello,
> 
> I'm a newbie to the Catalina code line and need some guidance (lots actually)...
> 
> I have a custom interceptor that works really well with Tomcat 3.x that does
> some special setup work
> in the preServletInit/postServletInit, preService/postService and
> preServletDestroy/postServletDestroy methods of
> the special RequestInterceptor.
> 
> My problem is determining functional equivalents to these in Catalina.
> 

The model for customized request processing in Catalina is quite a bit
different than Tomcat 3.x.  Fundamentally, you use a Valve for most
processing.  Valves implement the "chain of responsibility" pattern from
the GoF book -- and once you understand them, you will also understand how
Filters work in the servlet 2.3 spec :-).  However, Valves don't directly
do what you're asking for here.

The Context element supports the registration of InstanceListener objects,
which receive InstanceEvent notifications of the six events you mentioned
above, plus beforeFilter and afterFilter (2.3 specific).  This follows the
usual JavaBeans patterns for event notification.

>From server.xml, you can configure instance listeners by nesting a new
element inside the <Context>

	<Context path="/..." ...>
		<InstanceListener className="com.mycompany.MyListener/>
	</Context>

> Can anyone give me any pointers - I sort of lost my way in the source code and
> documentation
> (primarily due to existing references to 'interceptors' in both comments and
> docs.)
> 
> Is there still a way to do some pre/post processing for each corresponding
> servlet call (init,destroy and service).
> 
> I looked at VavleBase and couldn't see any direct comparison.
> 
> -Thom
> 
> 
> 
> 

Craig McClanahan


Catalina vs.preServletInit et. al.

Posted by "T. Park" <tp...@borland.com>.
Hello,

I'm a newbie to the Catalina code line and need some guidance (lots actually)...

I have a custom interceptor that works really well with Tomcat 3.x that does
some special setup work
in the preServletInit/postServletInit, preService/postService and
preServletDestroy/postServletDestroy methods of
the special RequestInterceptor.

My problem is determining functional equivalents to these in Catalina.

Can anyone give me any pointers - I sort of lost my way in the source code and
documentation
(primarily due to existing references to 'interceptors' in both comments and
docs.)

Is there still a way to do some pre/post processing for each corresponding
servlet call (init,destroy and service).

I looked at VavleBase and couldn't see any direct comparison.

-Thom




Re: A solution to the multiple calls of init problem

Posted by Milt Epstein <me...@uiuc.edu>.
On Thu, 8 Mar 2001, Craig Smithpeters wrote:

> I have had the problem of servlets that are loaded on startup being
> loaded again (init method firing again) on their first access by a
> client. This issue has been discussed a lot on the list over the
> last year and I have not seen a solution that would work for me.
> 
> I have found that if you set the <servlet-name> entry equal to the
> <servlet-class> entry in the web app's web.xml file that it will
> solve the problem.
> 
> Evidently, Tomcat is determining what servlets are loaded by
> checking the servlet-name entries and not the servlet-class entries.
> I think this should be considered a bug.

Actually, if I understand you correctly, this is the known, desired
(and useful) behavior, and is all spelled out in the spec (I don't
know if there's one section of the spec that talks about it, but
search for "definition" and "instance").  That is, when you define a
servlet, it is the servlet-name that defines the servlet, not the
servlet-class.  You can have multiple servlet definitions involving
the same servlet-class and different servlet-name's, and they are
considered distinct (i.e. different init-param's, different servlet
instances, and hence init will be called multiple times, as you are
experiencing).  As to which servlet definition is used, it all depends
on what servlet-name is specified in the URL (and if any
servlet-mapping's are defined in the servlet definition).  Also, this
can happen even when you only have one servlet definition, because
calling the servlet using the servlet-class directly (i.e. not the
servlet-name) is distinct as well.  For example, if in webapp myapp
you define a servlet with servlet-name foo and servlet-class
com.my.foo, the following lead to distinct servlet instances:

http://www.my.com/myapp/servlet/foo
http://www.my.com/myapp/servlet/com.my.foo

and will cause init to be called twice on the underlying servlet-class.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu


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