Failure to start - Xwiki 10.11.1 with datasource in Wildfly 14.x

Hi XWiki Team / Community,

I’m trying to deploy a Xwiki 10.11.1 instance on a fresh Wildfly 14.0.1 using a pre-configured PostgreSQL datasource on the container, but it seems I’m really missing some point. After trying all the information/configuration I could find (including some xwiki old forum entries), still not working. I’d really appreciate your help.

1) The failure: It seems my xwiki instance is not finding/binding to the datasource specified in hibernate.cfg.xml and web.xml files (and even a jboss-web.xml I’ve tried). On the first xwiki start, instead of the installation wizard, I’m getting an obviously very long stack trace about the missing xwiki reference, with the root cause:

Caused by: org.hibernate.HibernateException: Could not create a DBCP pool. There is an error in the Hibernate configuration file, please review it.
at com.xpn.xwiki.store.DBCPConnectionProvider.configure(DBCPConnectionProvider.java:232)
....
Caused by: java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:460)
at com.xpn.xwiki.store.DBCPConnectionProvider.configure(DBCPConnectionProvider.java:120)
... 110 more

2) My configs: I’ve defined the following datasource (and also the associated postgresql jdbc driver, with latest jar available) in Wildfly, and I can test it with success from container admin UI (changed the particular username/pass etc:

<datasource jndi-name="java:jboss/datasources/wikiPortalDS" pool-name="wikiPortalDS">
                <connection-url>jdbc:postgresql://dbserver:5432/wiki_portal_db</connection-url>
                <driver-class>org.postgresql.Driver</driver-class>
                <connection-property name="url">
                    jdbc:postgresql://dbserver:5432/wiki_portal_db
                </connection-property>
                <driver>postgresql</driver>
                <pool>
                    <max-pool-size>40</max-pool-size>
                </pool>
                <security>
                    <user-name>username</user-name>
                    <password>password</password>
                </security>
                <validation>
                    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
                    <background-validation>true</background-validation>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
                </validation>
            </datasource>

I’ve also set this datasource as the default binding datasource on wildfly, in server EE params.

I can see it successfully binds upon server start:

INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) WFLYJCA0001: Bound data source [java:jboss/datasources/wikiPortalDS]

So far I’ve used these configs, after many tries following infos from the war install guide and the Jboss/Wildfly internet forums:

WEB-INF/web.xml:

...
<resource-ref>
<description>wiki Portal DataSource</description>
<res-ref-name>jdbc/wikiPortalDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
...

WEB-INF/hibernate.cfg.xml (only the PostgreSQL related lines):

...
<property name="connection.datasource">jdbc/wikiPortalDataSource</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="xwiki.virtual_mode">schema</property>
<property name="jdbc.use_streams_for_binary">false</property>

<property name="hibernate.connection.charSet">UTF-8</property>
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.characterEncoding">utf8</property>

<mapping resource="xwiki.postgresql.hbm.xml"/>
<mapping resource="feeds.hbm.xml"/>
<mapping resource="activitystream.hbm.xml"/>
<mapping resource="instance.hbm.xml"/>
<mapping resource="notification-filter-preferences.hbm.xml"/>
<mapping resource="mailsender.hbm.xml"/>
...

WEB-INF/jboss-web.xml (added this file, since it’s a container specific configuration and it seems to be needed to map xwiki DS to the container-defined DS (OR NOT? :face_with_raised_eyebrow:)):

...
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/schema/jbossas
http://www.jboss.org/schema/jbossas/jboss-web_7_2.xsd">
<resource-ref>
	<res-ref-name>jdbc/wikiPortalDataSource</res-ref-name>
	<res-type>javax.sql.DataSource</res-type>
	<jndi-name>java:jboss/datasources/wikiPortalDS</jndi-name>   
</resource-ref>
</jboss-web>

3) The questions:

  • Is anything wrong with the config?
  • How can I properly map wildfly’s defined datasource to my xwiki instance? jboss-web.xml is needed in this case? Should I use any special namespaces/naming/reference etc?
  • Shouldn’t/Can’t I use the JNDI container datasource name directly on hibernate.cfg.xml? (tried that, no success)

Xwiki install guides seems not to be clear enough in datasource configs for wildfly. I would be more than welcome to help completing this info there.

Thanks in advance,
Ramon Brandao

Disclaimer: I’m not a Wildfly user nor a data source one :wink:

I’ve checked the sources and this means that the hibernate.connection.driver_class property is not defined in your hibernate.cfg.xml file.

The doc at https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/InstallationWAR/InstallationJBoss/ seems to suggest something like:

<property name="connection.datasource">java:jboss/datasources/XWikiDS</property>