Re: mail/Session problem please help

2003-06-06 Thread Ayhan Peker
At 13:19 05/06/03 +0100, you wrote:
Hi all
I am trying to use mail/Session resource as a global resource and it is 
not working!!
I got stuck. Please help

my server.xml is like

  GlobalNamingResources


ResourceParams name=mail/Session
parameter
  namemail.smtp.host/name
  valuebabel.image-data.com/value

/parameter

/ResourceParams

   /GlobalNamingResources

my host and context entry

host ...   /
context /
...
ResourceLink name=mail-Session global=mail/Session 
type=javax.mail.Session /
/Context
/Host

and I am trying to access it from a jsp page with :



Context initCtx = new InitialContext();

System.out.println(mail session is about to be  );

Object test = initCtx.lookup(java:comp/env/mail-Session);
System.out.println(test.getClass().getName());
javax.mail.Session mailsession = (javax.mail.Session) 
initCtx.lookup(java:comp/env/mail-Session);
System.out.println(mail session is created +mailsession);



but I am receiving the error message

mail session is about to be
javax.naming.NamingException: Cannot create resource instance
at 
org.apache.naming.factory.ResourceFactory.getObjectInstance(Resourc
Factory.java:189)
at 
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java
301)
at org.apache.naming.NamingContext.lookup(NamingContext.java:835)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at 
org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(Res
urceLinkFactory.java:143)
at 
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java
301)
at org.apache.naming.NamingContext.lookup(NamingContext.java:835)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at org.apache.jsp.MailPage_jsp._jspService(MailPage_jsp.java:56)
at 
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapp
r.java:204)
at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
289)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at 
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDi
patcher.java:684)
at 
org.apache.catalina.core.ApplicationDispatcher.doForward(Applicatio
Dispatcher.java:432)
at 
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationD
spatcher.java:356)
at actions.ActionRouter.route(ActionRouter.java:68)
at ActionServlet.service(ActionServlet.java:132)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Ap
licationFilterChain.java:247)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicatio
FilterChain.java:193)
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrappe
Valve.java:260)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveCont
xt.invokeNext(StandardPipeline.java:643)
at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.j
va:480)
at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:99
)
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContex
Valve.java:191)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveCont
xt.invokeNext(StandardPipeline.java:643)
at 
org.apache.catalina.valves.RequestFilterValve.process(RequestFilter
alve.java:324)
at 
org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.j
va:131)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveCont
xt.invokeNext(StandardPipeline.java:641)
at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.j
va:480)
at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:99
)
at 
org.apache.catalina.core.StandardContext.invoke(StandardContext.jav
:2396)
at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve
java:180)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveCont

mail/Session problem

2003-06-05 Thread Ayhan Peker
Hi all
I am trying to use mail/Session resource as a global resource
my server.xml is like
  GlobalNamingResources


ResourceParams name=mail/Session
parameter
  namemail.smtp.host/name

  valuebabel.image-data.com/value

/parameter

/ResourceParams


   /GlobalNamingResources
my host and context entry

host ...   /
context /
...
ResourceLink name=mail-Session global=mail/Session 
type=javax.mail.Session /
/Context
/Host

and I am trying to access it from a jsp page with :

	

Context initCtx = new InitialContext();

System.out.println(mail session is about to be  );

Object test = initCtx.lookup(java:comp/env/mail-Session);
System.out.println(test.getClass().getName());
javax.mail.Session mailsession = (javax.mail.Session) 
initCtx.lookup(java:comp/env/mail-Session);
System.out.println(mail session is created +mailsession);



but I am receiving the error message

