ExceptionInInitializer Error while Reading Data from teradata table using Spark

守給你的承諾、 提交于 2019-12-13 03:45:47

问题


I am using the below code to read data from teradata but getting error

val jdbcDF = spark.read
  .format("jdbc")
  .option("url",s"jdbc:teradata://${TeradataDBHost}/database=${TeradataDBDatabase}")
  .option("dbtable", TeradataDBDatabase+"."+TeradataDBTable)
  .option("driver","com.teradata.jdbc.TeraDriver")
  .option("user", TeradataDBUsername)
  .option("password", TeradataDBPassword)
  .load()

Error Stack Trace

Exception in thread "main" java.lang.ExceptionInInitializerError
            at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getGSSM(GenericTeraEncrypt.java:577)
            at com.teradata.jdbc.jdbc.GenericTeraEncrypt.<init>(GenericTeraEncrypt.java:116)
            at com.teradata.jdbc.jdbc.GenericTeradataConnection.<init>(GenericTeradataConnection.java:107)
            at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:186)
            at com.teradata.jdbc.jdk6.JDK6_SQL_Connection.<init>(JDK6_SQL_Connection.java:36)
            at com.teradata.jdbc.jdk6.JDK6ConnectionFactory.constructSQLConnection(JDK6ConnectionFactory.java:25)

Caused by: java.lang.NullPointerException
        at com.teradata.tdgss.jtdgss.TdgssConfigApi.GetMechanisms(Unknown Source)
        at com.teradata.tdgss.jtdgss.TdgssManager.<init>(Unknown Source)
        at com.teradata.tdgss.jtdgss.TdgssManager.<clinit>(Unknown Source)

回答1:


From the Teradata JDBC driver documentation:

If you receive one of the following exceptions:

  • NullPointerException at com.teradata.tdgss.jtdgss.TdgssConfigApi.GetMechanisms
  • IllegalArgumentException "InputStream cannot be null" at javax.xml.parsers.DocumentBuilder.parse, at com.teradata.tdgss.jtdgss.TdgssParseXml.parse

then the problem may be due to the classpath not being set, or the classpath being set incorrectly, such that tdgssconfig.jar cannot be found.

So I would guess that tdgssconfig.jar can't be found on the classpath.

Of course, it would be nice if the JDBC driver could have thrown a more helpful error message than an NPE. I am somewhat concerned that this appears to be a 'known issue' with the driver: I can't imagine it would take much effort to throw a more helpful exception in this situation. It doesn't say much for them if they have chosen to document this behaviour rather than fix it.

(Acknowledgement: found via this Teradata Community post.)



来源:https://stackoverflow.com/questions/47233040/exceptionininitializer-error-while-reading-data-from-teradata-table-using-spark

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!