Re: How to forward external-ip-facing requests from ApacheHTTPServer to Tomcat?

2005-12-25 Thread Pulkit Singhal
Hi,

Thank you for the suggestion :)
I will give it a shot but I am really too deep into my setup to be doing any
big changes or something new! So while I try to google and learn more about
setting up mod_proxy, I would really appreciate if someone can tell me:

How do I go about configuring apache to forward the outside-facing-ip
requests to Tomcat through JK connector?

This should be something pretty standard for anyone who has ever moved
Tomcat from a local testing env. (localhost) to a production env. (real ip)
...right?

Thanks,
- Pulkit

On 12/23/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 use mod_proxy, much easier, and in our tests has proven to scale better,
 and you will wanna look for a directive called ProxyHostPreserve so that
 request.getServerName returns the right name,
 then the IP address will be stored in x-forwarded-for header in the HTTP
 request.

 Filip

  Hello Everyone,
 
  I have successfully configured Apache to forward requests to my Tomcat
  instance. But it does so...only for requests whose IP resolves to
  127.0.0.1
 
  If I try to access a page through apache server (that's actually on
  tomcat)
  with the outside-facing-ip of my computer it fails.
 
  For example:
  1) URL: http://12.34.56.78:666/blah/serveMe.html;FAILS with
 a
  404 (apache does not forward properly)
 
  2) URL: http://12.34.56.78:8080/blah/serveMe.html;   SUCCEEDS
  (tomcat seems to be ok when it gets the request directly, so it has to
 be
  a
  forwarding failure by apache in the previous case)
 
  3) URL: http://my.domain.com:666/blah/serveMe.html;  SUCCEEDS (I
 have
  
  my.domain.com mapped to 127.0.0.1 in my windows' hosts file)
 
  4) URL: http://localhost:666/blah/serveMe.html;SUCCEEDS
 
  I think this happens because the 1st request (the one with the outside
  facing ip) is not forwarded to Tomcat by apache.
  a) The apache error logs show that Apache is trying to look for the page
  in
  the wrong place
  b) The access logs ofcourse show a 404 because it can't find the page to
  serve
 
  Now, I have read a few threads and been on a few forums and apparently
 my
  worker.properties file is supposed to be as simple as this:
  
  worker.list=ajp13
  worker.ajp13.port=8009
  worker.ajp13.host=my.domain.com
  worker.ajp13.type=ajp13
  ---
 
  I also tried putting my outside-facing-ip and localhost as values for 
  worker.ajp13.host but it didn't seem to make any difference at all.
 
  In that case I must ask all of you:
  Question 1: How do I go about configuring apache to forward the
  outside-facing-ip requests to Tomcat? If it is not done in
  workers.properties...then where is it handled?
  Question 2: Or am I wrong and it is actually handled by
  workers.properties?
  Even then, how?
 
  Thanks in advance to all those who answer and all those who take the
 time
  to
  read this.
 
  Cheers,
  - Pulkit
 



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




Re: How to forward external-ip-facing requests from ApacheHTTPServer to Tomcat?

2005-12-25 Thread Pulkit Singhal
Hi Daniel,

Firstly, Thank you for your response.

Secondly, I must confess that I failed to grasp some of it due to my
ignorance of Unix. I understood the overall idea but found myself
scared/hesitant in implementing it as I'm using Win Server 2003. I'm a bit
perplexed by the contents you said I could add to workers2.properties as I
was not aware that fields were acceptable in such format. May be its the
type of connector you are using or maybe its just my lack of
experience/knowledge.

I did find a soulution of ***sorts** which I would like to share with all of
you so that you may comment/bash on its weaknesses/lamenesses thus helping
me in finding a better one:

*sigh* I just:

a) Removed the 127.0.0.1my.server.com mapping from the hosts file.

b) Added another Virtual Host to my server.xml file...resulting in something
like this:

!-- Define the default virtual host --
Host name=localhost ...
Listener className=org.apache.jk.config.ApacheConfig
  modJk=c:/apps/apache/apache2/modules/mod_jk-
apache-2.0.55.so /
/Host

