Can I call My thread class in JSP/Java Bean??

2005-08-06 Thread IndianAtTech
Hi All,

Can I call thread classes in my JSP or Java Bean classes??

The reason why I am asking is, I have a situation in which if a person
registers as a consumer, then a mail shud be sent to providers that
who matches the consumers requirements

There is a possinbilty of sending more than 100 mails at an instance.
So after successful registration by consumer, I don't  want to put the
consumer in wait mode, So I have created a thread class and I am
trying to send the mail in the thread class

But the problem is although I called thread.start method, my run
method is not invoking.

I thought there could be a problem with my code and tested with
standalone java class. In standalone class I am able to send the mail.

So, I don't know why tomcat is  rejecting the My thread execution.

Any Ideas??


here is my code
// calling the thread
 jiya.general.results.MailThread mailThread =new
jiya.general.results.MailThread();

mailThread.start();


//sending the mail
 private void sendMail() throws JiyaException {

JiyaMailComponent jmc=new JiyaMailComponent();

jmc.setServer(192.12.0.91);

jmc.setUser([EMAIL PROTECTED]);

jmc.setPassword(a);

jmc.setFromAddress([EMAIL PROTECTED]);

jmc.setContentType(text/plain);

jmc.setTo([EMAIL PROTECTED]);

jmc.setSubject(Some Subject);
jmc.setBody(test body);

jmc.send();

 }

//this is inner class of My main class 
class MailThread extends Thread implements Runnable {
  public  MailThread()
  {
log(Entered here at mail thread execution); // here I am to
see the log info in log file
  }
public void run() {
try{

sendMail(); //not coming to this stage

}
catch(Exception ex) {
throw new RuntimeException(ex);
}
}
}

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



Re: load on startup

2005-08-06 Thread David Johnson
private static final SingletonObj singleton;

public SingletonObj ()
{
  super ();
  singleton = this;
}

public synchronized SingletonObj getSingleton ()
{
  if ( singleton == null )
  {
new SingletonObj();
  }
  return singleton;
}

On Fri, 2005-08-05 at 20:11 -0700, Ming Han wrote:
 You can use Singleton pattern, but care must be taken. 
 
 For example
 
 if ( singleton == null )
 {
singleton = new SingletonObj();
 }
 
 There might be a case where few thread running concurrently on the null
 checking, then multiple singleton object will be created more than one.
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around 
 http://mail.yahoo.com 
 
 -
 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: load on startup

2005-08-06 Thread David Johnson
{
private static final SingletonObj singleton;

// optional - use if you want the initialization to occur as class load
time
// Otherwise, the initialization will occur at first call to
getSingleton();

// static initialization at load time
static {
getSingelton ()/
}


private SingletonObj ()
{
  super ();
  singleton = this;
}

public static synchronized SingletonObj getSingleton ()
{
  if ( singleton == null )
  {
new SingletonObj();
  }
  return singleton;
}


}


On Fri, 2005-08-05 at 20:11 -0700, Ming Han wrote:
 You can use Singleton pattern, but care must be taken. 
 
 For example
 
 if ( singleton == null )
 {
singleton = new SingletonObj();
 }
 
 There might be a case where few thread running concurrently on the null
 checking, then multiple singleton object will be created more than one.
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around 
 http://mail.yahoo.com 
 
 -
 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]



What to do if you receive a 554 delivery error when posting

2005-08-06 Thread Mark Thomas

All,

Reports of 554 delivery errors have continued. My investigations are 
progressing but I need more information to track down the root cause. 
If you receive a 554 delivery failure message please forward the 
message *and the headers* to [EMAIL PROTECTED] or 
[EMAIL PROTECTED]


The headers are particularly important. 
http://www1.physics.ox.ac.uk/help/spam.html contains information on 
how to make sure the mail you send me includes the headers. Although 
this page refers to spam messages I should stress that I do not 
believe the 554 messages are spam.


Regards,

