Return-Path: Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@www.apache.org Received: (qmail 65405 invoked from network); 5 Aug 2004 13:01:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 5 Aug 2004 13:01:03 -0000 Received: (qmail 24750 invoked by uid 500); 5 Aug 2004 13:01:00 -0000 Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@jakarta.apache.org Received: (qmail 24718 invoked by uid 500); 5 Aug 2004 13:01:00 -0000 Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Commons HttpClient Project" Reply-To: "Commons HttpClient Project" Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 24703 invoked by uid 99); 5 Aug 2004 13:01:00 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.142.33.4] (HELO mxout2.cac.washington.edu) (140.142.33.4) by apache.org (qpsmtpd/0.27.1) with ESMTP; Thu, 05 Aug 2004 06:00:57 -0700 Received: from smtp.washington.edu (smtp.washington.edu [140.142.33.9]) by mxout2.cac.washington.edu (8.13.0+UW04.06/8.13.0+UW04.06) with ESMTP id i75D0uEB006391 for ; Thu, 5 Aug 2004 06:00:56 -0700 Received: from [10.2.2.127] (host74.209.113.141.conversent.net [209.113.141.74]) (authenticated bits=0) by smtp.washington.edu (8.13.0+UW04.06/8.13.0+UW04.06) with ESMTP id i75D0s9k025462 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Thu, 5 Aug 2004 06:00:55 -0700 Message-ID: <41122F86.2040304@u.washington.edu> Date: Thu, 05 Aug 2004 09:00:54 -0400 From: Michael Becke User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Commons HttpClient Project Subject: Re: Invoke a httpclient in a EJB References: <20040805124838.630.qmail@web50204.mail.yahoo.com> In-Reply-To: <20040805124838.630.qmail@web50204.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Karthi, From the wording it sounds like you are not supposed to run a server from an EJB. HttpClient creates sockets but it does not listen to or accept connections, it's a client only. As someone already mentioned it would be pretty useless if you couldn't make network connections from an EJB as that would eliminate JDBC as well. It sounds like the real issue is going to be thread creation and connection reuse. To avoid creating threads you should use neither the MultiThreadedHttpConnectionManager nor connection timeouts. Both of these will create threads. You will also need to ensure that all HttpConnections are closed when the EJB exists. I would suggest creating a simple HttpConnectionManager (very similar to SimpleHttpConnectionManager) that you can force close the connection with. Mike Karthikeyani K wrote: > Thanks everyone. > > The EJB restrictions specified at > http://java.sun.com/blueprints/qanda/ejb_tier/restrictions.html state > that Enterprise beans should not listen on, accept connections on, or > mutlicast from a network socket. Why can an enterprise bean not > listen to or accept connections on a socket? Because if an enterprise > bean is listening on a socket, it can't be passivated -- it must > always be available. Enterprise beans can be network socket clients, > and so they can use other network resources (including other > enterprise bean servers) to do their jobs. Just as with a database > connection, don't hang on to open client sockets across method calls; > instead, open them, communicate through the socket, and close it > before returning from the method. > > So does it mean that we cannot use a HttpClient to invoke a > postmethod from within a EJB, as httpclient creates sockets. Please > clarify. Is there any other alternate way. > > Thanks, > > Karthi > > > Gareth Davis wrote: EJB + threads + > httpclient... yes does break the letter of the spec's, but yep it > works and it works just fine. > > Who ever wrote the spec that said you couldn't open a socket in an > EJB really wasn't living in the real world. > > The only thing to watch is that MultiThreadedConnectionManager does > start it's own thread for managing the pool, this does work in an EJB > but it won't be shutdown correctly when the application is stopped, > you may find that you create a thread leak. > > Having said this I've only tried this in WebSphere 4 and 5. Version 4 > it wasn't a big deal as the process for the appserver got restarted > when re-installing the app, but in websphere 5 it caused a leak. > > Gareth Davis Logical Practice Systems Limited > > gareth@logicalpractice.com On 4 Aug 2004, at 16:20, Karthikeyani K > wrote: > > >> Hi, We have all requests posted to a servlet which delegates the >> request to a Stateless Session Bean. Does creatring and invoking a >> Httpclient postmethod in a helper class invoked by the Stateless >> Session Bean violate any of the EJB specifications. (EJB spec says >> sockets are not to be created in EJB code etc. ). Please suggest. >> >> >> Thanks, Karthi >> >> __________________________________________________ Do You Yahoo!? >> Tired of spam? Yahoo! Mail has the best spam protection around >> http://mail.yahoo.com > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional > commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org > > > --------------------------------- Do you Yahoo!? New and Improved > Yahoo! Mail - Send 10MB messages! --------------------------------------------------------------------- To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org