Hi Sachin & others,

I have resolved the problem. The problem was not in any code but due to
a different configuration we had in the tomcat/conf/server.xml for some
other feature.

Becoz of this the applications were being initialized two times each.
Now I am using the same old InitPlugIn code and it works fine on Linux
also.

Sorry for trouble and thanks a lot for your help.

Regards,
Uma.

-----Original Message-----
From: Uma Yarakaraju [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 13, 2004 1:48 PM
To: 'Struts Users Mailing List'
Subject: RE: PlugIn/ ActionServlet init() method called 2 times in Linux




Hi Sachin,

Thanks a lot for your reply. 

But creating another servlet for initialization doesn't work still.
Tomcat is initializing that servlet also twice on Linux and only once on
windows.

Below is my class that extends HttpServlet:

import javax.servlet.http.*;
import javax.servlet.*;

public class MyInitServlet extends HttpServlet{
        private static int const_count = 0;
        private static int dest_count = 0;
        private static int initServ_count = 0;
        private static int init_count = 0;

        public MyInitServlet() {
                System.out.println(
                        "UMA: MyInitServlet-> constructor called,
constr_count =" 
                                                        +
const_count++);
        }

        public  void init(ServletConfig config) throws ServletException
{                                       
                System.out.println("UMA: MyInitServlet ->init(..)
called, initServ_count =" 
                                                        +
initServ_count++);              
        }
        
        public void init() throws ServletException {

                System.out.println("UMA: MyInitServlet ->init called,
init_count =" 
                                                        + init_count++);

        }

         public void destroy() {
                System.out.println("Uma: MyInitServlet -> destroy
called, dest_count =" 
                                                        + dest_count++);

        }
}

Here is web.xml skeleton:
 <servlet>
      <servlet-name>InitServlet</servlet-name>
      <display-name>InitServlet</display-name>
      <servlet-class>MyInitServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
  </servlet>

And here are the tomcat logs on Linux:

        Starting service Tomcat-Standalone
        Apache Tomcat/4.1.18
        WebappClassLoader:
validateJarFile(/usr/local/tomcat/webapps/struts-blank/WEB-IN
        F/lib/servlet.jar) - jar not loaded. See Servlet Spec 2.3,
section 9.7.2. Offend
        ing class: javax/servlet/Servlet.class
        UMA: MyInitServlet-> constructor called, constr_count =0
        UMA: MyInitServlet ->init(..) called, initServ_count =0
        WebappClassLoader:
validateJarFile(/usr/local/tomcat/webapps/struts-blank/WEB-IN
        F/lib/servlet.jar) - jar not loaded. See Servlet Spec 2.3,
section 9.7.2. Offend
        ing class: javax/servlet/Servlet.class
        UMA: MyInitServlet-> constructor called, constr_count =0
        UMA: MyInitServlet ->init(..) called, initServ_count =0
        Sep 13, 2004 1:38:11 PM org.apache.jk.common.ChannelSocket init
        INFO: JK2: ajp13 listening on /0.0.0.0:8009
        Sep 13, 2004 1:38:11 PM org.apache.jk.server.JkMain start
        INFO: Jk running ID=0 time=0/38
config=/usr/local/tomcat/conf/jk2.properties

Did anyone get this before? Any ideas on why this is happening? Now I
will try option 2 in your mail below.

Thanks again,
Uma.


-----Original Message-----
From: Sachin Bhutada [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 13, 2004 11:55 AM
To: 'Struts Users Mailing List'
Subject: RE: PlugIn/ ActionServlet init() method called 2 times in Linux



hi Uma,
        If the same application is working fine with tomcat + windows
and
not working with tomcat+ linux, try out follwoing,it may solve ur
problem
for time being.
                1)Use one more servlet and integrate with struts instead
of
using plug-in or extending
ActionServlet.This but be nothing but workaround to the given probs.
Ideally
u shud go for plug-in. 
                2)In the plugin class,apply some checks if the db
connections are already created dont create it again. 

sachin 
xorant, mumbai


-----Original Message-----
From: Uma Yarakaraju [mailto:[EMAIL PROTECTED]
Sent: Monday, September 13, 2004 11:58 AM
To: [EMAIL PROTECTED]
Subject: PlugIn/ ActionServlet init() method called 2 times in Linux 



Hi,
 
Can anyone pl help on my below mail? Some more things I noticed are:
 
I downloaded the latest struts-1.2.2 zip. To the struts-blank.war I
added a simple plugin class (that prints system.out.println in the
constructor, init, and destroy methods) called MyPlugIn.java. I deployed
the struts-blank in tomcat-4.1.18 on WIN 2k. Works fine where the print
statements are printed once. 
 
Whereas in tomcat-4.1.18 on Linux they are printed 2 times each.
 
I tried using an extended ActionServlet class for initialization. Even
in this constructor, init() and destroy() methods are called 2 times on
Linux and once on windows.
 
I did really appreciate any help as our application has to go live and
this could affect the performance of our application (as the DB
connections are created multiple times).
 
Can anyone pl suggest ways to initialize a struts webapp other than
plugIn and extended ActionServlet.
 
Thanks & Regards,
Uma.
-----Original Message-----
From: Uma Yarakaraju [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 09, 2004 7:04 PM
To: [EMAIL PROTECTED]
Subject: PlugIn's init(...) method is called multiple times in Linux 



Hi, 

I have 3 struts based applications running in Tomcat 4.1.18. I have
deployed them in Red Hat Linux Advanced Server 3.0 platform.

In all my 3 apps, I have implemented the Struts's PlugIn interface for
doing the initialization tasks and configured them in the
struts-config.xml as shown below (for one of the apps):


  <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> 
    <set-property 
        property="pathnames" 
        value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> 
  </plug-in> 

  <plug-in className="com.a.b.c.d.e.InitPlugIn"> 
        <set-property property="filepath" value="/config/app.properties"
/> 
  </plug-in> 

In the init(ActionServlet servlet, ModuleConfig config) method of these
plugin classes I create DB connections. 

On Windows (2k) platform it works fine. That is the init(.) method is
called once for each app/plugin and the configured number of connections
are created.

But when I deploy them on our target Linux platform the init(.) method
of 2 apps is called 2 times and the other app is called 4 times. I had
some debug statements in the init(.) method of PlugIn class and they
show it is called multiple times.

Pl give your ideas on how I can resolve this. Any help will be highly
appreciated. 

Thanks in advance, 
Uma. 





Confidentiality Notice 

The information contained in this electronic message and any attachments
to this message are intended
for the exclusive use of the addressee(s) and may contain confidential
or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
[EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.



Confidentiality Notice 

The information contained in this electronic message and any attachments
to this message are intended
for the exclusive use of the addressee(s) and may contain confidential
or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
[EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.



Confidentiality Notice 

The information contained in this electronic message and any attachments to this 
message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged 
information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL 
PROTECTED] immediately
and destroy all copies of this message and any attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to