We use Wildfly 10 with a postgres datasource (postgres driver is deliverd in /modules folder) and in addition, a Redshift DB should be attached.
我们使用Wildfly 10和postgres数据源(postgres驱动程序是在/modules文件夹中交付的),此外,还应该附加一个Redshift DB。
So I followed Configure a JDBC Connection with Apache Maven :
My parent POM includes therefore:
因此,我使用Apache Maven配置了一个JDBC连接:因此,我的父POM包括:
<repositories>
...
<repository>
<id>redshift</id>
<url>http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release</url>
</repository>
</repositories>
and
和
<dependencies>
...
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42</artifactId>
<version>1.2.10.1009</version>
</dependency>
</dependencies>
If I know deploy me .war file, the following warning appears very early in the log:
如果我知道deploy me .war文件,下面的警告会在日志中很早就出现:
INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0005: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.2)
WARN [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0003: Unable to instantiate driver class "com.amazon.redshift.jdbc.Driver": java.lang.NoClassDefFoundError: com/amazon/redshift/core/jdbc42/PGJDBC42DriverImpl
So no wonder that later on, if I try to access the DB, I get
因此,以后,如果我尝试访问DB,我就会得到。
ERROR [stderr] (default task-64) java.sql.SQLException: No suitable driver found for jdbc:redshift://....
ERROR [stderr] (default task-64) at java.sql.DriverManager.getConnection(DriverManager.java:689)
ERROR [stderr] (default task-64) at java.sql.DriverManager.getConnection(DriverManager.java:208)
So what am I doing wrong? The driver is packaged in the .war, this is for sure, otherwise, there would not be a trial to instantiate it during deployment. Any help is highly appreciated!!
我做错了什么?驱动程序被打包在.war中,这是肯定的,否则,在部署期间不会有实例化它的尝试。非常感谢您的帮助!!
1 个解决方案
#1
1
Apparently the redshift-jdbc42
dependency has been packaged with "inner" JAR files, and this causes problems for class loading in some contexts. Try replacing
显然,redshift-jdbc42依赖项已经被打包为“内部”JAR文件,这在某些上下文中导致了类装入的问题。尝试更换
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42</artifactId>
<version>${amazon.redshift.version}</version>
</dependency>
with
与
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-redshift</artifactId>
<version>${amazonaws.sdk.version}</version>
</dependency>
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42-no-awssdk</artifactId>
<version>${amazon.redshift.version}</version>
</dependency>
(Source: https://forums.aws.amazon.com/thread.jspa?threadID=263573)
(来源:https://forums.aws.amazon.com/thread.jspa?threadID=263573)
#1
1
Apparently the redshift-jdbc42
dependency has been packaged with "inner" JAR files, and this causes problems for class loading in some contexts. Try replacing
显然,redshift-jdbc42依赖项已经被打包为“内部”JAR文件,这在某些上下文中导致了类装入的问题。尝试更换
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42</artifactId>
<version>${amazon.redshift.version}</version>
</dependency>
with
与
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-redshift</artifactId>
<version>${amazonaws.sdk.version}</version>
</dependency>
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42-no-awssdk</artifactId>
<version>${amazon.redshift.version}</version>
</dependency>
(Source: https://forums.aws.amazon.com/thread.jspa?threadID=263573)
(来源:https://forums.aws.amazon.com/thread.jspa?threadID=263573)