使用 java 11 部署错误编译的 EAR

EAR compiled with java 11 deployment error

使用 java11 编译 EAR 应用程序。 部署到 Wildfly 14 时 returns 出现以下错误:

Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ef' defined in class path resource [application-context.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [application-context.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

...

Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]
    at deployment.test-1.0.ear//org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:121)

使用 Java 8 编译的相同应用程序 部署没有问题 (实际上它是作为 java 8 应用程序启动的)。所以这似乎不是驱动程序本身的问题。

这是Wildfly路径中的module.xml modules/system/layers/base/com/oracle/main:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="com.oracle">
  <resources>
    <resource-root path="ojdbc6.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>

更改 EAR 应用程序以便在使用 java 11 编译时能够正确部署的最佳方法是什么?

ojdbc6 驱动程序不支持 Java 11。根据 What are the Oracle JDBC releases versus JDK versions,只有具有数据库 18.3 的 ojdbc8 驱动程序完全支持 Java 11。

升级驱动程序(可能还有数据库)或继续使用 Java 8.