title: Maven not setting classpath for dependencies properly
body: <p>OS name: "linux" version: "2.6.32-27-generic" arch: "i386" Family: "unix"</p>
  
  <p>Apache Maven 2.2.1 (r801777; 2009-08-06 12:16:01-0700)</p>
  
  <p>Java version: 1.6.0_20</p>
  
  <p>I am trying to use the mysql dependency in with maven in ubuntu. If I move the "mysql-connector-java-5.1.14.jar" file that maven downloaded into my $JAVA_HOME/jre/lib/ext/ folder, everything is fine when I run the jar.</p>
  
  <p>I think I should be able to just specify the dependency in the pom.xml file and maven should take care of setting the classpath for the dependency jars automatically. Is this incorrect?</p>
  
  <p>My pom.xml file looks like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;groupId&gt;com.ion.common&lt;/groupId&gt;
    &lt;artifactId&gt;TestPreparation&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
  
    &lt;name&gt;TestPrep&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
  
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
  
          &lt;configuration&gt;
            &lt;archive&gt;
              &lt;manifest&gt;
                &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                &lt;mainClass&gt;com.ion.common.App&lt;/mainClass&gt;
              &lt;/manifest&gt;
            &lt;/archive&gt;
          &lt;/configuration&gt;
  
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  
    &lt;dependencies&gt;
  
      &lt;!-- JUnit testing dependency --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- MySQL database driver --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;mysql&lt;/groupId&gt;
        &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
        &lt;version&gt;5.1.14&lt;/version&gt;
        &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>The command "mvn package" builds it without any problems, and I can run it, but when the application attempts to access the database, this error is presented:</p>
  
  <pre><code>java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
          at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Class.java:186)
          at com.ion.common.Functions.databases(Functions.java:107)
          at com.ion.common.App.main(App.java:31)
  </code></pre>
  
  <p>The line it is failing on is:</p>
  
  <pre><code>Class.forName("com.mysql.jdbc.Driver");
  </code></pre>
  
  <p>Can anyone tell me what I'm doing wrong or how to fix it?</p>