Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: a little question about JNDI authentication

  1. #1

    Default a little question about JNDI authentication

    Hi guys, I have a simple and probably stupid question

    Currently I have an application that is doing some batch jobs. I use spring batch to achieve this. And i am connecting through the database using jndi. Since i am using websphere ( 6.1 ), I setup a jndi referrring to a datasource. In the datasource i specify a j2c configuration to supply the username and password.
    When i deploy my application, everthing works fine. The reAuth of my module is container.

    Then i try to put my batch code using a new console application. This is where i start to get problem. I cannot connect to the jndi. I keeps on complaining:
    PHP Code:
    caused byjava.sql.SQLException: [ibm][db2][jcc][t4][10205][11234Null userid is not supported.DSRA0010ESQL State nullError Code = -99,999
        at com
    .ibm.db2.jcc.b.b.E(b.java:1792)
        
    at com.ibm.db2.jcc.b.b.d(b.java:1799)
        
    at com.ibm.db2.jcc.b.b.b(b.java:606)
        
    at com.ibm.db2.jcc.b.b.a(b.java:593)
        
    at com.ibm.db2.jcc.b.b.a(b.java:355)
        
    at com.ibm.db2.jcc.b.b.<init>(b.java:292)
        
    at com.ibm.db2.jcc.DB2PooledConnection.<init>(DB2PooledConnection.java:67)
        
    at com.ibm.db2.jcc.DB2ConnectionPoolDataSource.getPooledConnectionX(DB2ConnectionPoolDataSource.java:144)
        
    at com.ibm.db2.jcc.DB2ConnectionPoolDataSource.getPooledConnection(DB2ConnectionPoolDataSource.java:58)
        
    at com.ibm.ws.rsadapter.spi.InternalGenericDataStoreHelper$1.run(InternalGenericDataStoreHelper.java:897)
        
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
        
    at com.ibm.ws.rsadapter.spi.InternalGenericDataStoreHelper.getPooledConnection(InternalGenericDataStoreHelper.java:892)
        
    at com.ibm.ws.rsadapter.spi.InternalDB2UniversalDataStoreHelper.getPooledConnection(InternalDB2UniversalDataStoreHelper.java:1323)
        
    at com.ibm.ws.rsadapter.spi.WSRdbDataSource.getPooledConnection(WSRdbDataSource.java:1180)
        
    at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:1047)
        
    at com.ibm.ws.rsadapter.spi.WSDefaultConnectionManagerImpl.allocateConnection(WSDefaultConnectionManagerImpl.java:81)
        
    at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:431)
        
    at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:400)
        
    at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
        
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
        ... 
    13 more 
    So the main different between my 1st and second code is the second one is not running inside the application container.

    I try to supply the credentials in the initialcontext but it is not working
    PHP Code:
    <bean id="rlosTXTarget" class="org.springframework.jndi.JndiObjectFactoryBean">
            <
    property name="jndiName">
                <
    value>POOL</value>
            </
    property>
            <
    property name="jndiTemplate">
                <
    ref local="dsJndiTemplate" />
            </
    property>
        </
    bean>

    <
    bean id="dsJndiTemplate" class="org.springframework.jndi.JndiTemplate">
            <
    property name="environment">
                <
    props>
                    <
    prop key="java.naming.provider.url">t3://localhost:80</prop>
                    
    <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
                    <
    prop key="java.naming.security.principal">user</prop>
                    <
    prop key="java.naming.security.credentials">user</prop>
                    <
    prop key="java.naming.security.authentication">none</prop>
                    
                    
                </
    props>
            </
    property>
        </
    bean

    So my question is that can i actually pass username and password in the jnditemplate or actually there is something wrong with my server configuration ?

    Thanks for any reply

    regards

    ballistic_realm
    Last edited by ballistic_realm; Dec 23rd, 2008 at 12:03 AM.

  2. #2

    Default

    Can anybody help ?

  3. #3
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    I don't think it's a jndi authentification but db authentification problem.

  4. #4

    Default

    Hi

    Can you elaborate more by what you mean as db authentication problem ?

    thanks

  5. #5
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Well, it's a db2 exception you are getting:

    java.sql.SQLException: [ibm][db2][jcc][t4][10205][11234] Null userid is not supported.DSRA0010E: SQL State = null, Error Code = -99,999
    at com.ibm.db2.jcc.b.b.E(b.java:1792)
    at com.ibm.db2.jcc.b.b.d(b.java:1799)
    so I guess your datasource is not correctly configured.

  6. #6

    Default

    My datasource is correctly configured since i can connect to it from inside the container ( my web application deployed in the server) but not a console application outside the container

    I still dont know why though...

    thanks

  7. #7
    Join Date
    Jul 2009
    Posts
    3

    Default

    Did you get answer to your question. In WAS for DB Connection, you need a J2C Authentication entry. With in container, the authentication happens with this, outside container you need to pass user id and password while getting connection from datasource.

  8. #8
    Join Date
    Nov 2008
    Posts
    4

    Default

    I have the same problem, i only get the connection passing through the params, the username and pass. But the thing is that i have to connect without those params for security.
    Thanks

  9. #9
    Join Date
    Jul 2009
    Posts
    3

    Default

    You have to add an entry for resource-ref in your application's web.xml for the datasource. I am sure this should solve the problem.

  10. #10
    Join Date
    Nov 2008
    Posts
    4

    Default StandAlone app

    This is a StandAlone app, its a batch, that communicates with the database. Now, i'm managing the connection through a local datasource, but the things is that i need to use the jndi datasource for security reasons, which is reasonable.
    But, my problem is that, when i get the jndi datasource, then i cannot get the connection without passing the user and pass , which means that it is not using the credentials defined in WAS console.
    I hope you can help me, thanks for the response.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •