Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Using JNDI Datasource with SmartGWT

    Hi,

    I have problems to connect to the connection pool of my application server. I used the search function, but I didn' find any answers to my problem.

    Application Server: Glassfish
    DB: Oracle
    SmartGwt: Version 2.1 (Eval) [The Power Version is already ordered)

    Configuration web.xml:

    <resource-ref>
    <res-ref-name>jdbc/SdomPool</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>

    Configuration sun.web.xml:

    <sun-web-app>
    <resource-ref>
    <res-ref-name>jdbc/SdomPool</res-ref-name>
    <jndi-name>jdbc/SdomPool</jndi-name>
    </resource-ref>
    <security-role-mapping>
    <role-name>ASADMIN</role-name>
    <group-name>asadmin</group-name>
    </security-role-mapping>
    </sun-web-app>

    With the following Code on the Server-Side the access to the Connection-Pool is working:

    InitialContext context = new InitialContext();
    javax.sql.DataSource dataSource = (javax.sql.DataSource) context .lookup("jdbc/SdomPool")connection = dataSource.getConnection();

    If I'm using the Admin Console to configure the JDNI-Datsource I get the following Exception:

    Failure: Unable to connect. Error from Driver: java.lang.NullPointerException

    === 2010-07-22 13:41:49,106 [7-21] DEBUG BuiltinRPC - Testing DB connection for database: jdbc/SdomPool with config: {
    "driver.networkProtocol":"tcp",
    "interface.credentialsInURL":true,
    dbName:"jdbc/SdomPool",
    "database.type":"oracle",
    isDefault:true,
    "interface.type":"jndi",
    dbStatus:"Unable to connect",
    "driver.serverName":"localhost",
    "pool.enabled":"false",
    "driver.driverType":"thin",
    "driver.context":"_container_",
    "driver.portNumber":"1521",
    _selection_3:true,
    name:"jdbc/SdomPool"
    }
    === 2010-07-22 13:41:49,106 [7-21] DEBUG PoolableSQLConnectionFactory - Initializing SQL config for 'jdbc/SdomPool' via JNDI
    === 2010-07-22 13:41:49,107 [7-21] DEBUG JNDI - No configuration for JNDI context _container_ - assuming default initialContext
    === 2010-07-22 13:41:49,108 [7-21] DEBUG JNDI - Detected container context, using new InitialContext(env) lookup method
    === 2010-07-22 13:41:49,110 [7-21] INFO BuiltinRPC - testDB (jdbc/SdomPool) error: java.lang.NullPointerException




    Regards

    Christian

    #2
    Try using just "SdomPool" as the dbName. If that's not working, open the SQL DataSource Wizard in Visual Builder (see FAQ) and you should see your JNDI database in the list of DataSources in the dropdown - use whatever name is shown there.

    Comment


      #3
      Over that way the JNDI DataSouce didn't appear in the wizard, but in the log file I found this message:

      ...
      got NameClassPair with name:javax.naming.Reference, name: SdomPool
      ...
      === 2010-07-23 09:44:23,487 [7-44] DEBUG BuiltinRPC - Testing DB connection for database: jdbc/SdomPool
      === 2010-07-23 09:44:24,222 [7-44] DEBUG PoolableSQLConnectionFactory - Returning unpooled Connection
      === 2010-07-23 09:44:24,318 [7-44] INFO BuiltinRPC - testDB (jdbc/SdomPool) error: com.isomorphic.tools.SQLTestException: Insufficient Priveleges

      Any ideas?

      Comment


        #4
        I changed the database user in the pool to one with more database privileges. Now it's working. Could you please tell me on which tables the method "testDB" need access?

        Comment


          #5
          Intial the DataSource looks good, but after using the admin console to set the datasource as default. It doesn't working anymore.


          === 2010-07-23 11:34:23,600 [7-23] DEBUG BuiltinRPC - Testing DB connection for database: jdbc/cti_sdom
          === 2010-07-23 11:34:23,606 [7-23] INFO PoolManager - SmartClient pooling disabled for 'jdbc/cti_sdom' objects
          === 2010-07-23 11:34:23,606 [7-23] DEBUG PoolableSQLConnectionFactory - Initializing SQL config for 'jdbc/cti_sdom' via JNDI
          === 2010-07-23 11:34:23,607 [7-23] DEBUG JNDI - No configuration for JNDI context _container_ - assuming default initialContext
          === 2010-07-23 11:34:23,607 [7-23] DEBUG JNDI - Detected container context, using new InitialContext(env) lookup method
          === 2010-07-23 11:34:23,609 [7-23] INFO BuiltinRPC - testDB (jdbc/cti_sdom) error: java.sql.SQLException: java.lang.NullPointerException


          If I use the JNDI Datasource directly in the smartgwt datasource definition (dbName) without using the admin console it's working. Is there a way to
          change the default datasource without the admin console?

          Comment


            #6
            To test a connection with Oracle we use "select 1 from dual". This is settable in server.properties as sql.oracle.pingTest.

            As far as trying to use the Admin Console, the dbName to set is just "SdomPool" based on those other logs.

            Comment

            Working...
            X