1 2 Previous Next 18 Replies Latest reply: Apr 16, 2012 2:56 AM by jaikiran pai RSS

DataSource.getConnection(String username, String password) polluting datasource?

Nicklas Karlsson Master

I have a datasource from which I sometimes pull user-specific connections with the getConnection(username, password) method. However, when I at a later point use the normal getConnection(), the datasource appears to have been "polluted" with the user specific credentials and I end up with a

 

Caused by: javax.resource.ResourceException: Wrong credentials passed to getConnection!
 at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.checkIdentity(BaseWrapperManagedConnection.java:788)
 at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.getConnection(BaseWrapperManagedConnection.java:402)
 at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:473)

 

What would be the correct way to handle this scenario and ensure that the user-credentials are cleared after releasing the connection?

 

Thanks in advance,

  Nik

  • 1. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Nicklas Karlsson Master

    Eyeing through the code it looks like there is a concept of ReauthEnabled on the BaseWrapperManagedConnectionFactory and if that one is false (as per default), the current properties are checked against the ones in the connection and if mismatch, kaboom?

     

    Related to this, perhaps? https://community.jboss.org/wiki/Reauthentication

  • 2. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Jesper Pedersen Master

    Nicklas, I'll take a look once I have a moment.

  • 3. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Nicklas Karlsson Master

    It would be handy if the connection would return to the original, data-source-defined credentials upon close/return to the pool.

  • 5. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Jesper Pedersen Master

    And what is your datasource definition where you are seeing this ?

  • 6. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Nicklas Karlsson Master

    I'm on upstream master (from yesterday or so)

     

    The trace is

     

    Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000456: Unchecked throwable in ManagedConnection.getConnection() cl=org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@7f81df5e[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@1220990a connection handles=0 lastUse=1333604337614 trackByTx=false pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@5f045ffa pool internal context=SemaphoreArrayListManagedConnectionPool@1a1f68d2[pool=OSTiDataSource] xaResource=LocalXAResourceImpl@41ac064[connectionListener=7f81df5e connectionManager=1eb2f376 warned=false currentXid=null] txSync=null]
     at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:137)
     at my.DBUtil.getConnection(DBUtil.java:114)
     ... 21 more
    Caused by: javax.resource.ResourceException: IJ000456: Unchecked throwable in ManagedConnection.getConnection() cl=org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@7f81df5e[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@1220990a connection handles=0 lastUse=1333604337614 trackByTx=false pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@5f045ffa pool internal context=SemaphoreArrayListManagedConnectionPool@1a1f68d2[pool=OSTiDataSource] xaResource=LocalXAResourceImpl@41ac064[connectionListener=7f81df5e connectionManager=1eb2f376 warned=false currentXid=null] txSync=null]
     at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:487)
     at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:129)
     ... 22 more
    Caused by: javax.resource.ResourceException: Wrong credentials passed to getConnection!
     at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.checkIdentity(BaseWrapperManagedConnection.java:795)
     at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.getConnection(BaseWrapperManagedConnection.java:409)
     at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:473)
     ... 23 more
    
    

     

    the DS config is

     

     

                    <datasource jndi-name="java:jboss/datasources/MyDataSource" pool-name="MyDataSource" enabled="true">
                        <connection-url>jdbc:oracle:thin:@host:1521:db</connection-url>
                        <driver>oracle</driver>
                        <new-connection-sql>ALTER SESSION SET NLS_NUMERIC_CHARACTERS='.,'</new-connection-sql>
                        <pool>
                            <min-pool-size>2</min-pool-size>
                            <max-pool-size>2</max-pool-size>
                            <prefill>true</prefill>
                            <use-strict-min>true</use-strict-min>
                            <flush-strategy>EntirePool</flush-strategy>
                        </pool>
                        <security>
                            <user-name>me</user-name>
                            <password>me</password>
                        </security>
                        <validation>
                            <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
                            <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
                            <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
                        </validation>
                        <timeout>
                            <idle-timeout-minutes>10</idle-timeout-minutes>
                        </timeout>
                    </datasource>
    
    

     

    (lowered the pool size so I would be sure to get more mixed up credentials)

     

    I'm also seeing stuff like

     

     

    08:36:42 /:@ WARN  IJ000612: Destroying connection that could not be successfully matched: org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@3bf73da7[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@12d6f747 connection handles=0 lastUse=1333604171394 trackByTx=false pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@5f045ffa pool internal context=SemaphoreArrayListManagedConnectionPool@183946d2[pool=OSTiDataSource] xaResource=LocalXAResourceImpl@5858916a[connectionListener=3bf73da7 connectionManager=1eb2f376 warned=false currentXid=null] txSync=null]
    08:36:42 /:@ WARN  IJ000612: Destroying connection that could not be successfully matched: org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@21cfeaeb[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.local.LocalManagedConnection@5947fba4 connection handles=0 lastUse=1333604169481 trackByTx=false pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@5f045ffa pool internal context=SemaphoreArrayListManagedConnectionPool@183946d2[pool=OSTiDataSource] xaResource=LocalXAResourceImpl@4d9f9c7[connectionListener=21cfeaeb connectionManager=1eb2f376 warned=false currentXid=null] txSync=null]
    
    

     

    (and probably unrelated, some low-level read timeouts on a DB connection that should be network-wise just fine)

     

     

    Caused by: java.sql.SQLRecoverableException: IO Error: Socket read timed out
              at oracle.jdbc.driver.T4CPreparedStatement.fetch(T4CPreparedStatement.java:1093)
              at oracle.jdbc.driver.OracleResultSetImpl.close_or_fetch_from_next(OracleResultSetImpl.java:359)
              at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:263)
              at org.jboss.jca.adapters.jdbc.WrappedResultSet.next(WrappedResultSet.java:1862)
              at fi.affecto.webmarela.excel.muodostaja.ExcelTietokanta.haeSarakemäärittelyt(ExcelTietokanta.java:267) [classes:]
              ... 3 more
    Caused by: oracle.net.ns.NetException: Socket read timed out
              at oracle.net.ns.Packet.receive(Packet.java:321)
              at oracle.net.ns.DataPacket.receive(DataPacket.java:103)
              at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:230)
              at oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
    
    
  • 7. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Nicklas Karlsson Master

    (OK the network issue was, surprise, surprise, network-related. Switched to another interface and it appears to have gone away)

     

    Reading on, the matching-warning comes from the fact that the credentials changed between checkin and checkout from the pool?

  • 8. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Jesper Pedersen Master

    Thanks.

     

    While I'm thinking could you try the attached files, and send me the TRACE log from org.jboss.jca ?

  • 9. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Jesper Pedersen Master

    Nah, I'm not gonna do it this way for sure...

  • 10. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Jesper Pedersen Master

    Can you try the attached files, and see if they work for you in this scenario -- temp fix for this case only.

  • 11. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Nicklas Karlsson Master

    Hey, the easter bunny has been busy while I was away, thanks!

     

    It appears to solve the current issue. What was the approach for this fix and what do you think the final solution will be (should there be a JIRA to track)?

  • 12. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Jesper Pedersen Master

    We will fix it with a new datasources subsystem revision which will contain an <allow-multiple-users/> element under the pool definition.

  • 13. Re: DataSource.getConnection(String username, String password) polluting datasource?
    Nicklas Karlsson Master

    Was there any JIRA for it so I can keep track on when the workaround is no longer needed?

1 2 Previous Next