Ilegal argument exception when reading from resource object

38 views
Skip to first unread message

ionut.andras

unread,
Aug 5, 2011, 8:22:38 AM8/5/11
to mobicent...@googlegroups.com
Hi,

I have the following situation:

1. 10 clients came simultaneous on my server (HTTP POST Request with an XML in the body)
2. The server processes the requests
3. Immediately other 10 clients are coming to the server
4. The server processes most of the requests but sometimes it fires the following exception:
java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:218)
at org.apache.tomcat.util.buf.B2CConverter.convert(B2CConverter.java:84)
at org.apache.catalina.connector.InputBuffer.realReadChars(InputBuffer.java:403)
at org.apache.tomcat.util.buf.CharChunk.substract(CharChunk.java:416)
......
5. The other requests are working fine until another moment when the same exception is fired
6. After few tens or couple hounded of this error, the following exception is fired from time to time:

 org.jboss.util.NestedSQLException: Unable to get managed connection for MySQLDB1; - nested throwable: (javax.resource.ResourceException: Unable to get managed connection for MySQLDB1
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
.........
Caused by: javax.resource.ResourceException: Unable to get managed connection for MySQLDB1
at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:441)
at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:381)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
... 15 more


7. The server treats most of the next requests correctly
8. After a few tens or couple houndred of these last exception combined with few tens of the first exception,
the server does not process correctly any request anymore giving one of the two exceptions for every single request
until I restart mobincents

My method for this is:
- please observe in the comments that I've tried several methods with same result

    public String getRequestBody(HttpServletRequest request) {
        StringBuilder body = new StringBuilder();
        BufferedReader reader = null;
        try {
            reader = request.getReader();
            int bufferLength = 1024; // 1KB buffer
            char[] buffer = new char[bufferLength];
            int bytesRead = 0;
           
            if (null != reader) {
                while (-1 != (bytesRead = reader.read(buffer, 0, buffer.length))) {
                    body.append(buffer, 0, bytesRead);
                }
               
//                String  tmpStr = null;
//                while (null != (tmpStr = reader.readLine())){
//                    body.append(tmpStr);                   
//                }

                //reading char by char as there is an issue in JBOSS 5.1.0 GA
//                while (-1 != (bytesRead = reader.read())) {
//                    body.append((char)bytesRead);
//                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
       
        try {
            reader.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return body.toString();
    }

Mobicents 2.4 JAIN SLEE
HTTP Servlet RA

Anyone have a clue?

Thanks

Reply all
Reply to author
Forward
0 new messages