问题
eventually somebody can help me. Currently I have a really strange problem when starting wildfly 10 Final with a postgres driver but with the same setting wildfly 10 CR4 will start up.
The exception I get is following:
Caused by: javax.resource.ResourceException: IJ031089: Failed to load datasource: org.postgresql.Driver
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getDataSource(LocalManagedConnectionFactory.java:650)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:311)
... 6 more
Caused by: java.lang.ClassCastException: org.postgresql.Driver cannot be cast to javax.sql.DataSource
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getDataSource(LocalManagedConnectionFactory.java:633)
... 7 more
The strange thing is, it works on wildfly 10 CR4 but not on the final version wildfly 10 Final. Any Idea? For me it looks like a class loader problem but I'm not that an expert with wildfly to track it down.
my modules/org/postgres/main/module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgres">
<resources>
<resource-root path="postgresql-9.4.1208.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
My driver definition in standalone.xml
<driver name="postgres" module="org.postgres">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
<datasource-class>org.postgresql.Driver</datasource-class>
</driver>
Java JDK is: jdk1.8.0_73
Would really appreciate any help to fix my problem.
Thx in advance
/david
回答1:
The class name implementing a DataSource is either:
org.postgresql.ds.PGSimpleDataSource
or
org.postgresql.ds.PGPoolingDataSource
https://jdbc.postgresql.org/documentation/head/ds-ds.html
I assume Wildfly will manage the connections, so you probably don't need the pooling DataSource, only the simple: So it should be
<driver name="postgres" module="org.postgres">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
<datasource-class>org.postgresql.ds.PGSimpleDataSource</datasource-class>
</driver>
来源:https://stackoverflow.com/questions/36232968/wildfly-10-final-postgres-driver-classcastexception