Out of Memory on Jakarta Tomcat 5.0.19, jdk1.5.0_04

2005-09-20 Thread NoKideen
Hi all, I'm new in this mailling list

I'm currently end up  ways to solve problem out of memory in tomcat

this is
startup script in my Linux Fedora Core 2

CATALINA_OPTS= -Djava.awt.headless=true -server -Xss128k -Xincgc -Xms256m 
-Xmx256m

CPU is on 1Giga Memory

and the problem out of memory, can't happen in specific times, can't happen in 
specific pages (both servlet and JSP), currently happen in Random time/pages, 
usually 1 Weeks after startup.

Server run 24 Hours/day for development only


usually I use ant for reload servlet, after I change the java code

#ant reload

build.xml

- cut -
taskdef name=reloadclassname=org.apache.catalina.ant.ReloadTask/


what should I do ?

Thanks in Advance,

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



Re: Out of Memory on Jakarta Tomcat 5.0.19, jdk1.5.0_04

2005-09-20 Thread NoKideen
On Tuesday 20 September 2005 20:56, Allistair Crossley wrote:
 You'll almost likely find that the reload via Ant does not free up all
 resources and so each time you perform a reload you'll be leaking some
 memory resulting in OOME after a week.

 3 things to do;

 Get a profiler to see where you may be losing memory.

I will do this,

 Ensure no resource/references are held onto, dispose references correctly
how do I know Resource still in memory, usually in my servlet I always close 
my database connection, 

usually I use String to collect output first and out.print() those String
example :
String a=;
a+=Test 1;
a+=Test 2;
// very long , and almost 1 page 

out.println(a);

can this cause out of memory problem ?

I though there is Garbage Collector, as usually in Java Native Program ? 
if Garbage Collector is not working, how do I free up Resource in servlet ?


 Hard restart Tomcat when OOME occur.

if ant reload, cause the problem, 

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



Re: Out of Memory on Jakarta Tomcat 5.0.19, jdk1.5.0_04

2005-09-20 Thread NoKideen

On Tuesday 20 September 2005 21:11, Sonja Löhr wrote:
 I know this problem very well, since I worked on a very memory-consuming
 app where I coulnd't even reload twice. It has nothing to do with ant,
 and i think I also had such a case with tomcat 5.5  (now working on
 normal webapps ;-)

what you mean by normal webapps ? it's a html ?

 Cautiously, I would never reload via manager (or perhaps once) in
 production.

I'd really confuse, what is the real cause ?
Its the development (frequently use ant/ web manager ) to reload the 
webapps  ?

or 

Garbage collector problem ? every pages of servlet loaded, its use many 
library, Class file, example my own class :

public test servlet extends HttpServlet
.. doGet(...) {
...
PgInt pg = new PgInt();


pg.close();
pg = null;

}

It that means pg Objects is Destroyed,

or I must do something else ?

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



Can we Trust Runtime.freeMemory() information on tomcat

2005-09-20 Thread NoKideen
hi,

Can we trust information about Free memory available to tomcat using
Runtime.freeMemory()  ?

so if those memory won't go nearer to 0 (zero) it won't have problem Out of 
Memory ?


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



Automatically Quit from Tomcat if Exception found (Out of Memory Exception)

2005-09-21 Thread NoKideen
Hi, 

I just worried that my tomcat hangs,

 if my Probelm Out of Memory occurs, then there will no ways I can stop Tom 
cat else than use 

#kill -9 pid_tomcat

in my Linux,

what can I do in TOmcat so if those out of memory problem occurs, tomcat will 
quit by it self, 

then I can prepate in my /etc/init.d/tomcat script will re-run again tomcat.

Thanks in Advance,
 --
From Indonesia :D, the home of Java :-p






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



ConnectionPool JDBC3, Testing with realtime multiple client

2005-09-22 Thread NoKideen
Somebody please help me , example how to make A DataSource in 
server.xml/web.xml
or in webapps/testapps/WEB-INF/web.xml

using postgresql

and an example to access it in servlet . Use a PoolConnection, so only connect 
once, the other use that connection.


thank you,


currently I write data source in Servlet, there is so many error if I test it 
using realtime (10 clients access it servlet at the same secods), the 
connection initiated twice and more, more ...


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



Run Tomcat From Own Java Application

2005-09-23 Thread NoKideen

It least I install JProbe Free Edition,
I see that JProbe can run Tomcat from JProbe it self, ..

How we can build application to run Tomcat, not a Bash Script but A Java 
Application ...

example, we have provide CLASSPATH , and all things.

thanks

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



Re: Flexible way of defining application variables in text format?

2005-09-27 Thread NoKideen
On Tuesday 27 September 2005 15:36, Seak, Teng-Fong wrote:
 My webapp needs some application string variables for
 configuration.  For the moment, I hard-code them as class static
 properties and compiled.  But I'd like to know if there's any method to
 define such variables in a text file, something like the global.asa in
 ASP where we could simply write something like this withing the
 application_onstart subroutine:
 application(myvar) = my value

