{"id":32428,"date":"2014-11-04T16:00:20","date_gmt":"2014-11-04T14:00:20","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=32428"},"modified":"2014-11-07T00:45:30","modified_gmt":"2014-11-06T22:45:30","slug":"tomcat-wildfly-configuring-database-connectivity","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html","title":{"rendered":"Tomcat to Wildfly: Configuring Database connectivity"},"content":{"rendered":"<p><em>This excerpt has been taken from the \u201c<a href=\"http:\/\/www.itbuzzpress.com\/ebooks\/from-tomcat-to-wildfly.html\">From Tomcat to WildFly<\/a>\u201d book in which you\u2019ll learn how to port your existing Tomcat architectures to WildFly, including both the server configuration and the applications running on the top of it.<\/em><\/p>\n<p><em>WildFly is a fully compliant Java Enterprise Edition 7 container with a much wider set of available services and options compared to Tomcat.<\/em><\/p>\n<p><em>The book will also give you exposure to the most common pitfalls and drawbacks, which might happen during the migration.<\/em><\/p>\n<p>&nbsp;<\/p>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#introduction\">1. Introduction<\/a><\/dt>\n<dt><a href=\"#Installing the JDBC Driver as module\">2. Installing the JDBC Driver as module<\/a><\/dt>\n<dt><a href=\"#Registering the JDBC driver on the application server\">3. Registering the JDBC driver on the application server<\/a><\/dt>\n<dt><a href=\"#Configuring a datasource which uses the JDBC driver\">4. Configuring a datasource which uses the JDBC driver<\/a><\/dt>\n<dt><a href=\"#Configuration output\">5. Configuration output<\/a><\/dt>\n<dt><a href=\"#Porting Datasource parameters to WildFly\">6. Porting Datasource parameters to WildFly<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#Minimum and Maximum pool size\">6.1. Minimum and Maximum pool size<\/a><\/dt>\n<dt><a href=\"#Dealing with Idle connections\">6.2. Dealing with Idle connections<\/a><\/dt>\n<dt><a href=\"#Setting a timeout when acquiring connections\">6.3. Setting a timeout when acquiring connections<\/a><\/dt>\n<dt><a href=\"#Handling Connection leaks\">6.4. Handling Connection leaks<\/a><\/dt>\n<dt><a href=\"#Configuring Statement Cache\">6.5. Configuring Statement Cache<\/a><\/dt>\n<\/dl>\n<\/dd>\n<\/dl>\n<\/div>\n<h1><a name=\"introduction\"><\/a>1. Introduction<\/h1>\n<table border=\"1\">\n<tbody>\n<tr>\n<td><strong>Problem<\/strong>: I have a <strong>Datasource<\/strong> configuration on Tomcat, which is used to collect database connections from a pool. I need to port my configuration on WildFly.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>On Apache Tomcat, the datasource configuration can be included in the global section of your <strong><em>server.xml<\/em><\/strong> file. Here is for example a configuration for the popular MySQL database:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n&lt;Resource name=&quot;jdbc\/mysqlds&quot; auth=&quot;Container&quot; type=&quot;javax.sql.DataSource&quot;\r\n          maxActive=&quot;100&quot; maxIdle=&quot;30&quot; maxWait=&quot;10000&quot;\r\n          username=&quot;tomcat&quot; password=&quot;tomcat&quot;\r\n          driverClassName=&quot;com.mysql.jdbc.Driver&quot;\r\n          url=&quot;jdbc:mysql:\/\/localhost:3306\/mydatabase&quot;\/&gt; <\/pre>\n<p>In addition, the following lines should be placed on the <strong><em>WEB-INF\/web.xml<\/em><\/strong> for the application-specific content.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;web-app xmlns=&quot;http:\/\/java.sun.com\/xml\/ns\/j2ee&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http:\/\/java.sun.com\/xml\/ns\/j2ee http:\/\/java.sun.com\/xml\/ns\/j2ee\/web-app_2_4.xsd&quot; version=&quot;2.4&quot;&gt;\r\n   &lt;description&gt;Tomcat DB&lt;\/description&gt;\r\n   &lt;resource-ref&gt;\r\n      &lt;description&gt;Database Connection&lt;\/description&gt;\r\n      &lt;res-ref-name&gt;jdbc\/mysqlds&lt;\/res-ref-name&gt;\r\n      &lt;res-type&gt;javax.sql.DataSource&lt;\/res-type&gt;\r\n      &lt;res-auth&gt;Container&lt;\/res-auth&gt;\r\n   &lt;\/resource-ref&gt;\r\n&lt;\/web-app&gt; <\/pre>\n<p>In order to be able to load the MySQL JDBC driver, you need to include the JAR library in the <strong><em>CATALINA_HOME\/lib<\/em><\/strong> folder:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/image001.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-32434\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/image001.png\" alt=\"image001\" width=\"651\" height=\"325\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/image001.png 651w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/image001-300x149.png 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/a><\/p>\n<p>Let\u2019s see how to configure a Datasource configuration in <strong>WildFly<\/strong>. This can be accomplished in several ways, yet all possible solutions involve the following steps:<\/p>\n<ol>\n<li>Installing the JDBC driver as module<\/li>\n<li>Registering the JDBC driver on the application server<\/li>\n<li>Configuring a datasource which uses the JDBC driver<\/li>\n<\/ol>\n<p>We will see the recommended approach, which requires using the Command Line Interface, although we will mention some alternatives available.<\/p>\n<h1><a name=\"Installing the JDBC Driver as module\"><\/a>2. Installing the JDBC Driver as module<\/h1>\n<p>WildFly is based on the assumption that every library is itself a module. So, we will turn at first the JDBC driver into a module. This can be done by creating a file path structure under the <strong><em>JBOSS_HOME\/modules<\/em><\/strong> directory. For example, in order to install a MySQL JDBC driver, create a directory structure as follows: <strong><em>JBOSS_HOME\/modules\/com\/mysql\/main<\/em><\/strong>.<\/p>\n<ol>\n<li>Copy the JDBC driver JAR into the <strong>main<\/strong> subdirectory.<\/li>\n<li>In the <strong>main<\/strong> subdirectory, create a <strong><em>module.xml<\/em><\/strong> file containing the following definitions (just adapt the JDBC driver name to your case):<\/li>\n<\/ol>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\r\n&lt;module xmlns=&quot;urn:jboss:module:1.0&quot; name=&quot;com.mysql&quot;&gt;\r\n\r\n  &lt;resources&gt;\r\n    &lt;resource-root path=&quot;mysql-connector-java-5.1.24-bin.jar&quot;\/&gt;\r\n  &lt;\/resources&gt;\r\n\r\n  &lt;dependencies&gt;\r\n    &lt;module name=&quot;javax.api&quot;\/&gt;\r\n    &lt;module name=&quot;javax.transaction.api&quot;\/&gt;\r\n  &lt;\/dependencies&gt;\r\n\r\n&lt;\/module&gt; <\/pre>\n<p>The above procedure can be completed as well using the <strong>Command Line Interface<\/strong>, with a single command, which will create the file system structure, copy the JDBC driver into the main folder and configure a <strong><em>module.xml<\/em><\/strong> based on the options provided to the CLI.<\/p>\n<p>Here is how to do it, supposing that MySQL JDBC driver is available in the <strong><em>\/home\/wildfly<\/em><\/strong> folder:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nmodule add --name=com.mysql --resources=\/home\/wildfly\/mysql-connector-java-5.1.24-bin.jar --dependencies=javax.api,javax.transaction.api <\/pre>\n<h1><a name=\"Registering the JDBC driver on the application server\"><\/a>3. Registering the JDBC driver on the application server<\/h1>\n<p>Now that your MySQL is available as module on the application server, we will register it as JDBC driver. When using the CLI, this is a one-step operation:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=datasources\/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql) <\/pre>\n<p>Now, you can check that your MySQL driver is enlisted through the available JDBC Drivers. Here is how you can achieve it:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n&#x5B;standalone@localhost:9990 \/] \/subsystem=datasources:installed-drivers-list\r\n{\r\n         . . . . . . . . . . .\r\n         &quot;driver-name&quot; =&gt; &quot;mysql&quot;,\r\n         &quot;deployment-name&quot; =&gt; undefined,\r\n         &quot;driver-module-name&quot; =&gt; &quot;com.mysql&quot;,\r\n         &quot;module-slot&quot; =&gt; &quot;main&quot;,\r\n         &quot;driver-datasource-class-name&quot; =&gt; &quot;&quot;,\r\n         &quot;driver-xa-datasource-class-name&quot; =&gt; &quot;&quot;,\r\n         &quot;driver-class-name&quot; =&gt; &quot;com.mysql.jdbc.Driver&quot;,\r\n         &quot;driver-major-version&quot; =&gt; 5,\r\n         &quot;driver-minor-version&quot; =&gt; 1,\r\n         &quot;jdbc-compliant&quot; =&gt; false        }\r\n    ]\r\n} <\/pre>\n<h1><a name=\"Configuring a datasource which uses the JDBC driver\"><\/a>4. Configuring a datasource which uses the JDBC driver<\/h1>\n<p>The last step will actually create a datasource to be used by your applications. For this purpose, we will use the CLI <strong>data-source<\/strong> shortcut command, which requires as input the Pool name, the JNDI bindings, the JDBC Connection parameters and finally the security settings (username and password):<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\ndata-source add --jndi-name=java:\/jdbc\/mysqlds --name=MySQLPool --connection-url=jdbc:mysql:\/\/localhost:3306\/mydatabase --driver-name=mysql --user-name=jboss --password=jboss  <\/pre>\n<table border=\"1\">\n<tbody>\n<tr>\n<td>Please note that the JNDI name for the Datasource must use the prefix java:\/ to be accepted as valid. Therefore the binding used in tomcat (\u201cjdbc\/mysqlds\u201d) has been changed to \u201cjava:\/ jdbc\/mysqlds\u201d.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1><a name=\"Configuration output\"><\/a>5. Configuration output<\/h1>\n<p>If you have followed the above steps, you should have the following datasource configuration available in your datasource section:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;datasources&gt;\r\n\t&lt;datasource jndi-name=&quot;java:\/jdbc\/mysqlds&quot; \r\n                   pool-name=&quot;MySQLPool&quot; enabled=&quot;true&quot;&gt;\r\n\t\t&lt;connection-url&gt;jdbc:mysql:\/\/localhost:3306\/mydatabase&lt;\/connection-url&gt;\r\n\t\t&lt;driver&gt;mysql&lt;\/driver&gt;\r\n\t\t&lt;security&gt;\r\n\t\t\t&lt;user-name&gt;jboss&lt;\/user-name&gt;\r\n\t\t\t&lt;password&gt;jboss&lt;\/password&gt;\r\n\t\t&lt;\/security&gt;\r\n\t&lt;\/datasource&gt;\r\n\t&lt;drivers&gt;\r\n\t\t&lt;driver name=&quot;mysql&quot; module=&quot;com.mysql&quot;\/&gt;\r\n\t&lt;\/drivers&gt;\r\n &lt;\/datasources&gt; <\/pre>\n<h1><a name=\"Porting Datasource parameters to WildFly\"><\/a>6. Porting Datasource parameters to WildFly<\/h1>\n<p>Configuring the datasource on the application server is the first milestone for porting your applications on WildFly. Odds are however that you are using some specific connection pool settings that need to be ported on the application server. Some of these parameters have an identical match on WildFly, some others are based on different pooling strategies; therefore you need to adapt the configuration when porting them to the application server. Let\u2019s see how to port the most common pool options to WildFly:<\/p>\n<h2><a name=\"Minimum and Maximum pool size\"><\/a>6.1. Minimum and Maximum pool size<\/h2>\n<p>Choosing the right pool size is a must for the performance of your applications.\u00a0 Tomcat minimum pool size is determined by the <strong>minIdle<\/strong> parameter and the max pool size is configured through <strong>maxActive<\/strong>. The initial size of the pool, on the other hand, is configured with the <strong>initialSize<\/strong> parameter. Here is a sample configuration:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n&lt;Resource name=&quot;jdbc\/mysqlds&quot; auth=&quot;Container&quot; type=&quot;javax.sql.DataSource&quot;\r\n          maxActive=&quot;100&quot; minIdle=&quot;30&quot; initialSize=\u201d15\u201d \r\n          username=&quot;tomcat&quot; password=&quot;tomcat&quot;\r\n          driverClassName=&quot;com.mysql.jdbc.Driver&quot;\r\n          url=&quot;jdbc:mysql:\/\/localhost:3306\/mydatabase&quot;\/&gt; <\/pre>\n<p>When porting to WildFly, the parameters are named respectively <strong>min-pool-size<\/strong> and <strong>max-pool-size<\/strong> and can be set with any management instrument. Here\u2019s how to change them for the default datasource:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=datasources\/data-source=ExampleDS\/:write-attribute(name=min-pool-size,value=30)\r\n\/subsystem=datasources\/data-source=ExampleDS\/:write-attribute(name=max-pool-size,value=100) <\/pre>\n<p>The <strong>initial pool size<\/strong>, on the other hand, can be set using:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=datasources\/data-source=ExampleDS\/:write-attribute(name=initial-pool-size,value=5) <\/pre>\n<p>Additionally note that WildFly has also an attribute named <strong>pool-prefill<\/strong>, which determines whether to attempt to prefill the connection pool to the minimum number of connections:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=datasources\/data-source=ExampleDS\/:write-attribute(name=pool-prefill,value=true) <\/pre>\n<h2><a name=\"Dealing with Idle connections\"><\/a>6.2. Dealing with Idle connections<\/h2>\n<p>Connections that have been created but haven\u2019t been used by your applications are classified as idle connections. WildFly and Tomcat have a different way to deal with idle connections. More in detail, Tomcat uses both a <strong>minIdle<\/strong> and <strong>maxIdle<\/strong> parameter to determine respectively the minimum and maximum of idle connections that should be kept in the pool. We have already discussed about the minIdle parameter, which can be turned to be WildFly <strong>min-pool-size<\/strong>. On the other hand, the maxIdle parameter has not corresponding match on WildFly. The closest match is the <strong>i<\/strong><strong>dle-timeout-minutes<\/strong>, which is the number of minutes after which unused connections are closed (default 15 minutes). You can actually vary this parameter let\u2019s say to 10 minutes as follows:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=datasources\/data-source=ExampleDS\/:write-attribute(name=idle-timeout-minutes,value=10) <\/pre>\n<h2><a name=\"Setting a timeout when acquiring connections\"><\/a>6.3. Setting a timeout when acquiring connections<\/h2>\n<p>If all your connections in a pool are busy, your applications will obviously have to wait for a connection to be released. As you can imagine, there is a timeout for this scenario, which is handled by the <strong>maxWait<\/strong> parameter in Tomcat. In the following example the timeout is set to 30 seconds:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n&lt;Resource name=&quot;jdbc\/mysqlds&quot; auth=&quot;Container&quot; type=&quot;javax.sql.DataSource&quot;\r\n          maxWait=&quot;30000&quot; \r\n . . . . \/&gt; <\/pre>\n<p>WildFly has a corresponding parameter named <strong>blocking-timeout-wait-millis<\/strong> ; in the following CLI command we are setting it to 1 second (1000 ms):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=datasources\/data-source=ExampleDS\/:write-attribute(name=blocking-timeout-wait-millis,value=1000) <\/pre>\n<h2><a name=\"Handling Connection leaks\"><\/a>6.4. Handling Connection leaks<\/h2>\n<p>A connection leak is called in Tomcat terms an \u201c<strong>Abandoned connection<\/strong>\u201d, which happens when you are creating a Statement, or a PreparedStatement or CallableStatement and you miss to close the connection or the statement (or more often, you don\u2019t include the Connection <em>close<\/em> in a <em>finally<\/em> block).<\/p>\n<p>You can handle abandoned connections in Tomcat by enabling the <strong>removeAbandoned<\/strong> parameter. If set to true a connection is considered abandoned and eligible for removal if it has not been used for longer than the <strong>removeAbandonedTimeout<\/strong> (default 300 seconds).<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n&lt;Resource name=&quot;jdbc\/mysqlds&quot; auth=&quot;Container&quot; type=&quot;javax.sql.DataSource&quot;\r\n          removeAbandoned =&quot;true&quot;  removeAbandonedTimeout=\u201d300\u201d\r\n          . . . . \/&gt; <\/pre>\n<p>On the WildFly side, there is no corresponding tweak for abruptly closing connections that are qualified as abandoned. On the other hand, there are some useful parameters, which can be used to detect or trace the issue.<\/p>\n<p>If you are concerned about Statements (and PreparedStatements), you can use the track-statements parameter that checks for unclosed statements when a connection is returned to the pool and result sets are closed when a statement is closed\/return to the prepared statement cache. Valid values are:<\/p>\n<ul>\n<li>false: do not track statements and results<\/li>\n<li>true: track statements and result sets and warn when they are not closed<\/li>\n<li>nowarn: track statements but do no warn about them being unclosed<\/li>\n<\/ul>\n<p>Here is how to set this parameter to use NOWARN:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=datasources\/data-source=ExampleDS\/:write-attribute(name=track-statements,value=NOWARN) <\/pre>\n<p>In addition, you can enable <strong>debugging<\/strong> of the caching layer, which is handled in WildFly by the <strong>Cached Connection Managed<\/strong>, part of the Connector subsystem (JCA).<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=jca\/cached-connection-manager=cached-connection-manager\/:write-attribute(name=debug,value=true) <\/pre>\n<p>You should enable also the <strong>error<\/strong> parameter, which will let you detect any error connected with the cached connection manager:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=jca\/cached-connection-manager=cached-connection-manager\/:write-attribute(name=error,value=true) <\/pre>\n<p>Once that you have enabled logging, you will see for each connection acquired from the pool the following information:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nDEBUG &#x5B;org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (MSC service thread 1-4) {JNDI_NAME}: getConnection(null, null) &#x5B;1\/100]  <\/pre>\n<p>On the other hand, you will read the following message when connections are returning to the pool:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nDEBUG &#x5B;org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (MSC service thread 1-4) {JNDI_NAME}: returnConnection(607e334, false) &#x5B;1\/99]  <\/pre>\n<p>If you are debugging the statements emitted by your applications, you can easily find out where the connection leakage is.<\/p>\n<p>Finally, if you want some details about what is going on at JDBC level, you can log the JDBC statements by setting to true the property named spy:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=datasources\/data-source=MySQLPool\/:write-attribute(name=spy,value=true) <\/pre>\n<p>In order to debug the JDBC statements in your server logs, you need to create a logger element, which traces the jboss.jdbc.spy package. You can do it as follows:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=logging\/logger=jboss.jdbc.spy\/:add(level=TRACE) <\/pre>\n<p>Reload your server configuration and check the server logs, which are by default contained into <strong><em>JBOSS_HOME\/standalone\/log\/server.log<\/em><\/strong> (standalone mode) or <strong><em>JBOSS_HOME\/domain\/[server-name]\/log\/server.log<\/em><\/strong> (domain mode).<\/p>\n<h2><a name=\"Configuring Statement Cache\"><\/a>6.5. Configuring Statement Cache<\/h2>\n<p>A Prepared Statement is a pre-compiled object on the database whose access plan will be reused to execute further queries much quicker than normal queries. Prepared statements can be also cached by the application server itself when it&#8217;s necessary to issue the same statements across different requests. Tomcat&#8217;s jdbc-pool capabilities can manage the Prepared Statement cache using a <strong>JDBC interceptor<\/strong>, which is set as a JDBC property during pool creation. For example:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n&lt;Resource name=&quot;jdbc\/mysqlds&quot; auth=&quot;Container&quot; type=&quot;javax.sql.DataSource&quot;\r\n   jdbcInterceptors=&quot;StatementCache(prepared=true,callable=false,max=50)&quot;\r\n&lt;\/Resource&gt; <\/pre>\n<p>When running on WildFly, you can set the PreparedStatement cache size by writing the <strong>prepared-statements-cache-size<\/strong> attribute as in the following example, which sets its size to 25 statements:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/subsystem=datasources\/data-source=ExampleDS\/:write-attribute(name=prepared-statements-cache-size,value=25) <\/pre>\n<p><em><a href=\"http:\/\/www.itbuzzpress.com\/ebooks\/from-tomcat-to-wildfly.html\"><img decoding=\"async\" class=\"alignleft size-thumbnail\" style=\"margin: 10px;\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/11\/tomcat_to_wildfly.png\" alt=\"http:\/\/www.itbuzzpress.com\/\" width=\"175\" height=\"225\" \/><\/a>This excerpt has been taken from the \u201c<a href=\"http:\/\/www.itbuzzpress.com\/ebooks\/from-tomcat-to-wildfly.html\">From Tomcat to WildFly<\/a>\u201d book in which you&#8217;ll learn how to port your existing Tomcat architectures to WildFly, including both the server configuration and the applications running on the top of it. You will also get exposure to the most common pitfalls and drawbacks, which might happen during the migration.<\/em><\/p>\n<p><em>Apache Tomcat is a popular Web server and Servlet Container developed as an open-source project by the Apache Software Foundation since 1999. Today it is one of the most widely used platform for running Web applications both in simple sites and in large networks.<\/em><\/p>\n<p><em>Nevertheless, the amount of libraries available on Apache Tomcat are usually just enough for very simple architectures which require just the HTTP protocol and a limited number of services; this caused the natural tendency to increase its capabilities with new extensions or modules such as Spring, Hibernate, JDO or Struts. Although the purpose of this book is not to cast in a bad light on these architectures, we do believe that a comparative knowledge of other solutions can help you to choose the best for your projects.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This excerpt has been taken from the \u201cFrom Tomcat to WildFly\u201d book in which you\u2019ll learn how to port your existing Tomcat architectures to WildFly, including both the server configuration and the applications running on the top of it. WildFly is a fully compliant Java Enterprise Edition 7 container with a much wider set of &hellip;<\/p>\n","protected":false},"author":318,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[32,890,491],"class_list":["post-32428","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-apache-tomcat","tag-jboss-wildfly","tag-jdbc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Tomcat to Wildfly: Configuring Database connectivity - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"This excerpt has been taken from the \u201cFrom Tomcat to WildFly\u201d book in which you\u2019ll learn how to port your existing Tomcat architectures to WildFly,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tomcat to Wildfly: Configuring Database connectivity - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"This excerpt has been taken from the \u201cFrom Tomcat to WildFly\u201d book in which you\u2019ll learn how to port your existing Tomcat architectures to WildFly,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-11-04T14:00:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-06T22:45:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Francesco Marchioni\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Francesco Marchioni\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html\"},\"author\":{\"name\":\"Francesco Marchioni\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/840810b3b09bd863e49905dedf9c8377\"},\"headline\":\"Tomcat to Wildfly: Configuring Database connectivity\",\"datePublished\":\"2014-11-04T14:00:20+00:00\",\"dateModified\":\"2014-11-06T22:45:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html\"},\"wordCount\":2468,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"Apache Tomcat\",\"JBoss WildFly\",\"JDBC\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html\",\"name\":\"Tomcat to Wildfly: Configuring Database connectivity - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2014-11-04T14:00:20+00:00\",\"dateModified\":\"2014-11-06T22:45:30+00:00\",\"description\":\"This excerpt has been taken from the \u201cFrom Tomcat to WildFly\u201d book in which you\u2019ll learn how to port your existing Tomcat architectures to WildFly,\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/11\\\/tomcat-wildfly-configuring-database-connectivity.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Tomcat to Wildfly: Configuring Database connectivity\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/840810b3b09bd863e49905dedf9c8377\",\"name\":\"Francesco Marchioni\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86838ab2120add85d288e9c9c40d330b06a54bbda82b42a4bc7629212c40d8a9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86838ab2120add85d288e9c9c40d330b06a54bbda82b42a4bc7629212c40d8a9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86838ab2120add85d288e9c9c40d330b06a54bbda82b42a4bc7629212c40d8a9?s=96&d=mm&r=g\",\"caption\":\"Francesco Marchioni\"},\"sameAs\":[\"http:\\\/\\\/www.mastertheboss.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/francesco-marchioni\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Tomcat to Wildfly: Configuring Database connectivity - Java Code Geeks","description":"This excerpt has been taken from the \u201cFrom Tomcat to WildFly\u201d book in which you\u2019ll learn how to port your existing Tomcat architectures to WildFly,","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html","og_locale":"en_US","og_type":"article","og_title":"Tomcat to Wildfly: Configuring Database connectivity - Java Code Geeks","og_description":"This excerpt has been taken from the \u201cFrom Tomcat to WildFly\u201d book in which you\u2019ll learn how to port your existing Tomcat architectures to WildFly,","og_url":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-11-04T14:00:20+00:00","article_modified_time":"2014-11-06T22:45:30+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Francesco Marchioni","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Francesco Marchioni","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html"},"author":{"name":"Francesco Marchioni","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/840810b3b09bd863e49905dedf9c8377"},"headline":"Tomcat to Wildfly: Configuring Database connectivity","datePublished":"2014-11-04T14:00:20+00:00","dateModified":"2014-11-06T22:45:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html"},"wordCount":2468,"commentCount":2,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["Apache Tomcat","JBoss WildFly","JDBC"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html","url":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html","name":"Tomcat to Wildfly: Configuring Database connectivity - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2014-11-04T14:00:20+00:00","dateModified":"2014-11-06T22:45:30+00:00","description":"This excerpt has been taken from the \u201cFrom Tomcat to WildFly\u201d book in which you\u2019ll learn how to port your existing Tomcat architectures to WildFly,","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2014\/11\/tomcat-wildfly-configuring-database-connectivity.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Tomcat to Wildfly: Configuring Database connectivity"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/840810b3b09bd863e49905dedf9c8377","name":"Francesco Marchioni","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/86838ab2120add85d288e9c9c40d330b06a54bbda82b42a4bc7629212c40d8a9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/86838ab2120add85d288e9c9c40d330b06a54bbda82b42a4bc7629212c40d8a9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/86838ab2120add85d288e9c9c40d330b06a54bbda82b42a4bc7629212c40d8a9?s=96&d=mm&r=g","caption":"Francesco Marchioni"},"sameAs":["http:\/\/www.mastertheboss.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/francesco-marchioni"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/32428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/318"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=32428"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/32428\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=32428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=32428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=32428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}