0

I am trying to set up a JDBC using DataSource interface, DB2 database and Kerberos for authentication. I am using IBMs documentation which refers in Kerberos security with no user ID or password link here.

Code block for DataSource

DB2SimpleDataSource dataSource = new DB2SimpleDataSource();
            dataSource.setDriverType(4);
            dataSource.setServerName("server");
            dataSource.setPortNumber(portnumber);
            dataSource.setDatabaseName("database name");
            dataSource.setSslConnection(true);
            dataSource.setClientProgramName("program name");
            dataSource.setRetrieveMessagesFromServerOnGetMessage(true);
            dataSource.setSecurityMechanism(dataSource.KERBEROS_SECURITY);

I have the following error in my console:

Error message

com.ibm.db2.jcc.am.SqlException: [jcc][t4][10262][11223][4.19.49] Unexpected Throwable caught: class com.ibm.db2.jcc.am.le (in unnamed module @0x49097b5d) cannot access class sun.security.action.GetPropertyAction (in module java.base) because module java.base does not export sun.security.action to unnamed module @0x49097b5d. ERRORCODE=-4228, SQLSTATE=null
    at com.ibm.db2.jcc.am.kd.a(Unknown Source)
    at com.ibm.db2.jcc.am.kd.a(Unknown Source)
    at com.ibm.db2.jcc.am.kd.a(Unknown Source)
    at com.ibm.db2.jcc.t4.b.b(Unknown Source)
    at com.ibm.db2.jcc.t4.b.a(Unknown Source)
    at com.ibm.db2.jcc.t4.b.a(Unknown Source)
    at com.ibm.db2.jcc.t4.b.a(Unknown Source)
    at com.ibm.db2.jcc.t4.b.<init>(Unknown Source)
    at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(Unknown Source)
    at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(Unknown Source)
    at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(Unknown Source)
    at test.connection.TestDbConnectionDataSource.main(TestDbConnectionDataSource.java:81)
Caused by: java.lang.IllegalAccessError: class com.ibm.db2.jcc.am.le (in unnamed module @0x49097b5d) cannot access class sun.security.action.GetPropertyAction (in module java.base) because module java.base does not export sun.security.action to unnamed module @0x49097b5d
    at com.ibm.db2.jcc.am.le.a(Unknown Source)
    at com.ibm.db2.jcc.am.le.a(Unknown Source)
    at com.ibm.db2.jcc.t4.b.a(Unknown Source)

I am not using the dataSource.setKerberosServerPrincipal("sample/[email protected]"); which refers in IBM doc. Moreover, I am using many realm which I have to replace the @SRVLSJ.SJ.IBM.COM. For this reason I am using the System.setProperty("java.security.krb5.conf", "path\krb5.conf");

The adove error I can resolve this error if I use in VM arguments this: --add-exports java.base/sun.security.action=ALL-UNNAMED. But, I am searching a way to still work without this in VM arguments.

Last details. I am using com.ibm.db2.jcc.DB2SimpleDataSource interface. The version of DB2 is 4.19.49, jdk 17.0.6, Kerberos 5.

3
  • please edit your question (do not use comments) to add exact details of your KDC (name, version), and which jvm/jdk+version you are using, and what exactly do you mean by "I am using many realm".
    – mao
    Commented Jan 15 at 11:47
  • How can I find the KDC in windows @mao?
    – bagb
    Commented Jan 15 at 12:43
  • Still unclear. Please learn how to be explicit when you edit your question Do you mean that Microsoft Active-Directory is acting as your KDC? i.e. you are not using any third party product to act as the kerberos server? Also, please clarify whose jdk you are using, is it IBM, or Oracle, or OpenJDK. details matter .
    – mao
    Commented Jan 15 at 12:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.