dev@glassfish.java.net

[gf-dev] Re: can't release connection correctly when using resource adapter

From: William <streetpoet_at_163.com>
Date: Thu, 18 Sep 2014 17:29:48 +0800

Dear Jagadish,

        I created corresponding JIRA issue for that and wrote a simple solution in description, https://java.net/jira/browse/JAVAEETUTORIAL-286, thanks.

########################
William
System Architect
streetpoet_at_163.com
########################

On Sep 18, 2014, at 4:56 PM, Jagadish Prasath Ramu <jagadish.ramu_at_oracle.com> wrote:

> Hi William,
>
> It looks like an issue in the sample resource-adapter that does not send
> events to container whenever a connection is closed via a
> javax.resource.spi.ConnectionEventListener implementation.
>
> Could you please raise a JIRA issue ?
> http://java.net/jira/browse/JAVAEETUTORIAL
>
> Thanks,
> -Jagadish
>
> On Tue, 2014-09-16 at 15:28 +0800, William wrote:
>> Dear Experts,
>>
>>
>> I am trying to write a custom resource adapter. But met some problems,
>> so I re-run the example provided by Glassfish to test if has the same
>> issue. when I run the ‘traffic’ example, Also I found it can’t release
>> connection correctly after I set the attribute ‘maxPoolSize’ attribute
>> of @ConnectionFactoryDefinition. If I set this attribute to 5, that
>> means I can only use factory to get connection 5 times. In the 6th,
>> system will hang up and will get error message later. Even I have
>> released connection in time.
>>
>>
>> For the ‘ trading' example bundled with Glassfish, I just change one
>> place.(the project is under
>> <glassfish_home>/docs/javaee-tutorial/examples/connectors/trading)
>> the original definition in ‘ResourceAccessBean’class is as below:
>>
>>
>> @ConnectionFactoryDefinition(
>> name = "java:comp/env/eis/TradeConnectionFactory",
>> interfaceName =
>> "javaeetutorial.trading.rar.api.TradeConnectionFactory",
>> resourceAdapter = "#trading-rar",
>> minPoolSize = 5,
>> transactionSupport =
>>
>> TransactionSupport.TransactionSupportLevel.NoTransaction
>> )
>>
>>
>> and I just add one more attribute of it as below:
>>
>>
>> @ConnectionFactoryDefinition(
>> name = "java:comp/env/eis/TradeConnectionFactory",
>> interfaceName =
>> "javaeetutorial.trading.rar.api.TradeConnectionFactory",
>> resourceAdapter = "#trading-rar",
>> minPoolSize = 5,
>> maxPoolSize = 10,
>> transactionSupport =
>>
>> TransactionSupport.TransactionSupportLevel.NoTransaction
>> )
>>
>>
>> And this is the only place I modified, after changing, I refresh the
>> browser and repeat to click button ‘connect' and ‘disconnect’. When
>> the 11th, the browser hang up, and display error message later:
>> Error in allocating a connection. Cause: In-use connections equal
>> max-pool-size and expired max-wait-time. Cannot allocate more
>> connections.
>>
>>
>> Since I haven’t change other code, and just run example bundled with
>> Glassfish, So I think maybe there exist some bugs that not properly
>> release connection.
>> Can anybody help me to take a look at this issue? Thank you very much!
>>
>>
>> My Environment:
>>
>>
>> Glassfish 4.1 (build 13)
>> Oracle Java 1.7.0_51-b13
>>
>>
>> ########################
>> William
>> System Architect
>> streetpoet_at_163.com
>> ########################
>>
>>
>>
>
>