[jboss-user] [Datasource Configuration] - Can't connect to MySQL in Java EE/JBoss application

Sz Krze do-not-reply at jboss.com
Sun Sep 2 21:53:17 EDT 2012


Sz Krze [https://community.jboss.org/people/krzemian] created the discussion

"Can't connect to MySQL in Java EE/JBoss application"

To view the discussion, visit: https://community.jboss.org/message/757495#757495

--------------------------------------------------------------
While deploying my app I'm getting the following errors (I've also included subjectively significant warnings):


    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 at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))
    (...)
    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 at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})
    (..)
    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}

    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)
    (...)
    Caused by: javax.resource.ResourceException: Unable to get managed connection for MP01Local
    (...)
    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 at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))
    (...)
    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 at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})
    (...)
    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}

    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 at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))
    (...)
    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 at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})
    (...)
    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}

    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)
    (...)
    Caused by: javax.resource.ResourceException: Unable to get managed connection for MP01Local
    (...)
    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 at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))
    (...)
    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 at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})
    (...)
    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader at 66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}


As for the whole console output:  http://pastebin.com/de2Br9xL http://pastebin.com/de2Br9xL


*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.*

*persistence.xml*

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
           version="2.0">
      <persistence-unit name="mp" transaction-type="JTA">
        <jta-data-source>java:/MP01Local</jta-data-source>

               <properties>
           <!--s
           <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
           -->
           <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
           <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
       </properties>
      </persistence-unit>
    </persistence>


*mysqllocal-ds.xml*

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE datasources
        PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
        "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
    <datasources>

       <local-tx-datasource>
          <jndi-name>MP01Local</jndi-name>
          <connection-url>jdbc:mysql://localhost:3306/mp</connection-url>
          <driver-class>com.mysql.jdbc.Driver</driver-class>
          <user-name>mproot</user-name>
          <password>mproot123</password>
       </local-tx-datasource>

    </datasources>


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.


*I'm using*

 - Eclipse, build 20120614-1722, 
 - JBoss AS 6, 
 - mysql-connector-java-5.0.8-bin driver. 
 - As for the MySQL, mysql --version prints out "mysql  Ver 14.14 Distrib 5.5.25a, for Win32 (X86)".

*My project build path*

 1. jre6
 2. JBoss 6.x Runtime
 3. MySQL JDBC Driver 5.0.8, including mysql-connector-java-5.0.8-bin.jar [I have created it in Data Source Explorer)

 Any clues? Thanks in advance.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/757495#757495]

Start a new discussion in Datasource Configuration at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120902/d29d1e6e/attachment.html 


More information about the jboss-user mailing list