title: JBOSS 7 MYSQL missing dependencies error
body: <p>There are many threads like this one already for similar errors but none which have solved my problem so after an hour of trying to debug it, I have decide to ask for help.</p>
  
  <p><strong>Background</strong></p>
  
  <p>I am setting up a Java EE project. I have create an enterprise application and have create an EJB project, JPA project and web Project and added EAR's to the enterprise project.</p>
  
  <p>I have also added <code>mysql-connector-java-5.1.0-bin</code> to the <code>JBOSS/standalone/deployments</code> folder. And added to this jar file to the JPA project.</p>
  
  <p>Any advice on how to solve the error would be greatly apprecited.</p>
  
  <p><strong>The main error is:</strong></p>
  
  <pre><code> missing/unavailable dependencies" =&gt;   
      ["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSD
  </code></pre>
  
  <p><strong>Here is my full error:</strong></p>
  
  <pre><code>Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from [Module "org.hibernate:main" from local module loader @32008dad (roots: C:\Users\Bawn92\Desktop\Programs\jboss-as-7.1.1.Final\modules)]
      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
      at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_07]
      at java.lang.Class.forName(Class.java:186) [rt.jar:1.7.0_07]
      at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)
      at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:101)
      ... 23 more
  
  01:50:40,265 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "SIMSProject.ear" was rolled back with failure message {"JBAS014671: Failed services" =&gt; {"jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\"" =&gt; "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\": Failed to start service"},"JBAS014771: Services with missing/unavailable dependencies" =&gt; ["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDBMissing[jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDB]"]}
  01:50:40,296 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment SIMSWebProject.war in 31ms
  01:50:40,296 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment SIMSEJB.jar in 31ms
  01:50:40,309 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment SIMSProject.ear in 44ms
  01:50:40,312 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
  JBAS014777:   Services which failed to start:      service jboss.persistenceunit."SIMSProject.ear#SIMSJPA": org.jboss.msc.service.StartException in service jboss.persistenceunit."SIMSProject.ear#SIMSJPA": Failed to start service
  
  01:50:40,316 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.persistenceunit.\"SIMSProject.ear#SIMSJPA\"" =&gt; "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\": Failed to start service"},"JBAS014771: Services with missing/unavailable dependencies" =&gt; ["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDBMissing[jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDB]"]}}}
  </code></pre>
  
  <p><strong>MY -ds.xml is:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;datasources xmlns="http://www.jboss.org/ironjacamar/schema"&gt;
  &lt;datasource jndi-name="java:jboss/datasources/SIMSDB" enabled="true" 
   use-java-context="true" pool-name="SIMSDB"&gt;
   &lt;connection-url&gt;jdbc:mysql://localhost:3306/mydb&lt;/connection-url&gt;
  &lt;driver&gt;mysql-connector-java-5.1.0-bin.jar&lt;/driver&gt;
  &lt;pool&gt;&lt;/pool&gt;
  &lt;security&gt;
  &lt;user-name&gt;root&lt;/user-name&gt;
  &lt;password&gt;nbuser&lt;/password&gt;
  &lt;/security&gt;
  &lt;/datasource&gt;
  &lt;/datasources&gt;
  </code></pre>
  
  <p><strong>My persistence.xml file is:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.0"
     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"&gt;
     &lt;persistence-unit name="primary"&gt;
  
        &lt;jta-data-source&gt;java:jboss/datasources/SIMSDB&lt;/jta-data-source&gt;
        &lt;properties&gt;
  
           &lt;property name="hibernate.show_sql" value="false" /&gt;
        &lt;/properties&gt;
     &lt;/persistence-unit&gt;
      &lt;persistence-unit name="SIMSJPA"&gt;
          &lt;class&gt;model.Class&lt;/class&gt;
          &lt;class&gt;model.Subject&lt;/class&gt;
          &lt;class&gt;model.Teacher&lt;/class&gt;
          &lt;properties&gt;
             &lt;!--   //i put in dialect line  --&gt;
              &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /&gt;
              &lt;property name="hibernate.connection.username" value="root"/&gt;
              &lt;property name="hibernate.connection.password" value="nbuser"/&gt;
              &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/mydb"/&gt;
              &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p><strong>The datasourse section of my Standalone file is:</strong></p>
  
  <pre><code>&lt;datasource jndi-name="java:jboss/datasources/SIMSDB" pool-name="SIMSDB"&gt;
                  &lt;connection-url&gt;jdbc:mysql://localhost:3306/mydb&lt;/connection-url&gt;
                  &lt;driver&gt;mysql-connector-java-5.1.0-bin.jar&lt;/driver&gt;
                  &lt;transaction-isolation&gt;TRANSACTION_READ_COMMITTED&lt;/transaction-isolation&gt;
                  &lt;pool&gt;
                      &lt;min-pool-size&gt;10&lt;/min-pool-size&gt;
                      &lt;max-pool-size&gt;100&lt;/max-pool-size&gt;
                      &lt;prefill&gt;true&lt;/prefill&gt;
                  &lt;/pool&gt;
                  &lt;security&gt;
                      &lt;user-name&gt;test&lt;/user-name&gt;
                      &lt;password&gt;test&lt;/password&gt;
                  &lt;/security&gt;
                  &lt;statement&gt;
                      &lt;prepared-statement-cache-size&gt;32&lt;/prepared-statement-cache-size&gt;
                      &lt;share-prepared-statements/&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&gt;
      &lt;/drivers&gt;
  </code></pre>