Discussion:
[jboss-user] [IronJacamar] - "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info
berw
2013-08-12 13:07:10 UTC
Permalink
berw [https://community.jboss.org/people/berw] created the discussion

""getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info"

To view the discussion, visit: https://community.jboss.org/message/832314#832314

--------------------------------------------------------------
Hi all,

we are on our way to port our long time existing application to JBOSS 7.2 (before we used JBOSS 5 and we support WAS as well). One of the functions uses different connection instances of the same type of one JCA Connector within the same transaction. The different calls to getConnection get different connection request info objects. But even if they are different the second call to "getConnections" returns the first fetched and created connection. In this case the connection however is not sharable and is not meant to be.

Does anybody have the same or similar problem? Is this really a JBOSS bug or do I use it the wrong way?

Thanks for comments and best regards,
Wolfgang
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832314#832314]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
Jesper Pedersen
2013-08-12 13:10:51 UTC
Permalink
Jesper Pedersen [https://community.jboss.org/people/jesper.pedersen] created the discussion

"Re: "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info"

To view the discussion, visit: https://community.jboss.org/message/832316#832316

--------------------------------------------------------------
Well, you didn't post any configuration, so I'm guessing the wrong way ;) Do you have <security><application/></security> ?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832316#832316]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
berw
2013-08-12 13:26:44 UTC
Permalink
berw [https://community.jboss.org/people/berw] created the discussion

"Re: "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info"

To view the discussion, visit: https://community.jboss.org/message/832320#832320

--------------------------------------------------------------
Ok, what do you need to see?

*The resourceReference in the DD of the using EJB (the client) looks like this:*
<session id="PCEXMLExchangeRateImportImpl">
          <ejb-name>PCEXMLExchangeRateImportImpl</ejb-name>
          <local-home>com.myproclassic.server.services.exchangerate.importer.PCEExchangeRateImportImplLocalHome</local-home>
          <local>com.myproclassic.server.services.exchangerate.importer.PCEExchangeRateImportImplLocal</local>
          <ejb-class>com.myproclassic.server.services.exchangerate.importer.xml.PCEXMLExchangeRateImportImplBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Bean</transaction-type>
          <resource-ref id="ResourceRef_RaFile">
                    <description>
                    </description>
                    <res-ref-name>res/PCERAFile</res-ref-name>
                    <res-type>javax.resource.cci.ConnectionFactory</res-type>
                    <res-auth>Container</res-auth>
*<res-sharing-scope>Unshareable</res-sharing-scope>*
          </resource-ref>
</session>



*The client code looks like this:*
+PCERAFileConnectionRequestInfo requestInfoTemp = new PCERAFileConnectionRequestInfo(newName, "rw"); // newName is different at the second call within the same transaction.+
+fileConnection = (PCERAFileConnection) raFileConnectionFactory.getConnection(requestInfoTemp);+
+if (fileConnection != null)+
+     return fileConnection.getRandomAccessFile();+

*The connectionRequestInfo looks like this:*
+package com.wincor.jca;+
+import javax.resource.cci.ConnectionSpec;+
+import javax.resource.spi.ConnectionRequestInfo;+

+public class PCERAFileConnectionRequestInfo implements ConnectionRequestInfo, ConnectionSpec {+
+    private String fileName = "";+
+    private String openMode = "";+

+    public PCERAFileConnectionRequestInfo(String fileName, String openMode)     {+
+        this.fileName = fileName;+
+                         this.openMode = openMode;+
+    }+

+           public int hashCode() {+
+            return fileName.hashCode() + openMode.hashCode();+
+      }+

+    public boolean equals(Object obj)     {+
+        boolean result = false;+

+        if (obj != null)         {+
+            if (obj instanceof PCERAFileConnectionRequestInfo)             {+
+                                                       result = ((PCERAFileConnectionRequestInfo) obj).getFileName().equals(fileName)  && ((PCERAFileConnectionRequestInfo) obj).getOpenMode().equals(openMode);+
+            }+
+        }+
+        return result;+
+    }+
+    public String getFileName()    {+
+        return fileName;+
+    }+

+    public String getOpenMode()     {+
+        return openMode;+
+    }+
+}+
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832320#832320]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
Jesper Pedersen
2013-08-12 13:30:25 UTC
Permalink
Jesper Pedersen [https://community.jboss.org/people/jesper.pedersen] created the discussion

"Re: "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info"

To view the discussion, visit: https://community.jboss.org/message/832323#832323

--------------------------------------------------------------
It was more the configuration of the :resource-adapters: subsystem. However, you maybe running into https://issues.jboss.org/browse/JBEAP-24 https://issues.jboss.org/browse/JBEAP-24
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832323#832323]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
berw
2013-08-12 14:21:51 UTC
Permalink
berw [https://community.jboss.org/people/berw] created the discussion

"Re: "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info"

To view the discussion, visit: https://community.jboss.org/message/832335#832335

--------------------------------------------------------------
There are some JCA connectors in the configuration but the one that keeps me busy is not configured there. It has an ironjacamar.xml file in its META-INF folder. Isn't that a way to configure it?

<?xml version="1.0" encoding="UTF-8"?>
<p:ironjacamar xmlns:p=" http://www.jboss.org/ironjacamar/schema http://www.jboss.org/ironjacamar/schema"
          xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation=" http://www.jboss.org/ironjacamar/schema http://www.jboss.org/ironjacamar/schema http://www.jboss.org/ironjacamar/schema http://www.jboss.org/ironjacamar/schema ">
          <p:connection-definitions>
                    <p:connection-definition
                              jndi-name="java:/PCERAFile"
                              class-name="com.wincor.jca.PCERAFileManagedConnectionFactory">
                    </p:connection-definition>
          </p:connection-definitions>
</p:ironjacamar>
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832335#832335]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
Jesper Pedersen
2013-08-12 14:25:20 UTC
Permalink
Jesper Pedersen [https://community.jboss.org/people/jesper.pedersen] created the discussion

"Re: "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info"

To view the discussion, visit: https://community.jboss.org/message/832336#832336

--------------------------------------------------------------
That is ok.

However, there won't be any run-time manament of the resource. So depends if you need that or not... Only :resource-adapters: has it.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832336#832336]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
berw
2013-08-12 14:57:37 UTC
Permalink
berw [https://community.jboss.org/people/berw] created the discussion

"Re: "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info"

To view the discussion, visit: https://community.jboss.org/message/832346#832346

--------------------------------------------------------------
*OK it works now*. The problem was a missing setting for min and max pool size in the ironjacamar.xml. That seems to cause the use of the "OnePool". The "OnePool" implementation seems to ignore the ConnectionRequestInfo. Dont know whether it should better raise a ResourceException?

Hopefully the currently used pool implementation takes the CRI into account and it does not work by accident now (just by having more choice?)

Anyways, I really appreciate your help!
Thank you very much and best regards,
Wolfgang

*Looks like this now:*
<?xml version="1.0" encoding="UTF-8"?>
<p:ironjacamar xmlns:p=" http://www.jboss.org/ironjacamar/schema http://www.jboss.org/ironjacamar/schema"
          xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation=" http://www.jboss.org/ironjacamar/schema http://www.jboss.org/ironjacamar/schema http://www.jboss.org/ironjacamar/schema http://www.jboss.org/ironjacamar/schema ">
          <p:connection-definitions>
                    <p:connection-definition
                              jndi-name="java:/PCERAFile"
                              class-name="com.wincor.jca.PCERAFileManagedConnectionFactory">
            <p:pool>
                <p:min-pool-size>10</p:min-pool-size>
                <p:max-pool-size>100</p:max-pool-size>
            </p:pool>
            <p:security>
               <p:application/>
            </p:security>
                    </p:connection-definition>
          </p:connection-definitions>
</p:ironjacamar>
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832346#832346]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
Jesper Pedersen
2013-08-12 14:59:48 UTC
Permalink
Jesper Pedersen [https://community.jboss.org/people/jesper.pedersen] created the discussion

"Re: "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info"

To view the discussion, visit: https://community.jboss.org/message/832347#832347

--------------------------------------------------------------
No, the missing <security><application/></security> causes that. Adding that and you will get a pool which looks at the CRI objects.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832347#832347]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
berw
2013-08-12 15:08:39 UTC
Permalink
berw [https://community.jboss.org/people/berw] created the discussion

"Re: "getConnection" returns a shared connection regardless of the sharable property in the resource reference and regardless of the connection request info"

To view the discussion, visit: https://community.jboss.org/message/832350#832350

--------------------------------------------------------------
OK, got it! Thanks again.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832350#832350]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
Loading...