Mark
(one of) [EMAIL PROTECTED]


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



Re: Can I call My thread class in JSP/Java Bean??

2005-08-06 Thread Wade Chandler
You may be getting an error in your thread.  You
should not throw exceptions out of the run method. 
You should always log and update some table or static
collection so you can do something later if needed,
but throwing errors from threads is never a good idea
as you can hang up some stuff at times depending on
your JVM and you'll not know what is happening in any
case.  Use the standard java logging API, servlet
loggers, or log4j.

Wade

--- IndianAtTech [EMAIL PROTECTED] wrote:

 Hi All,
 
 Can I call thread classes in my JSP or Java Bean
 classes??
 
 The reason why I am asking is, I have a situation in
 which if a person
 registers as a consumer, then a mail shud be sent to
 providers that
 who matches the consumers requirements
 
 There is a possinbilty of sending more than 100
 mails at an instance.
 So after successful registration by consumer, I
 don't  want to put the
 consumer in wait mode, So I have created a thread
 class and I am
 trying to send the mail in the thread class
 
 But the problem is although I called thread.start
 method, my run
 method is not invoking.
 
 I thought there could be a problem with my code and
 tested with
 standalone java class. In standalone class I am able
 to send the mail.
 
 So, I don't know why tomcat is  rejecting the My
 thread execution.
 
 Any Ideas??
 
 
 here is my code
 // calling the thread
  jiya.general.results.MailThread mailThread =new
 jiya.general.results.MailThread();
 
 mailThread.start();
 
 
 //sending the mail
  private void sendMail() throws JiyaException {
 
 JiyaMailComponent jmc=new
 JiyaMailComponent();
 
 jmc.setServer(192.12.0.91);
 
 jmc.setUser([EMAIL PROTECTED]);
 
 jmc.setPassword(a);
 
 jmc.setFromAddress([EMAIL PROTECTED]);
 
 jmc.setContentType(text/plain);
 
 jmc.setTo([EMAIL PROTECTED]);
 
 jmc.setSubject(Some Subject);
 jmc.setBody(test body);
 
 jmc.send();
 
  }
 
 //this is inner class of My main class 
 class MailThread extends Thread implements Runnable
 {
   public  MailThread()
   {
 log(Entered here at mail thread
 execution); // here I am to
 see the log info in log file
   }
 public void run() {
 try{
 
 sendMail(); //not coming to this stage
 
 }
 catch(Exception ex) {
 throw new RuntimeException(ex);
 }
 }
 }
 

-
 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: Can I call My thread class in JSP/Java Bean??

2005-08-06 Thread Wade Chandler
Also , if all else fails make sure you can do what the
thread is doing from the JSP to make sure you're
emails are actually getting sent.  I have had some
funny issues sometimes with code in a servlet/JSP vs.
standalone.  Break it down to the least common
denominator firstsimplify then you will know if
it's really the thread or not.

Wade

