Bug 1091419 - Datasource security doesn't work with kerberos security domain and JPA on oracle
Summary: Datasource security doesn't work with kerberos security domain and JPA on oracle
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: JCA
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: DR4
: EAP 6.4.0
Assignee: Jesper Pedersen
QA Contact: Martin Simka
URL:
Whiteboard:
Depends On:
Blocks: 1147419
TreeView+ depends on / blocked
 
Reported: 2014-04-25 14:32 UTC by Martin Simka
Modified: 2019-08-19 12:41 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)
server.log (361.50 KB, text/x-log)
2014-04-25 14:32 UTC, Martin Simka
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1166719 0 unspecified CLOSED Incosistent matching of MCPs in PoolBySubject 2021-02-22 00:41:40 UTC
Red Hat Issue Tracker EAP6-215 0 Major Closed Authorization with static Kerberos credentials to Oracle DB on Oracle JVM 2019-03-04 12:46:30 UTC
Red Hat Issue Tracker EAP6-36 0 Critical New Propagate Kerberos session to Oracle Datasources on Oracle JDK 2019-03-04 12:46:30 UTC
Red Hat Issue Tracker JBJCA-1179 0 Major Closed Guard against Subject modification 2019-03-04 12:46:30 UTC

Internal Links: 1166719

Description Martin Simka 2014-04-25 14:32:42 UTC
Created attachment 889778 [details]
server.log

Description of problem:
When datasource is configured to use security domain with Kerberos authetication and application (ejb) tries to call em.persist(entity), exception is raised. Server tries to enlist / obtain connections when the transaction is in rollback mode (ABORT_ONLY). See attached server.log for full stacktrace. 

When I change datasource to use user-name/password, it works. Adjusting of pool size have no effect. 

15:33:11,543 TRACE [org.jboss.jca.core.connectionmanager.listener.TxConnectionListener] (http-/127.0.0.1:8080-4) Failed to enlist resource org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@48b75e7f[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@7e9d0924 connection handles=0 lastUse=1398432791336 trackByTx=true pool=org.jboss.jca.core.connectionmanager.pool.strategy.PoolBySubjectAndCri@682d524c pool internal context=SemaphoreArrayListManagedConnectionPool@124473c4[pool=TestDatasource] xaResource=LocalXAResourceImpl@77c35b6c[connectionListener=48b75e7f connectionManager=54a935d warned=false currentXid=null productName=Oracle productVersion=Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options jndiName=java:jboss/datasources/TestDatasource] txSync=TxSync@984042721{tx=TransactionImple < ac, BasicAction: 0:ffff7f000101:-63ea678b:535a63fd:e status: ActionStatus.ABORT_ONLY > wasTrackByTx=true enlisted=false}]: java.lang.Throwable: Unabled to enlist resource, see the previous warnings.
        at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener$TransactionSynchronization.<init>(TxConnectionListener.java:630)
        at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener.enlist(TxConnectionListener.java:316)
        at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.managedConnectionReconnected(TxConnectionManagerImpl.java:483)
        at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.reconnectManagedConnection(AbstractConnectionManager.java:623)
        at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:491)
        at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:143)
...


EJB:
@PersistenceContext(unitName = "defaultPU")
private EntityManager em;

public void test() {
        TestEntity entity = new TestEntity();
        entity.setValue("some value");

        em.persist(entity);
}

Datasource:
                <datasource jndi-name="java:jboss/datasources/TestDatasource" pool-name="TestDatasource" enabled="true" spy="true">
                    <connection-url>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db04.mw.lab.eng.bos.redhat.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=qaora11.jbossqa)))</connection-url>
                    <connection-property name="oracle.net.authentication_services">
                        (KERBEROS5)
                    </connection-property>
                    <driver>oracle11gR2.jar</driver>
                    <pool>
                        <min-pool-size>0</min-pool-size>
                        <max-pool-size>1</max-pool-size>
                        <allow-multiple-users>true</allow-multiple-users>
                    </pool>
                    <security>
                        <security-domain>DatabaseUser</security-domain>
                    </security>
                </datasource>

*Version-Release number of selected component (if applicable):
EAP 6.3.0.ER2
IronJacamar 1.0.26

*Steps to Reproduce:
1. clone datasource-kerberos test suite git://git.app.eng.bos.redhat.com/jbossqe-eap-tests-domain-mode.git
2. extract eap somewhere
3. run mvn integration-test -Djboss.dist=<path-to-eap> -Ddb.profile=oracle11gR2 -Djdbc.installation.type=deployment -Dit.test=org.jboss.qa.krbds.test.DatasourceWithAllowMultipleUsersTestCase#testDatasourceJPA
4. test fails, see server.log

