From version < 27.2 >
edited by Vincent Massol
on 2019/07/09
To version < 28.1 >
edited by Vincent Massol
on 2019/09/09
< >
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -122,20 +122,13 @@
122 122  {{/code}}
123 123  )))This is to avoid class loading issues for the Log4J library.
124 124  
125 -= Using a JBoss DataSource =
125 += Using a WildFly/JBoss DataSource =
126 126  
127 -JBoss links about this topic:
127 +== Tutorial for JBoss AS 7.1+ ==
128 128  
129 -* [[JBoss AS 7.1 Datasource Configuration>>https://docs.jboss.org/author/display/AS71/DataSource+configuration]]
130 -* [[DataSource configuration in AS 7>>https://community.jboss.org/wiki/DataSourceConfigurationInAS7]]
131 -* [[JBoss AS 7.1.0.Final "Thunder" released - Java EE 6 Full Profile certified!>>http://planet.jboss.org/post/jboss_as_7_1_0_final_thunder_released_java_ee_6_full_profile_certified]]
132 -* [[How do I migrate my application from AS5 or AS6 to AS7>>https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7]]
133 -* [[Excited about JBoss AS 7.1 Part I: Deployable Datasources>>https://community.jboss.org/en/tools/blog/2012/02/28/excited-about-jboss-as-71-part-i-deployable-datasources]]
134 -
135 -== Tutorial for JBoss AS 7.1 ==
136 -
137 -* Create a JBoss Module for your database driver. For example for HSQLDB, create the directory ##[ASROOT]/modules/org/hsqldb/main## and put the HSQLDB Driver JAR (e.g. ##hsqldb-2.2.9.jar##) in it and also create a ##module.xml## in it and write the following code inside:(((
138 -{{code}}
129 +* Create a JBoss Module for your database driver.
130 +** **HSQLDB**: create the directory ##[ROOT]/modules/org/hsqldb/main## and put the HSQLDB Driver JAR (e.g. ##hsqldb-2.2.9.jar##) in it and also create a ##module.xml## in it and write the following code inside:(((
131 +{{code language='xml'}}
139 139  <?xml version="1.0" encoding="UTF-8"?>
140 140  <module xmlns="urn:jboss:module:1.0" name="org.hsqldb">
141 141   <resources>
... ... @@ -147,7 +147,53 @@
147 147  </module>
148 148  {{/code}}
149 149  )))
150 -* Create a data source file named ##-ds.xml## (e.g. ##hsqldb-ds.xml##). If you're using a standalone deployment, put it in ##[ASROOT]/standalone/deployments/## (you can also put it in your ##WEB-INF/## dir). Example of content:(((
143 +** **MySQL**: create the directory ##[ROOT]/modules/com/mysql/main## and put the MySQL Driver JAR (e.g. ##mysql-connector-java-5.1.48.jar##) in it and also create a ##module.xml## in it and write the following code inside:(((
144 +{{code language='xml'}}
145 +<?xml version="1.0" encoding="UTF-8"?>
146 +
147 +<module xmlns="urn:jboss:module:1.1" name="com.mysql">
148 + <resources>
149 + <resource-root path="mysql-connector-java-5.1.48.jar"/>
150 + </resources>
151 + <dependencies>
152 + <module name="javax.api"/>
153 + <module name="javax.transaction.api"/>
154 + <module name="javax.servlet.api" optional="true"/>
155 + </dependencies>
156 +</module>
157 +{{/code}}
158 +)))
159 +* Edit the ##[ASROOT]/standalone/configuration/standalone.xml## file to add a new ##<datasource>## and a new ##<driver>## sections (adjust the properties as needed):
160 +** **MySQL**. Example:(((
161 +{{code language='xml'}}
162 +<datasources>
163 + <datasource jta="true" jndi-name="java:jboss/datasources/XWikiDS" pool-name="XWikiDS" enabled="true" use-java-context="true" use-ccm="true">
164 + <connection-url>jdbc:mysql://localhost:3306/xwiki?useSSL=false</connection-url>
165 + <driver>mysql</driver>
166 + <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
167 + <pool>
168 + <min-pool-size>10</min-pool-size>
169 + <max-pool-size>100</max-pool-size>
170 + <prefill>true</prefill>
171 + </pool>
172 + <security>
173 + <user-name>xwiki</user-name>
174 + <password>xwiki</password>
175 + </security>
176 + <statement>
177 + <prepared-statement-cache-size>32</prepared-statement-cache-size>
178 + <share-prepared-statements>true</share-prepared-statements>
179 + </statement>
180 + </datasource>
181 +...
182 +<drivers>
183 + <driver name="mysql" module="com.mysql">
184 + <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
185 + </driver>
186 +...
187 +{{/code}}
188 +)))
189 +** Note that it's also possible to create a data source file named ##-ds.xml## (e.g. ##hsqldb-ds.xml##) in ##[ASROOT]/standalone/deployments/## (you can also put it in your ##WEB-INF/## dir). Example of content for HSQLDB:(((
151 151  {{code}}
152 152  <?xml version="1.0" encoding="UTF-8"?>
153 153  <datasources xmlns="http://www.jboss.org/ironjacamar/schema">
... ... @@ -161,9 +161,29 @@
161 161   </datasource>
162 162  </datasources>
163 163  {{/code}}
203 +
204 +However it's not recommended because the deployment datasource feature should only be used in development environments, as the deployable datasources are considered as unmanaged datasource. Those are not recommended for production environments, because those can not be managed by the JBoss Management console or the management utilities like jboss-cli.sh. Hence such datasource cannot be managed like the managed dataSources which are configured inside the domain.xml or standalone*.xml files.
164 164  )))
206 +* Modify XWiki's ##WEB-INF/hibernate.cfg.xml## file to tell Hibernate to use the defined DataSource rather than a direct JDBC connection:(((
207 +{{code}}
208 +<!-- This needs to be commented out since we're not going to use XWiki's Data Source -->
209 +<!--property name="hibernate.connection.provider_class">com.xpn.xwiki.store.DBCPConnectionProvider</property-->
210 +...
211 +<!-- Tells Hibernate to use the defined data source -->
212 +<property name="connection.datasource">java:jboss/datasources/XWikiDS</property>
213 +
214 +<!-- The following can be commented out since these are not needed as they are defined in the Data source definition -->
215 +<!--
216 + <property name="hibernate.connection.url">jdbc:hsqldb:file:${environment.permanentDirectory}/database/xwiki_db;shutdown=true</property>
217 + <property name="hibernate.connection.username">sa</property>
218 + <property name="hibernate.connection.password"></property>
219 + <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
220 +-->
221 +...
222 +{{/code}}
223 +)))
165 165  
166 -== Old Tutorial ==
225 +== Tutorial for older versions ==
167 167  
168 168  * Uncomment the ##resource-ref## section in XWiki's ##web.xml## file. You should have:(((
169 169  {{code}}
... ... @@ -189,8 +189,19 @@
189 189  )))
190 190  * Modify XWiki's ##WEB-INF/hibernate.cfg.xml## file to tell Hibernate to use the defined DataSource rather than a direct JDBC connection:(((
191 191  {{code}}
251 +<!-- This needs to be commented out since we're not going to use XWiki's Data Source -->
252 +<!--property name="hibernate.connection.provider_class">com.xpn.xwiki.store.DBCPConnectionProvider</property-->
192 192  ...
254 +<!-- Tells Hibernate to use the defined data source -->
193 193  <property name="connection.datasource">java:jboss/datasources/XWikiDS</property>
256 +
257 +<!-- The following can be commented out since these are not needed as they are defined in the Data source definition -->
258 +<!--
259 + <property name="hibernate.connection.url">jdbc:hsqldb:file:${environment.permanentDirectory}/database/xwiki_db;shutdown=true</property>
260 + <property name="hibernate.connection.username">sa</property>
261 + <property name="hibernate.connection.password"></property>
262 + <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
263 +-->
194 194  ...
195 195  {{/code}}
196 196  )))

