<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Stateless Pooling In JBoss AS.
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/grdzeli_kaci">paata lominadze</a> in <i>EJB 3.0</i> - <a href="http://community.jboss.org/message/535357#535357">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>hi all,</p><p>I have strange problem.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My Env:</p><p>1. OS&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Sun Solaris Sparc</p><p>2.Application Server&#160;&#160; jboss-4.2.3.GA</p><p>3.java&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Oracle JRockit(R) version "1.6.0_05"</p><p><span>4.Ext. Lib.&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Apache http Client (</span><a class="jive-link-external-small" href="http://hc.apache.org/httpclient-3.x/" target="_blank">http://hc.apache.org/httpclient-3.x/</a><span>)</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have one stateless session bean which sends SMS Message to mobile using http client.</p><p>my session bean looks like :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Stateless<br/>@Remote(CommonFasade.class)<br/>public class CommonFasadeBean implements CommonFasade {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; private HttpClient httpClient = null;</p><p>&#160;&#160;&#160; public HttpClient getHttpClient() {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (httpClient == null) {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SimpleHttpConnectionManager manager = new SimpleHttpConnectionManager();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; manager.getParams().setConnectionTimeout(5000);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; manager.getParams().setSoTimeout(5000);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; httpClient = new HttpClient(manager);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return httpClient;<br/>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public void sendSMS(String fullSms, String phone, String from) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; HttpClient httpClient = getHttpClient();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; phone = Utils.trimPhone(phone);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; phone = getPhone(phone);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (phone == null) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; String sendToPhone = null;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; switch (phone.length()) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; case 8:<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sendToPhone = "%s2B995" + phone;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; case 9:<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sendToPhone = "%s2B995" + phone.substring(1);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; default:<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; String url = "</span><a class="jive-link-external-small" href="http://192.168.19.194:13013/cgi-bin/sendsms?from=" target="_blank">http://192.168.19.194:13013/cgi-bin/sendsms?from=</a><span>" + from</span><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + "&amp;username=1&amp;password=1&amp;to=" + sendToPhone + "&amp;text=%s";<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; long sc = -999;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (String sms : prepareSmsList(fullSms)) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; GetMethod method = new GetMethod(String.format(url, "%", sms));<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sc = httpClient.executeMethod(method);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (sc == HttpStatus.SC_ACCEPTED) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String response = method.getResponseBodyAsString();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (response.toLowerCase().indexOf("sent") != -1) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; logSMS(sms, phone, from);<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } finally {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; method.releaseConnection();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (Exception e) {<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br/>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>this code worked for tree years, but problem appeard some days ago.</p><p>every second or third day my jboss application server crashes.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>when i trying to find promlem i found this :</p><p>1. into solaris :</p><p>"netstat -an|grep 192.168.19.194|wc -l&#160; (this is SMS sender HTTP server)"</p><p>&#160;&#160;&#160;&#160; and result was : 12678</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>this is client socket connections from my jboss as, all of them is on a CLOSE_WAIT state.</p><p>After this when i looking into the jmx-console i found this :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/2469/MBeanView.jpeg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/2469/450-264/MBeanView.jpeg </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My question is why i have 12826 stateless session bean isntances into as ?</p><p>Into my jboss as stateless session pool config max size is 30.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>i think that something changed into&#160; HTTP Server or into network.</p><p>but i need workarount of this porblem .</p><p>is this pattern right for using http clients ? Maybe it will be more correct to use MDB for this ?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>when current size of my stateless session bean achieve 40000 the jboss as going down.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>can anybody help me what should i do ???</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>___________________</p><p>Regards,</p><p>Paata Lominadze.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/535357#535357">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB 3.0 at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>