any better idea than this one ? without modification web.xml :-D


this is example to to read
-
import lib.ConfLineSeparator;
...
...
ConfLineSeparator c = new ConfLineSeparator(/whereis/thefile/file.conf);
out.println(c.getConf(dbPwd,VALUEifMissing)); 
...
...


this is example data file /whereis/thefile/file.conf
--
#CONFig Text Mode, 
#Place many Configuration here
#Format is : property=value or property = value
#there is no SPACE, space is WASTE of String :-p
#value is value not value or 'value'
#all Chars are case sensitive
#Add # char to comment

# Db Conf
dbPwd=secret


Try this API Class file
-
package lib;
import java.io.*;
import java.util.Vector;

public class ConfLineSeparator {
String[] all;
int i=0;
String currentProp, currentVal;
Vector p;
Vector v;

public ConfLineSeparator(String file) {
all = new String[2000]; //maximum
p = new Vector();
v = new Vector();

readFile(file);
processNow();
}
public void readFile(String file) {
debug( Reading +file);
try {
i=0;
FileInputStream fstream = new FileInputStream(file);
DataInputStream in = new DataInputStream(fstream);

while (in.available() !=0){
i++;
in.readLine();
}
in.close();


all = new String[i];

i=0;
fstream = new FileInputStream(file);
in = new DataInputStream(fstream);
while (in.available() !=0){
all[i++] = in.readLine();
debug( Reading Got this data +all[i-1]);
}
in.close();

} catch (Exception e) {
debug( Reading Exception +e.getMessage());
}
}

public void processNow() {
// trim it
for (int z=0;z  all.length; z++) {
all[z] = all[z].trim();
}

i=0;
for (int z=0;z  all.length; z++) {
if (all[z].startsWith(#)) {

} else if (all[z].startsWith(#end)) {
return;
} else if (all[z].indexOf('=')==-1) {

} else if (all[z]==null || all[z]==) {

} else {
try {
p.add(i,new 
String(all[z].substring(0,all[z].indexOf('=')).trim()));
v.add(i,new 
String(all[z].substring(all[z].indexOf('=')+1,all[z].length()).trim()));
} catch (Exception e) {
}
debug((i) +  = +p.get(i)+ value_is 
+v.get(i));
i++;
}

}

}

public String getConf(String prop, String IfValueNotFound) {
try {
int tmp = p.indexOf(prop);
if (tmp =0  tmpv.size())
return (String) v.get(tmp);
else
return IfValueNotFound;
} catch (Exception e) {
//e.printStackTrace();
return IfValueNotFound;
}
}

public void debug(String x) {
//System.out.println(x);
}
}

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



Re: Flexible way of defining application variables in text format?

2005-09-27 Thread NoKideen
On Tuesday 27 September 2005 16:48, Jilles van Gurp wrote:
 NoKideen wrote:
 
  this is example to to read
  -
  import lib.ConfLineSeparator;
  ...
  ...
  ConfLineSeparator c = new
  ConfLineSeparator(/whereis/thefile/file.conf);
  out.println(c.getConf(dbPwd,VALUEifMissing));
  ...
  ...
 Use commons.configuration. Works beautifully and has the advantage that
 you don't need to change your deployment descriptor or server.xml if you
 want to change the configuration. With commons-configuration you can
 also reload and write the properties, store them in xml, a database or a
 simple text file.


is there any example, I'd still confuse how to read dot properties file


I think may API was to odds :-D, yeah that was trouble
but there is one thing I like is comments using #



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



Running Tomcat as Non-Root under Linux listen for port 80

2005-09-27 Thread NoKideen
is there anybody know how to do this ?
Running Tomcat as Non-Root under Linux listen for port 80

I'd try as tomcat , but there is error even if 
I do
# chown -R tomcat:root /usr/tomcat/*


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



PoolConnection always build new Connection

2005-10-08 Thread NoKideen
HI, currently I use Pool Connection like this bottom here,
And Works.

Only one Connection is made for every COnnection made
then ...

I tried to recompile for a code changes,

a new connection is built again,
so every recompile DataSource is built, so the old connection is leak, and the 
new code use new connection

what should I do ?
I use tomcat 5.5

thanks ?



Jdbc3PoolingDataSource source = new Jdbc3PoolingDataSource();
source.setDataSourceName(DataSource);
source.setServerName(localhost);
source.setDatabaseName(test);
source.setUser(testuser);
source.setPassword(testpassword);
source.setMaxConnections(10);
new InitialContext().rebind(DataSource, source);

Connection con = null;
try {
DataSource source = (DataSource)new InitialContext().lookup(DataSource);
con = source.getConnection();
// use connection
} catch (SQLException e) {
// log error
} catch (NamingException e) {
// DataSource wasn't found in JNDI
} finally {
if (con != null) {
try { con.close(); } catch (SQLException e) {}
}
}

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