WildFly 17.x

The instructions are the same as for Wildly 14.x below.

WildFly 14.x

The instructions are the same as for Wildly 10.x below.

WildFly 10.x

The instructions are the same as for JBoss AS 7.x below.

Some documentation that can be useful:

Troubleshooting

Weld Deployment Error

WildFly does automatic implicit CDI deployment when it finds some CDI beans in JARs. We need to prevent this since XWiki doesn't use CDI and there can be some third-party deps we use that have some CDI annotations.

Note that we fixed this by providing a META-INF/jboss-all.xml file telling WildFly to not do CDI bean scanning in XWiki 8.3M2+. However we found a problem with it and removed it in XWiki 10.8RC1+. In the end, it was found that this file was needed after all and put back in XWiki 10.11.9/11.3.2/11.6RC1+...

If you're using a version of XWiki that doesn't provide this jboss-all.xml then create one in the META-INF directory inside the XWiki WAR, with the following content:






xmlns="urn:jboss:1.0">
  xmlns="urn:jboss:weld:1.0" require-bean-descriptor="true"/>

JBoss AS 7.x

Example using Standalone Deployment

  • Copy the xwiki expanded WAR directory in JBOSSHOME/standalone/deployments/xwiki.war
  • Do a touch JBOSSHOME/standalone/deployments/xwiki.war.dodeploy
  • Start JBoss standalone: run ./standalone.sh from JBOSSHOME/bin/

