带有Java 9的Oracle JDBC驱动程序java.lang.NoClassDefFoundError:无法初始化类oracle.jdbc.OracleDriver

时间:2018-06-06 18:34:16

标签: java oracle jdbc java-9

我试图让Java应用程序使用Java 9+。当在1.9 jre中运行时,我得到以下堆栈跟踪:

2018-06-06 11:22:54.304 ERROR - main - Replicator - (stderr) java.lang.NoClassDefFoundError: Could not initialize class oracle.jdbc.OracleDriver
2018-06-06 11:22:54.305 ERROR - main - Replicator - (stderr) 

2018-06-06 11:22:54.306 ERROR - main - Replicator - (stderr)    at java.base/java.lang.Class.forName0(Native Method)
2018-06-06 11:22:54.306 ERROR - main - Replicator - (stderr) 

2018-06-06 11:22:54.306 ERROR - main - Replicator - (stderr)    at java.base/java.lang.Class.forName(Unknown Source)
2018-06-06 11:22:54.306 ERROR - main - Replicator - (stderr) 

2018-06-06 11:22:54.306 ERROR - main - Replicator - (stderr)    at java.sql/java.sql.DriverManager.isDriverAllowed(Unknown Source)
2018-06-06 11:22:54.306 ERROR - main - Replicator - (stderr) 

2018-06-06 11:22:54.306 ERROR - main - Replicator - (stderr)    at java.sql/java.sql.DriverManager.isDriverAllowed(Unknown Source)
2018-06-06 11:22:54.306 ERROR - main - Replicator - (stderr) 

2018-06-06 11:22:54.306 ERROR - main - Replicator - (stderr)    at java.sql/java.sql.DriverManager.getDrivers(Unknown Source)
2018-06-06 11:22:54.307 ERROR - main - Replicator - (stderr) 

2018-06-06 11:22:54.307 ERROR - main - Replicator - (stderr)    at java.sql/java.sql.DriverManager.getDrivers(Unknown Source)
2018-06-06 11:22:54.307 ERROR - main - Replicator - (stderr) 

2018-06-06 11:22:54.307 ERROR - main - Replicator - (stderr)    at org.apache.commons.dbcp2.BasicDataSource.<clinit>(BasicDataSource.java:77)

我已经确认类路径是准确的,因为1.这在Java 8中正常运行,并且2.在9中运行时所有其他.jars都已正确加载。有没有人在Java 9+上运行Oracle jdbc驱动程序有什么好运?

1 个答案:

答案 0 :(得分:2)

因此,一旦我为DriverManager打开跟踪日志记录,问题最终就会显示出来。 Sybase的旧jconn驱动程序与Java 9/10发生冲突,并导致DriverManager出错。既然现在已经不推荐使用该驱动程序,那就很有意义了。