mail session is about to be
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceFactory.getObjectInstance(Resourc
Factory.java:189)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java
301)
at org.apache.naming.NamingContext.lookup(NamingContext.java:835)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(Res
urceLinkFactory.java:143)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java
301)
at org.apache.naming.NamingContext.lookup(NamingContext.java:835)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at org.apache.jsp.MailPage_jsp._jspService(MailPage_jsp.java:56)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapp
r.java:204)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java
289)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDi
patcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(Applicatio
Dispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationD
spatcher.java:356)
at actions.ActionRouter.route(ActionRouter.java:68)
at ActionServlet.service(ActionServlet.java:132)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Ap
licationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicatio
FilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrappe
Valve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCont
xt.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.j
va:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:99
)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContex
Valve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCont
xt.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.RequestFilterValve.process(RequestFilter
alve.java:324)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.j
va:131)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCont
xt.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.j
va:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:99
)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.jav
:2396)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve
java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCont
xt.invokeNext(StandardPipeline.java:643)
at 

crontab problems

2003-02-25 Thread Ayhan Peker
Hi everybody ,
I have a problem..I am trying to write an application , which will run from 
cronatb on linux...
My application runs without a problem when i try it from the command 
line..BUT NOT FROM CRONTAB...
The challenge is: if jvm crashes i want to restart tomcat
my code is :
String[] command ={ /bin/sh, -c, ps -ex | grep Djava.endorsed.dirs};
int processcount=0;
Runtime r = Runtime.getRuntime();
Process p = r.exec(command);
InputStreamReader isr=new InputStreamReader(p.getInputStream());
BufferedReader br=new BufferedReader(isr);
String line=null;
while((line = br.readLine()) != null){
System.out.println(line);
processcount++;
}
if i decide to restart the server
i execute :
String[] command_ ={sh,-c,/root/adminscripts/restart_tomcat};
Process p2 = Runtime.getRuntime().exec(command_);
but the last two lines returns
/
The JAVA_HOME environment variable is not defined
message..
/
my retstart_tomcat scrip is
#!/bin/sh
cd /usr/local/tomcat/bin
./startup.sh
i will really appreciate if somebody helps..
basicly...
-run the crontab every min..
-invoke a java programme..
-programme counts the java-threads..
-decides if tomcat needs restarting..
-restarts tomcat..
my crontab script is:
* * * * * su root  cd /usr/local/tomcat/bin  /usr/local/java/bin/java 
-cp /usr/local/tomcat/bin/ TomcatwatcherThread  
/var/log/tomcat/restart.log 21
please help..
Thanks







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


RE: crontab problems

2003-02-25 Thread Ayhan Peker
I have no problems with tomcat...

But sometimes under heavy load jvm 1.4 crashes...
see the links:
Ok this is the bug:
http://developer.java.sun.com/developer/bugParade/bugs/4779653.html
unfortunately it is closed, affects 1.4.1 and will not apparently be fixed. 
It oiccurs in large apps under load.on Linux and Solaris ( and most likely 
Windows )
It is related to / a copy of the following bug which
http://developer.java.sun.com/developer/bugParade/bugs/4724356.html



what is the best suggestion?

just trying to determine if tomcat is running..
if not i will restart it ..
(jvm just crashed last saturday nightI did not know anything until the 
sunday evening)..

At 09:29 AM 2/25/03 -0500, you wrote:

Yes, Tomcat is generally very stable.  But: Trust, but verify. ;)