Troubleshooting

"More than the maximum number of request parameters" error

If you get the following error in the logs when trying to import a large XAR:

Servlet.service() for servlet action threw exception: java.lang.IllegalStateException: More than the maximum number of request parameters (GET plus POST) for a single request ([512]) were detected. Any parameters beyond this limit have been ignored. To change this limit, set the maxParameterCount attribute on the Connector.

You'll need to configure Tomcat in JBoss to support more than 512 form fields.

JBoss AS 4.0.x

  • Download and install the "JBoss Application Server". It's usually as simple as unzipping it in a directory. Let's call this directory $JBOSS_HOME
  • (optional) By default JBoss runs on port 8080. If you want to modify the port on which JBoss is running, edit $JBOSS_HOME/server//deploy/jbossweb-tomcat55.sar/server.xml. Search for 8080 and replace it with the port value you wish to use. Similarly change the port in $JBOSS_HOME/server//deploy/http-invoker.sar/META-INF/jboss-service.xml to the value you like
  • Copy and expand the XWiki WAR into a directory named xwiki.war/ (note that unlike most servlet containers JBoss wants the directory name to end with .war) in $JBOSS_HOME/server//deploy where server configuration is the JBoss configuration you're using
  • Edit $JBOSS_HOME/server//deploy/jbossweb-tomcat55.sar/server.xml to set UTF-8 encoding:
    <Connector port="8080" ... URIEncoding="UTF-8"/>
    <Connector port="8009" ... URIEncoding="UTF-8"/>

Classloading Isolation

The default JBoss behavior is that classes inside of the WEB-INF/classes and WEB-INF/lib directories of the WAR file are incorporated into the default shared class loader repository. This allows classes and resources to be shared between web applications. However this means that JARs provided by XWiki in WEB-INF/lib will get mixed with JARs provided by JBoss and if both application provide the same JAR but in a different version, class incompatibilities will occur. 

To solve this please read up on JBoss ClassLoading Configuration in order to configure JBoss not to use the unified class loader (set UseJBossWebLoader to false in META-INF/jboss-service.xml).

Alternatively you may try to remove the clashing JARs from XWiki's WEB-INF/lib hoping that the version provided by JBoss is compatible with XWiki's needs.

Log4j Error

It was reported that with XWiki 1.6 and JBoss 4.0.4, using these settings would generate an error with hibernate. Everything seems to work fine without these settings including classloading of log4j.

  • Edit $JBOSS_HOME/server//jbossweb-tomcat55.sar/META-INF/jboss-service.xml file and replace:
    name="Java2ClassLoadingCompliance">false
    name="UseJBossWebLoader">false
    with:
    name="Java2ClassLoadingCompliance">true
    name="UseJBossWebLoader">true
    This is to avoid class loading issues for the Log4J library.

Using a JBoss DataSource

Using a WildFly/JBoss DataSource

JBoss links about this topic:

Tutorial for JBoss AS 7.1