for manual testing you can now run eap and deploy app target/deployment/_DEFAULT__jpaTestDeployment_HostTestWebApp-jpa.war and then access http://localhost:8080/HostTestWebApp/HostTestServlet

Comment 2 Jesper Pedersen 2014-04-30 12:24:30 UTC
You can't obtain connections once a transaction is in rollback mode.

This needs further investigation.

Comment 3 Martin Simka 2014-05-13 08:14:24 UTC
this issue seems to be oracle exclusive, mentioned tests pass on mssql

Comment 4 Ivo Studensky 2014-05-14 04:55:21 UTC
The reason for roll-back only state is as follows:

15:33:11,341 WARN  [com.arjuna.ats.arjuna] (http-/127.0.0.1:8080-4) ARJUNA012140: Adding multiple last resources is disallowed. Trying to add LastResourceRecord(XAOnePhaseResource(LocalXAResourceImpl@77c35b6c[connectionListener=48b75e7f connectionManager=54a935d warned=false currentXid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffff7f000101:-63ea678b:535a63fd:e, node_name=1, branch_uid=0:ffff7f000101:-63ea678b:535a63fd:17, subordinatenodename=null, eis_name=java:jboss/datasources/TestDatasource > productName=Oracle productVersion=Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options jndiName=java:jboss/datasources/TestDatasource])), but already have LastResourceRecord(XAOnePhaseResource(LocalXAResourceImpl@36b6ed73[connectionListener=44b40d42 connectionManager=54a935d warned=false currentXid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffff7f000101:-63ea678b:535a63fd:e, node_name=1, branch_uid=0:ffff7f000101:-63ea678b:535a63fd:16, subordinatenodename=null, eis_name=java:jboss/datasources/TestDatasource > productName=Oracle productVersion=Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options jndiName=java:jboss/datasources/TestDatasource]))


It doesn't correctly track connections in the pool for Oracle database. After em.persist(entity) it creates a new connection and a new LocalXAResourceImpl by PoolBySubject#getTransactionNewConnection(). But then within beforeCompletion() it creates another new connection by PoolBySubject#getTransactionNewConnection() and thus another new LocalXAResourceImpl which it tries to enlist to the non-XA tx which fails.

The second time, i.e. within beforeCompletion(), when it tries to find an old connection by AbstractPool#getTransactionOldConnection(Transaction trackByTransaction, ManagedConnectionPool mcp) the mcp managed connection pool is different to the previous one and so {{ConnectionListener cl = (ConnectionListener)tsr.getResource(mcp);}} returns null instead of a connection listener which is stored in tsr at that time. I am still not sure however why the mcp differs in this case.

Comment 5 Ivo Studensky 2014-05-15 08:44:35 UTC
The issue cannot be debugged anymore due to outage of the kerberos server.

Anyway, I have a suspicion that Oracle database changes the Subject somehow which leads to this issue.

What happens there according to the attached server.log is that a new instance of SemaphoreArrayListManagedConnectionPool appears within beforeCompletion() which seems to be caused by a different key created by

Object key = getKey(subject, cri, separateNoTx);

at AbstractPool#getConnection() method. In this case the pool is a subject based one, thus the subject has to be different (as per SubjectKey code) which leads to a different key which then leads to a new managed connection pool created in AbsractPool#getManagedConnectionPool().

We need the kerberos server being up back to confirm this.

Comment 11 JBoss JIRA Server 2014-05-21 13:23:59 UTC
Jesper Pedersen <jpederse> updated the status of jira JBJCA-1179 to Closed

Comment 12 JBoss JIRA Server 2014-08-25 13:14:31 UTC
Jesper Pedersen <jpederse> updated the status of jira JBJCA-1179 to Reopened

Comment 13 JBoss JIRA Server 2014-09-09 15:26:28 UTC
Jesper Pedersen <jpederse> updated the status of jira JBJCA-1179 to Resolved

Comment 14 JBoss JIRA Server 2014-09-16 12:18:03 UTC
Jesper Pedersen <jpederse> updated the status of jira JBJCA-1179 to Closed

Comment 15 Ivo Studensky 2014-09-16 13:09:30 UTC
It has been fixed in IJ.

Comment 16 Ivo Studensky 2014-09-29 08:54:27 UTC
It will be fixed by upgrade to 1.0.28.Final.

Comment 17 Martin Simka 2014-10-16 11:49:13 UTC
verified on EAP 6.4.0.DR4

Comment 18 JBoss JIRA Server 2014-12-01 15:58:43 UTC
Kabir Khan <kabir.khan> updated the status of jira EAP6-215 to Resolved

Comment 19 JBoss JIRA Server 2015-04-28 15:05:23 UTC
John Doyle <jdoyle> updated the status of jira EAP6-215 to Closed


Note You need to log in before you can comment on or make changes to this bug.