John

 -Original Message-
 From: Hannes Schmidt [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, February 25, 2003 9:23 AM
 To: Tomcat Users List
 Subject: Re: crontab problems


 Yes, using wget is probably the second best solution. The
 best one is to
 find the reason why Tomcat crashes at all, since it generally
 is a stable
 and reliable product.

 Cron doesn't execute more than once a minute (at least mine
 doesn't) which
 still is quite often. 5 or 10 minutes would be ok too. But
 that's a matter
 of taste, really.

 - Original Message -
 From: Turner, John [EMAIL PROTECTED]
 To: 'Tomcat Users List' [EMAIL PROTECTED]
 Sent: Tuesday, February 25, 2003 3:00 PM
 Subject: RE: crontab problems


 
  Agreed...using a Java program to watch Tomcat seems a
 little circular.
  Plus, I don't see any sort of delay or sleep in the poster's JAva
  code...it looks like it just keeps hammering at Tomcat, as
 the cron job is
  * * * * *.  Creating all those Runtime objects over and
 over can't be
  helping performance any.
 
  A simple shell script using wget would be fine...sure, you
 can watch the
  output of ps -ef, but that doesn't tell you if Tomcat is accepting
  requests or not.  There could be an entry for Tomcat in the
 process table,
  but Tomcat could be refusing requests.
 
  I just write a simple JSP page that outputs the contents of
 a variable,
 like
  ***SUCCESS*** or something like that, then use wget to
 grab that page
  every so often and check for the string in the output...if
 it's there,
  things should be OK (there are no guarantees).  If it's
 not, you have a
  problem.  This way, the JSP page is compiled and cached by
 Tomcat, it uses
  very little memory, and doesn't bog down the server.
 
  There are plenty of other alternatives much more robust
 than a simple
 shell
  script...you could use Netsaint/Nagios, Big Brother, and a
 whole bunch of
  others.
 
  John
 
   -Original Message-
   From: Hannes Schmidt [mailto:[EMAIL PROTECTED]
   Sent: Tuesday, February 25, 2003 6:29 AM
   To: Tomcat Users List
   Subject: Re: crontab problems
  
  
   Right, you might also just put
  
   JAVA_HOME=...
  
   at the beginning of your crontab.
  
   I assume you have good reasons to use a Java program to
 watch Tomcat.
   Personally, I would have written a shell script. If you
   really want to use
   Java, you might want to use a different, more reliable
   approach to detect
   (un)availability of Tomcat, something like
  
   import java.net.*;
   URL url = new URL( http://localhost:8080/examples; );
   URLConnection con = url.openConnection();
   con.setUseCaches( false );
   con.connect();
   if( con.getContentLength()  0 ) {
   // restart tomcat
   }
  
   But I just wrote this out of my head ...
  
   - Original Message -
   From: Ralph Einfeldt [EMAIL PROTECTED]
   To: Tomcat Users List [EMAIL PROTECTED]
   Sent: Tuesday, February 25, 2003 10:43 AM
   Subject: RE: crontab problems
  
  
   You have to make shure that your script retstart_tomcat
   sets and exports all needed environment variables before
   calling ./startup.sh:
  
   JAVA_HOME=/usr/local/java/jdk1.3.1
   CATALINA_HOME=path to tomcat installation
   CATALINA_BASE=path to tomcat instance or $CATALINA_HOME
   # JAVA_OPTS='-client -v'
  
   export JAVA_HOME CATALINA_HOME CATALINA_BASE JAVA_OPTS
   ./startup.sh
  
-Original Message-
From: Ayhan Peker [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 25, 2003 10:30 AM
To: [EMAIL PROTECTED]
Subject: crontab problems
   
but the last two lines returns
/
The JAVA_HOME environment variable is not defined
message..
/
my retstart_tomcat scrip is
#!/bin/sh
cd /usr/local/tomcat/bin
./startup.sh
  
  
 -
   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

RE: crontab problems

2003-02-25 Thread Ayhan Peker
Am I right to think that if jvm crashes...Once writing to core file is 
finished, jvm can be restarted..(that is what we have been doing--jvm 
crashes, of course tomcat too)
AND crontab say 5 min later..launches this java programme, which will 
restart tomcat..this is not a thread..just a java programme...that is the 
reason I am trying to launch it from crontab...

When jvm crashes it writes its report..and goes away from the memory..You 
can still launch a java programme after this crash (like launching tomcat 
again after the crash)..

..

--tomcat running
--jvm crashes..
--crontab launches my watcher (written in java)
--my application checks if tomcat is running...and restarts is necessary..
--if my programme is running at the time of crash..my programme crashes 
too...but 5 min later my programme is activated by crontab again..

Am I missing something here?

Take care..

Ayhan



At 10:12 AM 2/25/03 -0500, you wrote:

Well, if the JVM is crashed, how can a program or application written in
Java help you manage Tomcat?  That was the point.
John

 -Original Message-
 From: Ayhan Peker [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, February 25, 2003 9:43 AM
 To: Tomcat Users List
 Subject: RE: crontab problems


 I have no problems with tomcat...

 But sometimes under heavy load jvm 1.4 crashes...
 see the links:

 Ok this is the bug:
 http://developer.java.sun.com/developer/bugParade/bugs/4779653.html
 unfortunately it is closed, affects 1.4.1 and will not
 apparently be fixed.
 It oiccurs in large apps under load.on Linux and Solaris (
 and most likely
 Windows )
 It is related to / a copy of the following bug which
 http://developer.java.sun.com/developer/bugParade/bugs/4724356.html




 what is the best suggestion?

 just trying to determine if tomcat is running..
 if not i will restart it ..
 (jvm just crashed last saturday nightI did not know
 anything until the
 sunday evening)..


 At 09:29 AM 2/25/03 -0500, you wrote:

 Yes, Tomcat is generally very stable.  But: Trust, but verify. ;)
 
 John
 
   -Original Message-
   From: Hannes Schmidt [mailto:[EMAIL PROTECTED]
   Sent: Tuesday, February 25, 2003 9:23 AM
   To: Tomcat Users List
   Subject: Re: crontab problems
  
  
   Yes, using wget is probably the second best solution. The
   best one is to
   find the reason why Tomcat crashes at all, since it generally
   is a stable
   and reliable product.
  
   Cron doesn't execute more than once a minute (at least mine
   doesn't) which
   still is quite often. 5 or 10 minutes would be ok too. But
   that's a matter
   of taste, really.
  
   - Original Message -
   From: Turner, John [EMAIL PROTECTED]
   To: 'Tomcat Users List' [EMAIL PROTECTED]
   Sent: Tuesday, February 25, 2003 3:00 PM
   Subject: RE: crontab problems
  
  
   
Agreed...using a Java program to watch Tomcat seems a
   little circular.
Plus, I don't see any sort of delay or sleep in the
 poster's JAva
code...it looks like it just keeps hammering at Tomcat, as
   the cron job is
* * * * *.  Creating all those Runtime objects over and
   over can't be
helping performance any.
   
A simple shell script using wget would be fine...sure, you
   can watch the
output of ps -ef, but that doesn't tell you if Tomcat
 is accepting
requests or not.  There could be an entry for Tomcat in the
   process table,
but Tomcat could be refusing requests.
   
I just write a simple JSP page that outputs the contents of
   a variable,
   like
***SUCCESS*** or something like that, then use wget to
   grab that page
every so often and check for the string in the output...if
   it's there,
things should be OK (there are no guarantees).  If it's
   not, you have a
problem.  This way, the JSP page is compiled and cached by
   Tomcat, it uses
very little memory, and doesn't bog down the server.
   
There are plenty of other alternatives much more robust
   than a simple
   shell
script...you could use Netsaint/Nagios, Big Brother, and a
   whole bunch of
others.
   
John
   
 -Original Message-
 From: Hannes Schmidt [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, February 25, 2003 6:29 AM
 To: Tomcat Users List
 Subject: Re: crontab problems


 Right, you might also just put

 JAVA_HOME=...

 at the beginning of your crontab.

 I assume you have good reasons to use a Java program to
   watch Tomcat.
 Personally, I would have written a shell script. If you
 really want to use
 Java, you might want to use a different, more reliable
 approach to detect
 (un)availability of Tomcat, something like

 import java.net.*;
 URL url = new URL( http://localhost:8080/examples; );
 URLConnection con = url.openConnection();
 con.setUseCaches( false );
 con.connect();
 if( con.getContentLength()  0 ) {
 // restart tomcat
 }

 But I just wrote this out