Tutorial for JBoss AS 7.1+

  • Create a JBoss Module for your database driver. For example for HSQLDB, create the directory [ASROOT]/modules/org/hsqldb/main and put the HSQLDB Driver JAR (e.g. hsqldb-2.2.9.jar) in it and also create a module.xml in it and write the following code inside:

    xmlns="urn:jboss:module:1.0" name="org.hsqldb">
     
        path="hsqldb-2.2.9.jar"/>
     
     
        name="javax.api"/>
     
  • Create a JBoss Module for your database driver.
    • HSQLDB: create the directory [ROOT]/modules/org/hsqldb/main and put the HSQLDB Driver JAR (e.g. hsqldb-2.2.9.jar) in it and also create a module.xml in it and write the following code inside:

      xmlns="urn:jboss:module:1.0" name="org.hsqldb">
       
          path="hsqldb-2.2.9.jar"/>
       
       
          name="javax.api"/>
       
    • MySQL: create the directory [ROOT]/modules/com/mysql/main and put the MySQL Driver JAR (e.g. mysql-connector-java-5.1.48.jar) in it and also create a module.xml in it and write the following code inside:


      xmlns="urn:jboss:module:1.1" name="com.mysql">
       
          path="mysql-connector-java-5.1.48.jar"/>
       
       
          name="javax.api"/>
          name="javax.transaction.api"/>
          name="javax.servlet.api" optional="true"/>
       
  • Create a data source file named -ds.xml (e.g. hsqldb-ds.xml). If you're using a standalone deployment, put it in [ASROOT]/standalone/deployments/ (you can also put it in your WEB-INF/ dir). Example of content:

    xmlns="http://www.jboss.org/ironjacamar/schema">
      jndi-name="java:jboss/datasources/XWikiDS" pool-name="XWikiDS" enabled="true" use-java-context="true">
       jdbc:hsqldb:file:[path to your hsqldb db file, e.g. /tmp/xwiki-data/database/xwiki_db];shutdown=true
       hsqldb
       
         sa
         
       
     
  • Edit the [ASROOT]/standalone/configuration/standalone.xml file to add a new and a new sections (adjust the properties as needed):
    • MySQL. Example:

        jta="true" jndi-name="java:jboss/datasources/XWikiDS" pool-name="XWikiDS" enabled="true" use-java-context="true" use-ccm="true">
         jdbc:mysql://localhost:3306/xwiki?useSSL=false
         mysql
         TRANSACTION_READ_COMMITTED
         
           10
           100
           true
         
         
           xwiki
           xwiki
         
         
           32
           true
         
       
      ...

        name="mysql" module="com.mysql">
         com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
       
      ...
    • Note that it's also possible to create a data source file named -ds.xml (e.g. hsqldb-ds.xml) in [ASROOT]/standalone/deployments/ (you can also put it in your WEB-INF/ dir). Example of content for HSQLDB:

      xmlns="http://www.jboss.org/ironjacamar/schema">
        jndi-name="java:jboss/datasources/XWikiDS" pool-name="XWikiDS" enabled="true" use-java-context="true">
         jdbc:hsqldb:file:[path to your hsqldb db file, e.g. /tmp/xwiki-data/database/xwiki_db];shutdown=true
         hsqldb
         
           sa
           
         
       

      However it's not recommended because the deployment datasource feature should only be used in development environments, as the deployable datasources are considered as unmanaged datasource. Those are not recommended for production environments, because those can not be managed by the JBoss Management console or the management utilities like jboss-cli.sh. Hence such datasource cannot be managed like the managed dataSources which are configured inside the domain.xml or standalone*.xml files.

  • Modify XWiki's WEB-INF/hibernate.cfg.xml file to tell Hibernate to use the defined DataSource rather than a direct JDBC connection:


    ...

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


    ...

Old Tutorial

Tutorial for older versions

  • Uncomment the resource-ref section in XWiki's web.xml file. You should have:

     DB Connection
     jdbc/XWikiDS
     javax.sql.DataSource
     Container
  • Create the following jboss-web.xml file in the deployed XWiki's WEB-INF/ directory:



     
           jdbc/XWikiDS
           java:jboss/datasources/XWikiDS
      
  • Modify XWiki's WEB-INF/hibernate.cfg.xml file to tell Hibernate to use the defined DataSource rather than a direct JDBC connection:
    ...
    name="connection.datasource">java:jboss/datasources/XWikiDS
    ...


    ...

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


    ...

Issues related to JBoss

TypeKeySummaryStatusCreated Date
BugXWIKI-7989Fail to import Default XE XAR in JBoss AS7Closed29-Jun-2012
BugXWIKI-7987Failed to deploy on JBoss AS7 with SLF4J class cast exceptionClosed29-Jun-2012
BugXWIKI-7986Failed to deploy on JBoss AS7 with Taglib errorsClosed27-Jun-2012
BugXWIKI-7984Jboss AS 7 does not like jythonClosed27-Jun-2012
BugXWIKI-5946Extension manager fails on JBoss AS 5Closed02-Feb-2011
BugXWIKI-3093Container managed Datasource not working (JBOSS 4.2.2, Xwiki 1.6.2)Closed11-Jan-2009
ImprovementXWIKI-1027Support deployment on Jboss 4.xClosed26-Mar-2007
ImprovementXINFRA-13Encoding configuration for JBoss usersClosed10-Apr-2012
BugXCOMMONS-208Failed to deploy on JBoss AS7 with Reflections VFS errorsClosed29-Jun-2012

Get Connected