<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Can't connect to MySQL in Java EE/JBoss application
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/krzemian">Sz Krze</a> in <i>Datasource Configuration</i> - <a href="https://community.jboss.org/message/757495#757495">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>While deploying my app I'm getting the following errors (I've also included subjectively significant warnings):</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    03:36:42,113 WARN  [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))</p><p>    (...)</p><p>    Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})</p><p>    (..)</p><p>    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}</p><p>    </p><p>    03:36:42,122 WARN  [org.hibernate.cfg.SettingsFactory] Could not obtain connection to query metadata: org.jboss.util.NestedSQLException: Unable to get managed connection for MP01Local; - nested throwable: (javax.resource.ResourceException: Unable to get managed connection for MP01Local)</p><p>    (...)</p><p>    Caused by: javax.resource.ResourceException: Unable to get managed connection for MP01Local</p><p>    (...)</p><p>    Caused by: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))</p><p>    (...)</p><p>    Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})</p><p>    (...)</p><p>    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}</p><p>    </p><p>    03:36:42,143 WARN  [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))</p><p>    (...)</p><p>    Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})</p><p>    (...)</p><p>    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}</p><p>    </p><p>    03:36:42,147 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] schema export unsuccessful: org.jboss.util.NestedSQLException: Unable to get managed connection for MP01Local; - nested throwable: (javax.resource.ResourceException: Unable to get managed connection for MP01Local)</p><p>    (...)</p><p>    Caused by: javax.resource.ResourceException: Unable to get managed connection for MP01Local</p><p>    (...)</p><p>    Caused by: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))</p><p>    (...)</p><p>    Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})</p><p>    (...)</p><p>    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>As for the whole console output: <a class="jive-link-external-small" href="http://pastebin.com/de2Br9xL">http://pastebin.com/de2Br9xL</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>Basically, it seems as if my JDBC driver is not visible, but I have placed the .jar both in the server's default/lib folder and in project's build path, thus I'm clueless now.</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>persistence.xml</strong></p><p>  </p><p><span style="font-family: 'courier new', courier;">    <?xml version="1.0" encoding="UTF-8"?></span></p><p><span style="font-family: 'courier new', courier;"><span>    <persistence xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span>" xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"</span></span></p><p><span style="font-family: 'courier new', courier;"><span>           xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span> </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" target="_blank">http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd</a><span>"</span></span></p><p><span style="font-family: 'courier new', courier;">           version="2.0"></span></p><p><span style="font-family: 'courier new', courier;">      <persistence-unit name="mp" transaction-type="JTA"></span></p><p><span style="font-family: 'courier new', courier;">        <jta-data-source>java:/MP01Local</jta-data-source></span></p><p>    </p><p><span style="font-family: 'courier new', courier;">               <properties></span></p><p><span style="font-family: 'courier new', courier;">           <!--s</span></p><p><span style="font-family: 'courier new', courier;">           <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/></span></p><p><span style="font-family: 'courier new', courier;">           --></span></p><p><span style="font-family: 'courier new', courier;">           <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/></span></p><p><span style="font-family: 'courier new', courier;">           <property name="hibernate.hbm2ddl.auto" value="create-drop"/></span></p><p><span style="font-family: 'courier new', courier;">       </properties></span></p><p><span style="font-family: 'courier new', courier;">      </persistence-unit></span></p><p><span style="font-family: 'courier new', courier;">    </persistence></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>mysqllocal-ds.xml</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-family: 'courier new', courier;">    <?xml version="1.0" encoding="UTF-8"?></span></p><p><span style="font-family: 'courier new', courier;">    <!DOCTYPE datasources</span></p><p><span style="font-family: 'courier new', courier;">        PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"</span></p><p><span style="font-family: 'courier new', courier;"><span>        "</span><a class="jive-link-external-small" href="http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd" target="_blank">http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd</a><span>"></span></span></p><p><span style="font-family: 'courier new', courier;">    <datasources></span></p><p>       </p><p><span style="font-family: 'courier new', courier;">       <local-tx-datasource></span></p><p><span style="font-family: 'courier new', courier;">          <jndi-name>MP01Local</jndi-name></span></p><p><span style="font-family: 'courier new', courier;">          <connection-url>jdbc:mysql://localhost:3306/mp</connection-url></span></p><p><span style="font-family: 'courier new', courier;">          <driver-class>com.mysql.jdbc.Driver</driver-class></span></p><p><span style="font-family: 'courier new', courier;">          <user-name>mproot</user-name></span></p><p><span style="font-family: 'courier new', courier;">          <password>mproot123</password></span></p><p><span style="font-family: 'courier new', courier;">       </local-tx-datasource></span></p><p>        </p><p><span style="font-family: 'courier new', courier;">    </datasources></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I have placed the DS XML file in default/deploy path of the JBoss server and mysql-connector-java-5.0.8-bin in default/lib, as indicated in the JBoss manual.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>I'm using</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> - Eclipse, build 20120614-1722, </p><p> - JBoss AS 6, </p><p> - mysql-connector-java-5.0.8-bin driver. </p><p> - As for the MySQL, mysql --version prints out "mysql  Ver 14.14 Distrib 5.5.25a, for Win32 (X86)".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>My project build path</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> 1. jre6</p><p> 2. JBoss 6.x Runtime</p><p> 3. MySQL JDBC Driver 5.0.8, including mysql-connector-java-5.0.8-bin.jar [I have created it in Data Source Explorer)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> Any clues? Thanks in advance.</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/757495#757495">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Datasource Configuration at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>