title: JBoss Hibernate: Could not load requested class com.mysql.jdbc.Driver
body: <p>I have an instalation of JBoss that was working with postgresql...
  I'm tring to change to mySQL.</p>
  
  <p>I've downloaded mysql-connector-java-5.1.36-bin.jar and put it into JBOSS_HOME/module/com/mysql/main, created the module.xml and changed my standalone.xml.</p>
  
  <p>But whem I try start the server i got the folloing stacktrace:</p>
  
  <pre><code>ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 48) MSC000001: Failed to start service jboss.persistenceunit."myapp.war#myapp": org.jboss.msc.service.StartException in service jboss.persistenceunit."myapp.war#myapp": javax.persistence.PersistenceException: [PersistenceUnit: myapp] Unable to build EntityManagerFactory
      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_20]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_20]
      at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_20]
      at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1]
  Caused by: javax.persistence.PersistenceException: [PersistenceUnit: myapp] Unable to build EntityManagerFactory
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)
      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57)
      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99)
      ... 4 more
  Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver com.mysql.jdbc.Driver could not be loaded
      at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:111)
      at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
      at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
      at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1825)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1783)
      at org.hibernate.ejb.EntityManagerFactoryImpl.&lt;init&gt;(EntityManagerFactoryImpl.java:96)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
      ... 9 more
  Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [com.mysql.jdbc.Driver]
      at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:151)
      at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106)
      ... 21 more
  Caused by: java.lang.ClassNotFoundException: Could not load requested class : com.mysql.jdbc.Driver
      at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:318)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [rt.jar:1.8.0_20]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [rt.jar:1.8.0_20]
      at java.lang.Class.forName0(Native Method) [rt.jar:1.8.0_20]
      at java.lang.Class.forName(Class.java:340) [rt.jar:1.8.0_20]
      at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:148)
      ... 22 more
  </code></pre>
  
  <p>Can someone help?</p>
  
  <p>My persistence.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
      http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
      version="2.1"&gt;
      &lt;persistence-unit name="myapp"&gt;
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
  
          &lt;!-- Annotated entity classes --&gt;
          &lt;class&gt;br.com.programadoremjava.ginga.test.myapp.entity.MyClassA&lt;/class&gt;
          &lt;class&gt;br.com.programadoremjava.ginga.test.myapp.entity.MyClassB&lt;/class&gt;
  
          &lt;properties&gt;
              &lt;!-- DADOS CONEXAO --&gt;
              &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /&gt;
              &lt;property name="hibernate.connection.username" value="application" /&gt;
              &lt;property name="hibernate.connection.password" value="application" /&gt;
              &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/myapp" /&gt;
  
              &lt;!-- CONFIGURACAO --&gt;
              &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /&gt;
              &lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;
              &lt;property name="hibernate.show_sql" value="true" /&gt;
              &lt;property name="hibernate.format_sql" value="true" /&gt;
          &lt;/properties&gt;
  
      &lt;/persistence-unit&gt;
  
  &lt;/persistence&gt;
  </code></pre>
  
  <p>My standalone.xml datasource configuration:</p>
  
  <pre><code>&lt;subsystem xmlns="urn:jboss:domain:datasources:1.2"&gt;
      &lt;datasources&gt;
          &lt;datasource jta="true" jndi-name="java:/myapp-ds" pool-name="test" enabled="true" use-java-context="true" use-ccm="true"&gt;
              &lt;connection-url&gt;jdbc:mysql://localhost:3306/myapp&lt;/connection-url&gt;
              &lt;driver&gt;com.mysql&lt;/driver&gt;
              &lt;transaction-isolation&gt;TRANSACTION_READ_COMMITTED&lt;/transaction-isolation&gt;
              &lt;pool&gt;
                  &lt;min-pool-size&gt;5&lt;/min-pool-size&gt;
                  &lt;max-pool-size&gt;30&lt;/max-pool-size&gt;
                  &lt;prefill&gt;true&lt;/prefill&gt;
                  &lt;use-strict-min&gt;false&lt;/use-strict-min&gt;
                  &lt;flush-strategy&gt;FailingConnectionOnly&lt;/flush-strategy&gt;
              &lt;/pool&gt;
              &lt;security&gt;
                  &lt;user-name&gt;application&lt;/user-name&gt;
                  &lt;password&gt;application&lt;/password&gt;
              &lt;/security&gt;
              &lt;statement&gt;
                  &lt;prepared-statement-cache-size&gt;32&lt;/prepared-statement-cache-size&gt;
              &lt;/statement&gt;
          &lt;/datasource&gt;
          &lt;drivers&gt;
              &lt;driver name="com.mysql" module="com.mysql"&gt;
                  &lt;xa-datasource-class&gt;com.mysql.jdbc.jdbc2.optional.MysqlXADataSource&lt;/xa-datasource-class&gt;
                  &lt;driver-class&gt;com.mysql.jdbc.Driver&lt;/driver-class&gt;
              &lt;/driver&gt;
          &lt;/drivers&gt;
      &lt;/datasources&gt;
  &lt;/subsystem&gt;
  </code></pre>
  
  <p>My JBOSS_HOME/module/com/mysql/main/module.xml</p>
  
  <pre><code>&lt;module xmlns="urn:jboss:module:1.0" name="com.mysql"&gt;
      &lt;resources&gt;
          &lt;resource-root path="mysql-connector-java-5.1.36-bin.jar"/&gt;
      &lt;/resources&gt;
      &lt;dependencies&gt;
          &lt;module name="javax.api"/&gt;
      &lt;/dependencies&gt;
  &lt;/module&gt;
  </code></pre>