I can´t configure my datasource by using a "*-ds.xml" deployment descriptor with the database driver installed as module. The datasource *-ds.xml file is only valid if I deploy the database driver directly as jar. I think that If you choose to install the driver as a module you will have to configure the datasource in the standalone.xml directly. I would like the solution driver module + deployment descriptor.
-
Have you imported your db driver module to your app? – eis Feb 23 '16 at 16:25
-
What do you mean by imported? I have just placed the module.xml and the jar it in the modules/org/postgresql/main folder. so far I can just get the module + standalone.xml or deplyoment descriptor+ jar deployment working. but not module+deployment descriptor – Laura Liparulo Feb 23 '16 at 16:27
2 Answers
For your module to be visible to your application, you need to import the module to your application. You need jboss-deployment-structure.xml in your WEB-INF for your application, something like this:
<?xml version="1.0"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.postgresql" services="export">
<imports>
<include path="META-INF**"/>
<include path="org**"/>
<!-- assuming package of the driver is org.something -->
</imports>
</module>
</dependencies>
</deployment>
</jboss-deployment-structure>
After that, the module and the driver should be visible for your app as well as to your *-ds.xml.
This is the way to say in *-ds.xml that you want to use a driver from a module:
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
(example using postgresql configuration, since you seem to be using that)
Edit: Tested this using following as postgresql-ds.xml:
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_1.xsd">
<datasource jndi-name="java:jboss/datasources/PostgeSQLDB " pool-name="PostgreSQLPool">
<connection-url>jdbc:postgresql://localhost:5432/example
</connection-url>
<driver>postgres</driver>
<pool>
<max-pool-size>30</max-pool-size>
</pool>
<security>
<user-name>postgresql</user-name>
<password>postgresql</password>
</security>
</datasource>
<drivers>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource
</xa-datasource-class>
</driver>
</drivers>
</datasources>
However, with Wildfly 10 it gives this:
20:17:22,895 WARN [org.jboss.as.connector] (MSC service thread 1-2) WFLYJCA0091: -ds.xml file deployments are deprecated. Support
may be removed in a future version.
20:17:23,058 WARN [org.jboss.as.connector.deployer.dsdeployer] (MSC service thread 1-1) WFLYJCA0012: <drivers/> in standalone -ds
.xml deployments aren't supported: Ignoring my-spring-app.war
I tested also on Wildfly 8.1, where the message is same. So it seems deploying a datasource configuration in -ds.xml is not supported and you need to create it in standalone.xml, referencing to module there. This forum link seems to confirm that.
What the link also says that you can define a data source using .ear/.war descriptors, which might be a better fit for your use case anyway. I created an example using a .war file and web.xml, located here, and this answer says you can do the same with .ears. Arguably it's even better than -ds.xml, since it is a standard.
-
altough the logging message says "deprecated" the solution with the datasource + driver in the *-ds.xml file only worked in wildfly 8.X. With jboss 7 it didn´t work. – Laura Liparulo Feb 25 '16 at 08:42
-
I can´t get it working wit the xa-datasource-class. I will investigate more if I have time – Laura Liparulo Feb 25 '16 at 08:43
-
@LauraLiparulo my main point was not about the deprecated message, but the next one. It says the section needed to define drivers isn't supported. But you should be able to obtain similar functionality with .ear/war descriptors. – eis Feb 25 '16 at 10:47
-
with Wildfly 10.0.0.Final I only get the WFLYJCA0091 warning with the driver in the standalone.xml and datasources in *-ds.xml . For now I won´t undertake the solution with web.xml as my datasource has a lot of configuration tags and it works with wildfly 8.2.1 and wildfly 10.0.X. For a while we should be covered here in the firm :-) @Eis Thank you – Laura Liparulo Feb 25 '16 at 11:00
-
Yes, with driver in the standalone.xml it should work as well. The thing not supported is driver in *-ds.xml. Ok, glad to be of help :) – eis Feb 25 '16 at 11:03
-
I got it working thanks to eis, by placing the jboss-deployment-descriptor in the META-INF folder of the ear archive :-)
Anyway for now I have to put the driver in the standalone.xml file directly:
<driver name="postgresql-9_2-1002_jdbc4_jar" module="org.postgresql">
<driver-class>org.postgresql.Driver</driver-class>
</driver>
With the jar deployment I could put it in the *-ds.xml file directly. I think it´s possible. I don´t give up.

- 2,849
- 26
- 27
-
See my update - it doesn't seem to be possible, unfortunately. But there is an alternative that might suite you better. – eis Feb 24 '16 at 19:22