--- Wade Chandler [EMAIL PROTECTED]
wrote:

 You may be getting an error in your thread.  You
 should not throw exceptions out of the run method. 
 You should always log and update some table or
 static
 collection so you can do something later if needed,
 but throwing errors from threads is never a good
 idea
 as you can hang up some stuff at times depending on
 your JVM and you'll not know what is happening in
 any
 case.  Use the standard java logging API, servlet
 loggers, or log4j.
 
 Wade
 
 --- IndianAtTech [EMAIL PROTECTED] wrote:
 
  Hi All,
  
  Can I call thread classes in my JSP or Java Bean
  classes??
  
  The reason why I am asking is, I have a situation
 in
  which if a person
  registers as a consumer, then a mail shud be sent
 to
  providers that
  who matches the consumers requirements
  
  There is a possinbilty of sending more than 100
  mails at an instance.
  So after successful registration by consumer, I
  don't  want to put the
  consumer in wait mode, So I have created a thread
  class and I am
  trying to send the mail in the thread class
  
  But the problem is although I called thread.start
  method, my run
  method is not invoking.
  
  I thought there could be a problem with my code
 and
  tested with
  standalone java class. In standalone class I am
 able
  to send the mail.
  
  So, I don't know why tomcat is  rejecting the My
  thread execution.
  
  Any Ideas??
  
  
  here is my code
  // calling the thread
   jiya.general.results.MailThread mailThread =new
  jiya.general.results.MailThread();
  
  mailThread.start();
  
  
  //sending the mail
   private void sendMail() throws JiyaException {
  
  JiyaMailComponent jmc=new
  JiyaMailComponent();
  
  jmc.setServer(192.12.0.91);
  
  jmc.setUser([EMAIL PROTECTED]);
  
  jmc.setPassword(a);
  
  jmc.setFromAddress([EMAIL PROTECTED]);
  
  jmc.setContentType(text/plain);
  
  jmc.setTo([EMAIL PROTECTED]);
  
  jmc.setSubject(Some Subject);
  jmc.setBody(test body);
  
  jmc.send();
  
   }
  
  //this is inner class of My main class 
  class MailThread extends Thread implements
 Runnable
  {
public  MailThread()
{
  log(Entered here at mail thread
  execution); // here I am to
  see the log info in log file
}
  public void run() {
  try{
  
  sendMail(); //not coming to this stage
  
  }
  catch(Exception ex) {
  throw new RuntimeException(ex);
  }
  }
  }
  
 

-
  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]
 
 


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



Re: load on startup

2005-08-06 Thread Mauricio Nuñez
Improved version without sync locking:

class SingletonObj
{ 

private static SingletonObj instance;

static
{
instance=new SingletonObj();
}

private SingletonObj()
{

}

public static SingletonObj getInstance() // without sync !
{   
return instance;
}

}

El sáb, 06-08-2005 a las 09:14 -0500, David Johnson escribió:
 {
 private static final SingletonObj singleton;
 
 // optional - use if you want the initialization to occur as class load
 time
 // Otherwise, the initialization will occur at first call to
 getSingleton();
 
 // static initialization at load time
 static {
 getSingelton ()/
 }
 
 
 private SingletonObj ()
 {
   super ();
   singleton = this;
 }
 
 public static synchronized SingletonObj getSingleton ()
 {
   if ( singleton == null )
   {
 new SingletonObj();
   }
   return singleton;
 }
 
 
 }
 
 
 On Fri, 2005-08-05 at 20:11 -0700, Ming Han wrote:
  You can use Singleton pattern, but care must be taken. 
  
  For example
  
  if ( singleton == null )
  {
 singleton = new SingletonObj();
  }
  
  There might be a case where few thread running concurrently on the null
  checking, then multiple singleton object will be created more than one.
  
  __
  Do You Yahoo!?
  Tired of spam?  Yahoo! Mail has the best spam protection around 
  http://mail.yahoo.com 
  
  -
  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]
 


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



Re: loading resources from the servlet.

2005-08-06 Thread Anoop kumar V
just place your .properties file under web-inf/classes which is alway
guaranteed to be in your classpath... - so u are still outside of any
packages...

Anoop