!-- Define the hack virtual host for external-facing-ip
requests
Host name=my.server.com ...
Listener className=org.apache.jk.config.ApacheConfig
  modJk=c:/apps/apache/apache2/modules/mod_jk-
apache-2.0.55.so /
/Host

c) This happened to do the job, as now the file that Tomcat was
auto-generating for use by Apache had some lines that accounted for the
proper forwarding of external-facing-ip requests as well :)
These were not there earlier and the file I speak of is
tomcat_home\conf\auto\mod_jk.conf )

d) I still feel a bit jilted because my solution seems repetitive...there
are 2 virtual hosts that are located in the exact same place and to top it
off they have the same listeners inside them. They are identical in every
aspect.
I HAD tried entering Aliasmy.server.com/Alias under the localhost
virtual-host but that did not seem to do the job... so I settled for having
this repitition.

Do let me know of your thoughts on this...

Cheers,
- Pulkit

On 12/25/05, Daniel Blumenthal [EMAIL PROTECTED] wrote:

 I've set up my system so that Apache handles all requests, and forwards to
 the servlet when the path is www.mysite.com/myservlet/*.

 Following are my installation notes.
 (note that there's a slightly newer version of the JK connector)

 % tar zxf jakarta-tomcat-connectors-jk2-src-current.tar.gz
 % cd jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2
 % ./configure --with-apxs2=/usr/local/apache/bin/apxs
 % make
 % su
 % cp ../build/jk2/apache2/mod_jk2.so /usr/local/apache/modules
 % cp ../build/jk2/apache2/jkjni.so /usr/local/apache/modules

 make sure that httpd owns the apache directory

 tomcat/server.xml: make sure that the following connector is uncommented:
   Connector className=org.apache.ajp.tomcat4.Ajp13Connector port=8009
 minProcessors=5 maxProcessors=75 acceptCount=10 debug=0/

 create a workers2.properties file in /usr/local/apache/conf with the
 following contents:
   [logger]
   level=DEBUG
   [shm]
   file=/usr/local/apache/logs/jk2.shm
   size=1048576
   [channel.socket:localhost:8009]
   info=Ajp13 forwarding over socket
   tomcatId=localhost:8009
   [uri:/myservlet/*]
   context=/myservlet

 % touch /usr/local/apache/logs/jk2.shm
 % chown httpd /usr/local/apache/logs/jk2.shm
 % chgrp httpd /usr/local/apache/logs/jk2.shm

 add the following line to /usr/local/apache/conf/httpd.conf:
   LoadModule jk2_module modules/mod_jk2.so


 I hope this helps.

 Daniel


  -Original Message-
  From: Pulkit Singhal [mailto:[EMAIL PROTECTED]
  Sent: Sunday, December 25, 2005 1:12 PM
  To: Tomcat Users List
  Subject: Re: How to forward external-ip-facing requests from
  ApacheHTTPServer to Tomcat?
 
  Hi,
 
  Thank you for the suggestion :)
  I will give it a shot but I am really too deep into my setup
  to be doing any big changes or something new! So while I try
  to google and learn more about setting up mod_proxy, I would
  really appreciate if someone can tell me:
 
  How do I go about configuring apache to forward the
  outside-facing-ip requests to Tomcat through JK connector?
 
  This should be something pretty standard for anyone who has
  ever moved Tomcat from a local testing env. (localhost) to a
  production env. (real ip) ...right?
 
  Thanks,
  - Pulkit
 
  On 12/23/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  
   use mod_proxy, much easier, and in our tests has proven to scale
   better, and you will wanna look for a directive called
   ProxyHostPreserve so that request.getServerName returns the right
   name, then the IP address will be stored in x-forwarded-for
  header in
   the HTTP request.
  
   Filip
  
Hello Everyone,
   
I have successfully configured Apache to forward requests to my
Tomcat instance. But it does so...only for requests whose IP
resolves to
127.0.0.1
   

About Tomcat Connector

2005-12-25 Thread pzy peng
Hello: 
   I use Tomcat Connector to forward servlet requests from IIs6 to tomcat5, my 
config like this: 

file workers.properties.minimal 

worker.list=wlb 
worker.wlb.host=localhost 
worker.wlb.port=8009 
worker.wlb.type=ajp13 
worker.wlb.socket_keepalive=1 
worker.wlb.socket_timeout=36000 


file uriworkermap.properties 
/jsp-examples/*=wlb 
/servlets-examples/*=wlb 

It works fine; 

Now I want a persistence connection to servlet,the servlet like this: 

public class connServlet extends HttpServlet 
{ 
bool doconnect=false; 
  private void connect(HttpServletRequest req, HttpServletResponse res)throws 
IOException, ServletException 
 { 
try { 
   .. 
while (doconnect==true ) 
{ try { Thread.sleep(1L); } 
  catch (InterruptedException i) { break; } 
 }   
  } 
catch (Exception e){   System.out.println( e.toString());  } 
  } 
 
   public void doPost(HttpServletRequest req, HttpServletResponse res) throws 
ServletException, IOException { 
 String actionType =req.getHeader(ActionType); 
 if (actionType.equalsIgnoreCase(connect)   doconnect==false ) 
{  doconnect=true; connect(req,res);return;   } 
 if (actionType.equalsIgnoreCase(disconnect)  ) 
{  doconnect=false; return;  } 
. 
   
   } 

} 


It can work in tomcat5,but It can not work with Tomcat Connector in IIs6, 
if Tomcat Connector can not do this or the config file is wrong? 

thanks! 

peng 




__
赶快注册雅虎超大容量免费邮箱?
http://cn.mail.yahoo.com

About Tomcat Connector

2005-12-25 Thread pzy peng
__赶快注册雅虎超大容量免费邮箱?http://cn.mail.yahoo.com---BeginMessage---
Hello: 
   I use Tomcat Connector to forward servlet requests from IIs6 to tomcat5, my 
config like this: 

file workers.properties.minimal 

worker.list=wlb 
worker.wlb.host=localhost 
worker.wlb.port=8009 
worker.wlb.type=ajp13 
worker.wlb.socket_keepalive=1 
worker.wlb.socket_timeout=36000 


file uriworkermap.properties 
/jsp-examples/*=wlb 
/servlets-examples/*=wlb 

It works fine; 

Now I want a persistence connection to servlet,the servlet like this: 

public class connServlet extends HttpServlet 
{ 
bool doconnect=false; 
  private void connect(HttpServletRequest req, HttpServletResponse res)throws 
IOException, ServletException 
 { 
try { 
   .. 
while (doconnect==true ) 
{ try { Thread.sleep(1L); } 
  catch (InterruptedException i) { break; } 
 }   
  } 
catch (Exception e){   System.out.println( e.toString());  } 
  } 
 
   public void doPost(HttpServletRequest req, HttpServletResponse res) throws 
ServletException, IOException { 
 String actionType =req.getHeader(ActionType); 
 if (actionType.equalsIgnoreCase(connect)   doconnect==false ) 
{  doconnect=true; connect(req,res);return;   } 
 if (actionType.equalsIgnoreCase(disconnect)  ) 
{  doconnect=false; return;  } 
. 
   
   } 

} 


It can work in tomcat5,but It can not work with Tomcat Connector in IIs6, 
if Tomcat Connector can not do this or the config file is wrong? 

thanks! 

peng 




__
赶快注册雅虎超大容量免费邮箱?
http://cn.mail.yahoo.com---End Message---
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

about Tomcat Connector

2005-12-25 Thread what this
 Hello: 
   I use Tomcat Connector to forward servlet requests from IIs6 to 
tomcat5, my config like this: 

file workers.properties.minimal 

worker.list=wlb 
worker.wlb.host=localhost 
worker.wlb.port=8009 
worker.wlb.type=ajp13 
worker.wlb.socket_keepalive=1 
worker.wlb.socket_timeout=36000 


file uriworkermap.properties 
/jsp-examples/*=wlb 
/servlets-examples/*=wlb 

It works fine; 

Now I want a persistence connection to servlet,the servlet like this: 

public class connServlet extends HttpServlet 
{ 
bool doconnect=false; 
  private void connect(HttpServletRequest req, HttpServletResponse 
res)throws IOException, ServletException 
 { 
try { 
   .. 
while (doconnect==true ) 
{ try { Thread.sleep(1L); } 
  catch (InterruptedException i) { break; } 
 }   
  } 
catch (Exception e){   System.out.println( e.toString());  
} 
  } 
 
   public void doPost(HttpServletRequest req, HttpServletResponse res) 
throws ServletException, IOException { 
 String actionType =req.getHeader(ActionType); 
 if (actionType.equalsIgnoreCase(connect)   doconnect==false ) 
{  doconnect=true; connect(req,res);return;   } 
 if (actionType.equalsIgnoreCase(disconnect)  ) 
{  doconnect=false; return;  } 
. 
   
   } 

} 


It can work in tomcat5,but It can not work with Tomcat Connector in 
IIs6, 
if Tomcat Connector can not do this or the config file is wrong? 

thanks! 

peng 



-
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 

KDE 3.5 based advanced Linux Desktop released

2005-12-25 Thread Sagara Wijetunga
Tomahawk Computers (www.tomahawkcomputers.com),
Singapore, released an advanced multimedia centric
Linux desktop distribution featuring Intel Centrino
wireless technology, Zeroconf, High-Definition audio
and video playback, Bluetooth, Firewire, iPod access
and Podcasts. Complete suite of software also included
for home and corporate use featuring KDE 3.5, Firefox
1.5, Openoffice 2.0, etc. Tomahawk Desktop is
compatible with wide-screen monitors and flat panels
with aspect ratio 16:10, 16:9 in addition to popular
5:4 and 4:3.

Unique features of Tomahawk Desktop are, resistant to
Pharming/Phishing, fast Internet access, remote
serviceability and package user based simple yet very
effective package management system. No mounting and
unmounting hassle for accessing Thumbdrives, Digital
cameras, MP3 players, etc. 

Full functional evaluation version is available to
download via Bittorrent from http://www.tomahawkcomputers.com/download.html.




__ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/

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



Re: IllegalAccessException expected all the time, but only occurs sometimes. Why?

2005-12-25 Thread Sean Dockery
I found this on the web that seems to explain why the problem is
occurring...

http://opensource2.atlassian.com/projects/spring/browse/SPR-1518

Sean Dockery [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I have a TestCase as follows...

 package example;

 import java.util.Date;

 import junit.framework.TestCase;

 public class JavaBeanTest extends TestCase {

 public JavaBeanTest(String testName) {
  super(testName);
 }

 public void testThrowawayCopy() throws Exception {
  // setup
  final JavaBean bean = new JavaBean();
  bean.setId(1L);
  bean.setName(hello);
  // exercise
  final JavaBean copy = bean.throwawayCopy();
  bean.setExpired(new Date());
  copy.setId(2L);
  copy.setName(world);
  // verify
  assertEquals(id affected by copy.setId(long) call, 2L, bean.getId());
  assertEquals(name not affected by copy.setName(String) call, hello,
 bean.getName());
  assertNotNull(expired has changed, bean.getExpired());

  assertEquals(id has changed, 2L, copy.getId());
  assertEquals(name has changed, world, copy.getName());
  assertNull(expired not affected by bean.setExpired(Date) call,
 copy.getExpired());
 }

 public static Test suite() {
  TestSuite suite = new TestSuite();
  Test test = new JavaBeanTest(testThrowawayCopy);
  for (int i = 0; i  1000; i++) {
   suite.addTest(test);
  }
  return suite;
 }

 }

 ...for which I have a JavaBean class as follows...

 package example;

 import java.lang.reflect.Method;
 import java.util.Date;

 public class JavaBean {

 private long id;
 private String name;
 private Date expired;

 public JavaBean() {
  // default constructor for JavaBean
 }

 public Date getExpired() {
  return expired;
 }

 public void setExpired(Date expired) {
  this.expired = expired;
 }

 public long getId() {
  return id;
 }

 public void setId(long id) {
  this.id = id;
 }

 public String getName() {
  return name;
 }

 public void setName(String name) {
  this.name = name;
 }

 public JavaBean throwawayCopy() {
  return new ThrowawayJavaBean();
 }

 private final class ThrowawayJavaBean extends JavaBean {

  private boolean propagateId;

  private ThrowawayJavaBean() {
   copyProperties();
   propagateId = true;
  }

  private void copyProperties() {
   try {
Method[] methods = JavaBean.this.getClass().getDeclaredMethods();
for (int i = 0; i  methods.length; i++) {
 final Method source = methods[i];
 if (source.getName().startsWith(get)) {
  Method target = getClass().getMethod(set +
 source.getName().substring(3), new Class[] { source.getReturnType() });
  target.invoke(this, new Object[] { source.invoke(JavaBean.this, new
 Object[] {}) });
 }
}
   } catch (Exception e) {
throw unchecked(e);
   }
  }

  public void setId(long id) {
   super.setId(id);

   if (propagateId) {
JavaBean.this.setId(id);
   }
  }

  private RuntimeException unchecked(Exception e) {
   if (e instanceof RuntimeException) {
return (RuntimeException) e;
   }
   return new RuntimeException(e);
  }

 }

 }


 This code has been adapted from some code in a production application at 
 my
 work.  The production code actually uses Spring's
 BeanUtils.copyProperties(Object source, Object target) method in the
 ThrowawayJavaBean constructor, but we should be accomplishing the same 
 thing
 by using reflection directly.

 As you can see, the ThrowawayJavaBean class is a *private* nested class.
 During load tests of the production application, the production code
 (running in Tomcat) *sometimes* experiences an IllegalAccessException due 
 to
 the fact that we're using reflection against a private nested class.  The
 problem has never occurred when the visibility of the nested class is
 public.  Additionally, I have *never* seen the exception occur in the 
 JUnit
 TestRunner with neither the code I have presented above, nor the 
 production
 code itself.

 My confusion lies with the question of why the IllegalAccessException 
 occurs
 only infrequently in the production code running under Tomcat instead of
 always occurring.  That is, why doesn't (wouldn't) it happen all the
 time--for example, in my TestCase?

 Thanks for your time. 




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



RE: How to forward external-ip-facing requests from ApacheHTTPServer to Tomcat?

2005-12-25 Thread Daniel Blumenthal
Pulkit,

I don't have any experience with WinServer (strictly a Linux man), but if it
works...  Also, it was my understanding (last time I checked) that no one's
maintaining the old jk connector code - possibly because your method is now
the recommended way?  I don't know.

Good luck!

Daniel

 -Original Message-
 From: Pulkit Singhal [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, December 25, 2005 6:29 PM
 To: Tomcat Users List; [EMAIL PROTECTED]
 Subject: Re: How to forward external-ip-facing requests from 
 ApacheHTTPServer to Tomcat?
 
 Hi Daniel,
 
 Firstly, Thank you for your response.
 
 Secondly, I must confess that I failed to grasp some of it 
 due to my ignorance of Unix. I understood the overall idea 
 but found myself scared/hesitant in implementing it as I'm 
 using Win Server 2003. I'm a bit perplexed by the contents 
 you said I could add to workers2.properties as I was not 
 aware that fields were acceptable in such format. May be its 
 the type of connector you are using or maybe its just my lack 
 of experience/knowledge.
 
 I did find a soulution of ***sorts** which I would like to 
 share with all of you so that you may comment/bash on its 
 weaknesses/lamenesses thus helping me in finding a better one:
 
 *sigh* I just:
 
 a) Removed the 127.0.0.1my.server.com mapping from the 
 hosts file.
 
 b) Added another Virtual Host to my server.xml 
 file...resulting in something like this:
 
 !-- Define the default virtual host --
 Host name=localhost ...
 Listener 
 className=org.apache.jk.config.ApacheConfig
   
 modJk=c:/apps/apache/apache2/modules/mod_jk-
 apache-2.0.55.so /
 /Host
 
 !-- Define the hack virtual host for external-facing-ip
 requests
 Host name=my.server.com ...
 Listener 
 className=org.apache.jk.config.ApacheConfig
   
 modJk=c:/apps/apache/apache2/modules/mod_jk-
 apache-2.0.55.so /
 /Host
 
 c) This happened to do the job, as now the file that Tomcat 
 was auto-generating for use by Apache had some lines that 
 accounted for the proper forwarding of external-facing-ip 
 requests as well :) These were not there earlier and the file 
 I speak of is tomcat_home\conf\auto\mod_jk.conf )
 
 d) I still feel a bit jilted because my solution seems 
 repetitive...there are 2 virtual hosts that are located in 
 the exact same place and to top it off they have the same 
 listeners inside them. They are identical in every aspect.
 I HAD tried entering Aliasmy.server.com/Alias under the 
 localhost virtual-host but that did not seem to do the job... 
 so I settled for having this repitition.
 
 Do let me know of your thoughts on this...
 
 Cheers,
 - Pulkit
 
 On 12/25/05, Daniel Blumenthal [EMAIL PROTECTED] wrote:
 
  I've set up my system so that Apache handles all requests, and 
  forwards to the servlet when the path is www.mysite.com/myservlet/*.
 
  Following are my installation notes.
  (note that there's a slightly newer version of the JK connector)
 
  % tar zxf jakarta-tomcat-connectors-jk2-src-current.tar.gz
  % cd jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2
  % ./configure --with-apxs2=/usr/local/apache/bin/apxs
  % make
  % su
  % cp ../build/jk2/apache2/mod_jk2.so /usr/local/apache/modules % cp 
  ../build/jk2/apache2/jkjni.so /usr/local/apache/modules
 
  make sure that httpd owns the apache directory
 
  tomcat/server.xml: make sure that the following connector 
 is uncommented:
Connector 
 className=org.apache.ajp.tomcat4.Ajp13Connector port=8009
  minProcessors=5 maxProcessors=75 acceptCount=10 debug=0/
 
  create a workers2.properties file in 
 /usr/local/apache/conf with the 
  following contents:
[logger]
level=DEBUG
[shm]
file=/usr/local/apache/logs/jk2.shm
size=1048576
[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
tomcatId=localhost:8009
[uri:/myservlet/*]
context=/myservlet
 
  % touch /usr/local/apache/logs/jk2.shm % chown httpd 
  /usr/local/apache/logs/jk2.shm % chgrp httpd 
  /usr/local/apache/logs/jk2.shm
 
  add the following line to /usr/local/apache/conf/httpd.conf:
LoadModule jk2_module modules/mod_jk2.so
 
 
  I hope this helps.
 
  Daniel
 
 
   -Original Message-
   From: Pulkit Singhal [mailto:[EMAIL PROTECTED]
   Sent: Sunday, December 25, 2005 1:12 PM
   To: Tomcat Users List
   Subject: Re: How to forward external-ip-facing requests from 
   ApacheHTTPServer to Tomcat?
  
   Hi,
  
   Thank you for the suggestion :)
   I will give it a shot but I am really too deep into my 
 setup to be 
   doing any big changes or something new! So while I try to 
 google and 
   learn more about setting up mod_proxy, I would really 
 appreciate if 
   someone can tell me:
  
   How do I go about configuring apache to forward the 
   outside-facing-ip requests to Tomcat through JK connector?
  
   This should be 

Re: How to load a class when tomcat starts

2005-12-25 Thread Anoop kumar V
Here is some code that might help you:

import java.io.*;
import java.net.*;
import java.util.*;

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

public class InitServlet extends HttpServlet {

public void init(ServletConfig config) throws ServletException {
super.init(config);
System.out.print(Loading classes in the JVM );
try{
Class.forName(com.m2.isr2.Database);
System.out.print(.);
Class.forName(com.m2.isr2.platform.ActiveDirectory);
System.out.print(.);
} catch (ClassNotFoundException e)
{
System.out.println(e);
e.printStackTrace(System.out);
}
System.out.println( Completed!);
}

Hope that helps you...
Anoop


On 12/15/05, vineesh kumar [EMAIL PROTECTED] wrote:

 Dear anoop,
Wat i actually need is the same as u hav done, to load a config
 file.
 so i created a GetProperties class, which simlpy read a file and
 initializes some static variables.
 Then i tried to run the application but, the fields are still null.and
 the application is not connecting to the database
 can u just quote the code snippet u had used?
 thanks in advance
 vineesh
 On 12/10/05, Anoop kumar V [EMAIL PROTECTED] wrote:
  The way we have done is to load a servlet during startup (very easy to
 do in
  web.xml) and through this servlet use Class.forName(classname) to load
 the
  required classes into memory.
 
  The reason we do this is to read a .properties file and store all the
 name
  value pairs in a hashmap to be retrieved by various classes at run time.
 
  Hope that helps,
  Anoop
 
  On 12/10/05, Richard Mixon [EMAIL PROTECTED] wrote:
  
   Vineesh,
  
   You should probably  use a ServletContextListener . It will give you
   control
   when the web application starts and when it ends, among otherevents.
 It is
   pretty well described in the servlet spec and is pretty simple.
  
   HTH -Richard
  
   -Original Message-
   From: vineesh kumar [mailto:[EMAIL PROTECTED]
   Sent: Saturday, December 10, 2005 12:22 AM
   To: users@tomcat.apache.org
   Subject: How to load a class when tomcat starts
  
   Hi all,
  
   I need to load a java class when tomcat starts, which will initializes
   some
   configuration files and so i can use the fields in the class throught
 the
   environment.How can i do this.?
   Actually I am working on a distributed application, so the
 configuration
   files may change frequently but once the system is initialized it will
 not
   change until shut down.
   regards
   vineesh
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
  --
  Thanks and best regards,
  Anoop
 
 




--
Thanks and best regards,
Anoop


Re: About possible memory leak in Tomcat 5.x

2005-12-25 Thread Anoop kumar V
I think this is a great finding - it will certainly help all those teams
faced with the Out of memory errors which curiously pops up oly after we
move the code to production..

I hope you will have the tomcat developers look into this by sending this to
tomcat-developers forum.

THanks,
Anoop

On 12/19/05, Andrievsky Dmaitry [EMAIL PROTECTED] wrote:

 Hello users,

 About a half a year ago I've found that my webapp works fine in
 development environment, but leaks memory in production one.
 I've searched through all the code, found a few minor errors, but it
 didn't help.
 (of course, tag pooling are disabled completely)

 So then i've tried to use profiler, looking on alien classes.
 (I've tried before too, but my attention was concentrated on my own
 classes)

 And then i've found lots of
 org.apache.jasper.runtime.PageContextImpl
 from which there were a lot of references to the objects, that i've
 treated as dead.


 All PageContextImpl's lived at
 org.apache.jasper.runtime.JspFactoryImpl.pool


 There are property of org.apache.jasper.runtime.JspFactoryImpl, named
 USE_POOL, which rules pool usage, but it is private,
 and i've not found any way to set it to false from outside.
 Initially it's true.

 So, i've set it to false directly in code,
 rebuilt tomcat and replaced files ${CATALINA_HOME}/common/lib/jasper-*.jar
 from production environment with fresh ones.

 So, it seems that the problem is successfully solved.
 As far as I can see there no more memory leakage.

 I think it would be useful to allow users to set property of
 org.apache.jasper.runtime.JspFactoryImpl.USE_POOL from config files or
 in any other way, without rebuilding entire tomcat application.

 P.S.
 In fact, I think, it's not REAL memory leak - memory usage, may be,
 will stop grow on some large value (2+ GB, when pool become full), but i
 have not such
 amount of memory.
 Now memory usage about 100-200 mb after full gc, depending on amount
 of currently working users.

 P.P.S What seems to me interesting.
 Although before putting PageContextImpl into pool JspFactoryImpl calls
 pc.release(), and inside the method all links must become null (or
 not?..) and referenced objects must become available to gc, they are not.
 May be it is the root of the problem?..

 BTW disabling of pool solves the problem completely...


 --
 Best regards,
 Dmitry Andrievskymailto:[EMAIL PROTECTED]



















































































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




--
Thanks and best regards,
Anoop