title: JSP Pages cannot connect to MySQL Datasource via JBoss
body: <p>I am using Eclipse to create a simple project using JSP pages that pulls data from a MySQL database through a JBoss 6 AS.  It would appear I have the MySQL database properly bound to JBoss because it starts up without an errors and even displays the following message.</p>
  
  <pre><code>17:09:43,782 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/MyDatabase]
  </code></pre>
  
  <p>However when I try to launch my index.jsp page I get the following error:</p>
  
  <pre><code>exception 
  
  
  javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get 
  connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for 
  jdbc/MyDatabase"
  
  
  org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
  org.apache.jsp.index_jsp._jspService(index_jsp.java:112)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
  
  
  root cause 
  
  javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid:   "java.sql.SQLException: No suitable driver found for jdbc/MyDatabase"
    org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:318)
  org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:201)
  org.apache.jsp.index_jsp._jspx_meth_sql_005fquery_005f0(index_jsp.java:133)
  org.apache.jsp.index_jsp._jspService(index_jsp.java:64)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
  </code></pre>
  
  <p>I cannot seem to figure out why the last step of this whole thing, to allow my JSP page to be able to read from the DB is not working.</p>
  
  <p>Files for reference:</p>
  
  <p><strong>JBoss Standalone.xml</strong></p>
  
  <pre><code>    &lt;subsystem xmlns="urn:jboss:domain:datasources:1.1"&gt;
          &lt;datasources&gt;
              &lt;datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true"&gt;
                  &lt;connection-url&gt;jdbc:h2:mem:test;DB_CLOSE_DELAY=-1&lt;/connection-url&gt;
                  &lt;driver&gt;h2&lt;/driver&gt;
                  &lt;security&gt;
                      &lt;user-name&gt;sa&lt;/user-name&gt;
                      &lt;password&gt;sa&lt;/password&gt;
                  &lt;/security&gt;
              &lt;/datasource&gt;
              &lt;datasource jta="true" jndi-name="java:jboss/datasources/MyDatabase" pool-name="MyDatabase" enabled="true" use-java-context="true"&gt;
                  &lt;connection-url&gt;jdbc:mysql://localhost:3306/MyDatabase&lt;/connection-url&gt;
                  &lt;driver&gt;mysql&lt;/driver&gt;
                  &lt;security&gt;
                      &lt;user-name&gt;root&lt;/user-name&gt;
                      &lt;password&gt;root&lt;/password&gt;
                  &lt;/security&gt;
              &lt;/datasource&gt;
              &lt;drivers&gt;
                  &lt;driver name="h2" module="com.h2database.h2"&gt;
                      &lt;xa-datasource-class&gt;org.h2.jdbcx.JdbcDataSource&lt;/xa-datasource-class&gt;
                  &lt;/driver&gt;
                  &lt;driver name="mysql" module="com.mysql"&gt;
                      &lt;driver-class&gt;com.mysql.jdbc.Driver&lt;/driver-class&gt;
                      &lt;xa-datasource-class&gt;com.mysql.jdbc.jdbc2.optional.MysqlXADataSource&lt;/xa-datasource-class&gt;
                  &lt;/driver&gt;
              &lt;/drivers&gt;
          &lt;/datasources&gt;
  </code></pre>
  
  <p><strong>The Module.xml file located in JBOSS_HOME/modules/com/mysql/main</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;module xmlns="urn:jboss:module:1.1" name="com.mysql"&gt;
  &lt;resources&gt;
      &lt;resource-root path="mysql-connector-java-5.1.25-bin.jar"/&gt;
  &lt;/resources&gt;
  &lt;dependencies&gt;
      &lt;module name="javax.api"/&gt;
      &lt;module name="javax.transaction.api"/&gt;
      &lt;module name="javax.servlet.api" optional="true"/&gt;
  &lt;/dependencies&gt;
  &lt;/module&gt;
  </code></pre>
  
  <p>Inside of JBOSS_HOME/modules/com/mysql/main I have the mysql-connector-java-5.1.25-bin.jar</p>
  
  <p><strong>Web.xml Contents</strong></p>
  
  <pre><code> &lt;display-name&gt;TicketApp&lt;/display-name&gt;
  
   &lt;welcome-file-list&gt;
     &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
     &lt;welcome-file&gt;response.jsp&lt;/welcome-file&gt;
   &lt;/welcome-file-list&gt;
  </code></pre>
  
  <p><strong>Jboss-Web.xml Contents</strong></p>
  
  <pre><code> Blank for now
  </code></pre>
  
  <p><strong>It also appears that when I add in resource-ref tags to both the web.xml and jboss-web.xml file that everything blows up and I get the following errors from JBoss:</strong></p>
  
  <pre><code>17:18:29,519 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1)       JBAS015876: Starting deployment of "MyApp.war"
  17:18:29,994 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-11) MSC000001:        Failed to start service jboss.deployment.unit."MyApp.war".POST_MODULE: org.jboss.msc.service.StartException in service     jboss.deployment.unit."MyApp.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "MyApp.war"
  at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:123) [jboss-as-server-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
  at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]
  at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)     [rt.jar:1.7.0_21]
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)      [rt.jar:1.7.0_21]
  at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]
      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011033: Could not load javax.sql.Datasource referenced in env-entry
  at      org.jboss.as.ee.component.deployers.ResourceReferenceProcessor.getResourceRefEntries(ResourceReferenceProcessor.java:159)
  at    org.jboss.as.ee.component.deployers.ResourceReferenceProcessor.processDescriptorEntries(ResourceReferenceProcessor.java:73)
  at org.jboss.as.ee.component.deployers.AbstractDeploymentDescriptorBindingsProcessor.deploy(AbstractDeploymentDescriptorBindingsProcessor.java:100)
  at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:116) [jboss-as-server-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
  ... 5 more
     Caused by: java.lang.ClassNotFoundException: javax.sql.Datasource from [Module "deployment.TicketApp.war:main" from Service Module Loader]
  at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.3.GA-redhat-1]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.3.GA-redhat-1]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.3.GA-redhat-1]
  at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.3.GA-redhat-1]
  at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.3.GA-redhat-1]
  at org.jboss.as.ee.component.deployers.ResourceReferenceProcessor.getResourceRefEntries(ResourceReferenceProcessor.java:157)
  ... 8 more
  
     17:18:30,009 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "MyApp.war" was rolled back with failure message {"JBAS014671: Failed services" =&gt; {"jboss.deployment.unit.\"MyApp.war\".POST_MODULE" =&gt; "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"MyApp.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"MyApp.war\"
  Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011033: Could not load javax.sql.Datasource referenced in env-entry
  Caused by: java.lang.ClassNotFoundException: javax.sql.Datasource from [Module \"deployment.MyApp.war:main\" from Service Module Loader]"}}
   17:18:30,014 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment MyApp.war in 7ms
   17:18:30,019 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" =&gt; {"Operation step-2" =&gt; {"JBAS014671: Failed services" =&gt; {"jboss.deployment.unit.\"MyApp.war\".POST_MODULE" =&gt; "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"MyApp.war\".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment \"MyApp.war\"
  Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011033: Could not load javax.sql.Datasource referenced in env-entry
  Caused by: java.lang.ClassNotFoundException: javax.sql.Datasource from [Module \"deployment.MyApp.war:main\" from Service Module Loader]"}}}}
  </code></pre>