On 8/5/05, Maciej Stoszko [EMAIL PROTECTED] wrote:
 Thx Jon,
 I had already looked at the wiki entry you graciously pointed me to.
 I need a bit more. The class X, I mentioned, is already packaged and I am
 looking for a way of using it without changing it (unless there is no other
 way.) It makes the assumption that the ../data folder is in the classpath.
 In eclipse or via ant I can easily set my classpath 'right', is there a way
 to do it for the webapp inside Tomcat?
 
 Regards,
 maciek
 
 PS. What does HTH stand for?
 
 -Original Message-
 From: Jon Wingfield [mailto:[EMAIL PROTECTED]
 Sent: Friday, August 05, 2005 12:28 PM
 To: Tomcat Users List
 Subject: Re: loading resources from the servlet.
 
 http://wiki.apache.org/jakarta-tomcat/HowTo#head-45c3314139cb900ddd43dde2ff6
 71532e6e844bc
 
 HTH,
 
 Jon
 
 Maciej Stoszko wrote:
  I have a class X which needs to load a .properties file.
 
  Here is a code snippet:
 
 ClassLoader cl = this.getClass().getClassLoader();
 
 InputStream stream =  cl.getResourceAsStream(/data/x.properties);
 
 
 
  It works just fine from my JUnit test for X.
 
 
 
  Now, I would like this class to be called from the servlet, which would
 run
  inside Tomcat 5.5.9. The only way to get that to work is to place my
  x.properties file inside the package the class X lives in. Well, I'd
 rather
  not to mix properties with classfiles.
 
 
 
  Another way, I can load that file, is to use servlets getServletContext()
  method. However, that would mean I need to pass the InputStream from the
  servlets to my class X. Well, I'd rather not to change X to use its caller
  to get X's properties file.
 
 
 
  I guess, what I need to do is to add the WEB-INF or ROOT dir of my webapp
 to
  the classpath, so the classloader can find it. Or is there some other way
 of
  accomplishing it?
 
 
 
  I think I am missing something fundamental ... cos that doesn't seem to be
  too strange of a requirement ...
 
  Any ideas?
 
  Thanks,
 
  maciek
 
 
 
 
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
Thanks and best regards,
Anoop

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



Re: anonymising Tomcat

2005-08-06 Thread Rainer Jung
Take a look at

./org/apache/catalina/util/ServerInfo.properties

in CATALINA_HOME/server/lib/catalina.jar.

It contains:

server.info=Apache Tomcat/5.5.10
server.number=5.5.10.0

You can put different values in there and deploy the new properties file in

CATALINA_HOME/server/classes/org/apache/catalina/util/ServerInfo.properties

As far as I know, there are no negative side effects.

Have fun

Rainer

 Is it possible to configure Tomcat (5.5.9) so that a
 moderately able hacker couldn't figure out what is
 serving up our web apps?

 Paul Singleton


 --
 No virus found in this outgoing message.
 Checked by AVG Anti-Virus.
 Version: 7.0.338 / Virus Database: 267.10.0/63 - Release Date: 3/Aug/2005


 -
 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: Tomcat application won't start with MySQL Connection Pooling

2005-08-06 Thread Caldarale, Charles R
 From: James Adams [mailto:[EMAIL PROTECTED] 
 Subject: RE: Tomcat application won't start with MySQL 
 Connection Pooling 
 
 I have now created a context.xml according to the
 example in the Tomcat 5.5 documentation and this time
 I've placed it my application's META-INF directory in
 the WAR
 
 --- META-INF/context.xml -
 Context path=/ioifocus

Please note the following for the path attribute in the Tomcat 5.5 doc
for Context:

The value of this field must not be set except when statically defining
a Context in server.xml, as it will be infered [sic] from the filenames
used for either the .xml context file or the docBase.

Also, examine the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory
(usually conf/Catalina/localhost/), and remove any .xml files that might
have been automatically created previously for your application and
restart Tomcat.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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



RE: How to turn off perssitent sessions in Tomcat 4.1?

2005-08-06 Thread Richard Mixon (qwest)
Hmm,

I assume you have read the documentation on this:
  http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/manager.html
If so, have you tried leaving the manager element out?

 HTH - Richard

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 05, 2005 3:26 AM
To: tomcat-user@jakarta.apache.org
Subject: RE: How to turn off perssitent sessions in Tomcat 4.1?


Can any one help me out in this issue?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent:
Thursday, August 04, 2005 11:27 AM
To: tomcat-user@jakarta.apache.org
Subject: RE: How to turn off perssitent sessions in Tomcat 4.1?


I am waiting for a good response.
Can any body help me out in this?


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]

Sent: Wednesday, August 03, 2005 6:01 PM
To: tomcat-user@jakarta.apache.org
Subject: RE: How to turn off perssitent sessions in Tomcat 4.1?


Hi Edgar,

Thanks for the reply.
But I am using Tomcat 4.1.29 and I tried this option (I mean,
pathname= in Manager element of server.xml) in Tomcat 4.1.29, which is
not successful. Is there any way to turn off session persistence in
Tomcat 4.1 itself or I need to upgrade to Tomcat 5.0.

In order to avoid the exception we have to make all the objects that is
put in session to be serializable, right no?.

I am using struts framework. So by default all form beans are
serializable and all primitive data types are also serializable.


Why Tomcat complains about CoyoteRequestFacade is not serializable?


Please clarify my doubts.
Advance thanks to all of u !!!

-Original Message-
From: Edgar Alves [mailto:[EMAIL PROTECTED]

Sent: Wednesday, August 03, 2005 5:00 PM
To: Tomcat Users List
Subject: Re: How to turn off perssitent sessions in Tomcat 4.1?

Hi,
  On Tomcat 5.5 you can turn persistent session loading off by setting
the SessionManager pathname attribute to . Hope that helps.

  -- Edgar Alves

[EMAIL PROTECTED] wrote:

Hi,




I am using Apache+Tomcat 4.1.29 for running my application. When I am 
restarting Tomcat I am getting persistent session loading exception
like
this:




  2004-03-11 13:52:18 StandardManager[] IOException while loading 
persisted sessions:


   java.io.WriteAbortedException: writing aborted;
java.io.NotSerializableException:


   org.apache.coyote.tomcat4.CoyoteRequestFacade

   java.io.WriteAbortedException: writing aborted;
java.io.NotSerializableException:


   org.apache.coyote.tomcat4.CoyoteRequestFacade

   at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1278)

   at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845
)

   at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)

   at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:164
