> This is how I am getting the Client Instance.
> 
>       org.apache.commons.httpclient.HttpURL url = (org.apache.commons.
>           httpclient.HttpURL) getURL(path + "/" + user);
> 
>       org.prithvi.docparser.microsoft.msexchange.apache.OwaWebdavResource
>           webDavResourceFile = getWebResource(
>           url);
> 
>       //get the client session
>       client = webDavResourceFile.retrieveSessionInstance();
> 
> Is this instance comes from SimpleConnectionManager ??

Simple answer, yes.

Two notes:
- Don't use UrlGetMethod. It's deprecated. Just use GetMethod.
- As a first solution try to surround the following two lines of your
  code given below with a synchronized(client) {} block:

  int status = client.executeMethod(getMethod);
  byte attachmentBytes[] = getMethod.getResponseBody();

Regards,
Ingo


> 
> thanks for trying to helping me
> 
> Sudhakar
> 
> 
> 
> 
> 
> --- Ingo Brunberg <[EMAIL PROTECTED]> wrote:
> 
> > First, this is not quite the right list for asking this question. It
> > would have better been asked on the commons-httpclient-dev list.
> > 
> > But anyway, your code snippet does not show how you create the
> > HttpClient instance that you use. Be aware that by default you get one
> > that uses the so called SimpleConnectionManager. You cannot use that
> > one to access the same connection concurrently from more than one
> > thread. If you want HttpClient to manage the connections for you in a
> > multithreaded environment, you should use the
> > MutliThreadedConnectionManager.
> > 
> > Ingo
> > 
> > > Hello Guys,
> > > 
> > > Subject: URLGetMethod.executeMethod is hanging under multi threaded environment
> > > 
> > > Please see the folloiwng code. I am trying to download the mails of MS Exchange 
> > > Server using
> > > URLGetMethod.executeMethod. But when execution pointer comes to the thread area
> > > (URLGetMethod.executemethod),
> > > 
> > > URLGetMethod.executemethod is not coming out of it's loop. Could you please 
> > > explain what is
> > the
> > > problem with this code??
> > > 
> > > 
> > > class SaveAttachmentThread
> > >     extends Thread
> > >     implements Runnable {
> > >   static int threadCount = 0;
> > >   String uri = "";
> > >   String strAttachmentName = "";
> > >   private org.apache.commons.httpclient.HttpClient client = null;
> > >   org.apache.commons.httpclient.methods.UrlGetMethod attachmentMethod = null;
> > > 
> > >   public SaveAttachmentThread(String uri, String strAttachmentName,
> > >                               org.apache.commons.httpclient.HttpClient client) {
> > >     this.uri = uri;
> > >     this.strAttachmentName = strAttachmentName;
> > >     this.client = client;
> > > 
> > >   }
> > > 
> > >   public SaveAttachmentThread(org.apache.commons.httpclient.methods.
> > >                               UrlGetMethod _getMethod, String attachment) {
> > >     attachmentMethod = _getMethod;
> > >     this.strAttachmentName = attachment;
> > >   }
> > > 
> > >   public void run() {
> > >     //strAttachmentName = URLDecoder.decode(strAttachmentName);
> > >     System.err.println("Saved to " + strAttachmentName);
> > >     System.err.println("URL :" + uri);
> > >     try {
> > > 
> > > 
> > >         System.err.println("Saving the URL :" + strAttachmentName);
> > >         org.apache.commons.httpclient.methods.UrlGetMethod getMethod = new org.
> > >             apache.commons.httpclient.methods.UrlGetMethod(uri);
> > >         int status = client.executeMethod(getMethod);
> > > 
> > > 
> > >       byte attachmentBytes[] = getMethod.getResponseBody();
> > >       FileOutputStream fout = new FileOutputStream(strAttachmentName);
> > >       fout.write(attachmentBytes);
> > >       fout.close();
> > >       fout = null;
> > > 
> > >       threadCount++;
> > >       System.err.println(threadCount);
> > > 
> > >     }
> > >     catch (Throwable e) {
> > >       System.err.println("Error raised while saving the URI : " +
> > >                          strAttachmentName);
> > >       e.printStackTrace();
> > >     }
> > >   }
> > > }
> > > 
> > > 
> > > Thanks
> > > Sudhakar
> > > 
> > > 
> > > 
> > > =====
> > > "No one can earn a million dollars honestly."- William Jennings Bryan 
> > > (1860-1925) 
> > > 
> > > "Make everything as simple as possible, but not simpler."- Albert Einstein 
> > > (1879-1955)
> > > 
> > > "It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw 
> > > (1856-1950)
> > > 
> > > 
> > >           
> > > __________________________________
> > > Do you Yahoo!?
> > > New and Improved Yahoo! Mail - Send 10MB messages!
> > > http://promotions.yahoo.com/new_mail 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> =====
> "No one can earn a million dollars honestly."- William Jennings Bryan (1860-1925) 
> 
> "Make everything as simple as possible, but not simpler."- Albert Einstein 
> (1879-1955)
> 
> "It is dangerous to be sincere unless you are also stupid."- George Bernard Shaw 
> (1856-1950)
> 
> 
>               
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail


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

Reply via email to