You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Uma Yarakaraju <um...@wipro.com> on 2004/09/09 15:33:48 UTC

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.

One more thing I noticed is: I had put a static int variable in the
PlugIn classes and am incrementing it in the constructor and printing
it. Every time the value is printed as 0 (initial value) only and it is
not getting incremented though the plugin is called multiple times.

What must be wrong? Is it a problem with my code? If so I don't
understand how it works fine on Windows. and I am sure there is no other
place where mistakenly the DB connections could be created. 

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 Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

Re: PlugIn/ ActionServlet init() method called 2 times in Linux

Posted by Joe Germuska <Jo...@Germuska.com>.
>Can anyone pl suggest ways to initialize a struts webapp other than
>plugIn and extended ActionServlet.

If you are using Servlet 2.3 or newer, you could use a ServletContextListener
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContextListener.html

Although from what you describe, I would thing that the real problem 
is that Tomcat is initializing the servlet twice, which means that 
even the ServletContextListeners might get initialized twice.

I would double-check your assumption that the difference is 
platform-specific; perhaps it's more a difference in how the two 
different Tomcat installations are configured?  If that's not the 
case, then the only other difference between Tomcat on Windows and 
Tomcat on Linux is the manner in which Tomcat is actually started up.

Hope this helps,
	Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn 
back; I'll know I'm in the wrong place."
    - Carlos Santana

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


PlugIn/ ActionServlet init() method called 2 times in Linux

Posted by Uma Yarakaraju <um...@wipro.com>.
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:uma.raju@wipro.com] 
Sent: Thursday, September 09, 2004 7:04 PM
To: user@struts.apache.org
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 Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

RE: PlugIn's init(...) method is called multiple times in Linux

Posted by Uma Yarakaraju <um...@wipro.com>.
Hi David,

I have the struts.jar and other jars located in each of the individual
webapp's WEB-INF/lib directories.

Thanks & Regards,
Uma.

-----Original Message-----
From: David G. Friedman [mailto:humble@ix.netcom.com] 
Sent: Friday, September 10, 2004 8:29 AM
To: Struts Users Mailing List; uma.raju@wipro.com
Subject: RE: PlugIn's init(...) method is called multiple times in Linux



Uma,

Do you have the struts jar located in a shared central folder on the
Redhat
system or in each individual webapp's WEB-INF/lib directory?

Regards,
David

-----Original Message-----
From: Uma Yarakaraju [mailto:uma.raju@wipro.com]
Sent: Thursday, September 09, 2004 9:34 AM
To: user@struts.apache.org
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.

One more thing I noticed is: I had put a static int variable in the
PlugIn classes and am incrementing it in the constructor and printing
it. Every time the value is printed as 0 (initial value) only and it is
not getting incremented though the plugin is called multiple times.

What must be wrong? Is it a problem with my code? If so I don't
understand how it works fine on Windows. and I am sure there is no other
place where mistakenly the DB connections could be created.

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
Mailadmin@wipro.com 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 Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

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


RE: PlugIn's init(...) method is called multiple times in Linux

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Uma,

Do you have the struts jar located in a shared central folder on the Redhat
system or in each individual webapp's WEB-INF/lib directory?

Regards,
David

-----Original Message-----
From: Uma Yarakaraju [mailto:uma.raju@wipro.com]
Sent: Thursday, September 09, 2004 9:34 AM
To: user@struts.apache.org
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.

One more thing I noticed is: I had put a static int variable in the
PlugIn classes and am incrementing it in the constructor and printing
it. Every time the value is printed as 0 (initial value) only and it is
not getting incremented though the plugin is called multiple times.

What must be wrong? Is it a problem with my code? If so I don't
understand how it works fine on Windows. and I am sure there is no other
place where mistakenly the DB connections could be created.

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
Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.


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