6
)

   at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)

   at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845
)

   at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)

   at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:164
6
)

   at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)

   at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)

   at




org.apache.catalina.session.StandardSession.readObject(StandardSession.
j
ava:1369)




I am not using clustering. I want to turn off the session persistence
in
Tomcat 4.1.29?

I have tried so many options with StandardManager in server.xml. But I 
was not successful.

Please help me out in this?




Regards

AK








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




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]




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: 

Re: load on startup

2005-08-06 Thread David Johnson
instance needs to be final, or it may be changed by some tricks that
break encapsulation.


On Sat, 2005-08-06 at 15:59 -0400, Mauricio Nuñez wrote:
 Improved version without sync locking:
 
 class SingletonObj
 { 
 
   private static SingletonObj instance;
 
   static
   {
   instance=new SingletonObj();
   }
 
   private SingletonObj()
   {
 
   }
 
   public static SingletonObj getInstance() // without sync !
   {   
   return instance;
   }
 
 }
 
 El sáb, 06-08-2005 a las 09:14 -0500, David Johnson escribió:
  {
  private static final SingletonObj singleton;
  
  // optional - use if you want the initialization to occur as class load
  time
  // Otherwise, the initialization will occur at first call to
  getSingleton();
  
  // static initialization at load time
  static {
  getSingelton ()/
  }
  
  
  private SingletonObj ()
  {
super ();
singleton = this;
  }
  
  public static synchronized SingletonObj getSingleton ()
  {
if ( singleton == null )
{
  new SingletonObj();
}
return singleton;
  }
  
  
  }
  
  
  On Fri, 2005-08-05 at 20:11 -0700, Ming Han wrote:
   You can use Singleton pattern, but care must be taken. 
   
   For example
   
   if ( singleton == null )
   {
  singleton = new SingletonObj();
   }
   
   There might be a case where few thread running concurrently on the null
   checking, then multiple singleton object will be created more than one.
   
   __
   Do You Yahoo!?
   Tired of spam?  Yahoo! Mail has the best spam protection around 
   http://mail.yahoo.com 
   
   -
   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]
  
 
 
 -
 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]