Oracle JDBC ojdbc6 Jar as a Maven Dependency

jdbcmavenoraclewar

I cannot seem to get Maven to bundle the ojdbc6.jar file into my project's war file. I have it working within the POM file when specifying a dependency directly for Hibernate tools. But it won't get bundled with the project's war file, and therefore my project won't run on Tomcat.

I have tried every solution I can find out there on the net, including those specified for this question here:

Find Oracle JDBC driver in Maven repository

Most recently, I did the following:

  1. Download the jar file to my machine

  2. Run the following command to install the jar into my local repository:

    mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true
    

    (I've tried all kinds of variants of that command, too.)

  3. Finally, I put the dependency into my pom file:

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>
    
  4. I run a clean build, but it fails:

    mvn -U clean package
    
    [INFO] Scanning for projects...
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building jazztwo 0.0.1
    [INFO] ------------------------------------------------------------------------
    Downloading: http://repo1.maven.org/maven2/com/oracle/ojdbc6/11.2.0.3/ojdbc6-11.2.0.3.jar
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.700s
    [INFO] Finished at: Tue Mar 27 15:06:14 PDT 2012
    [INFO] Final Memory: 3M/81M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project jazztwo: Could not resolve dependencies for project edu.berkeley:jazztwo:war:0.0.1: Could not find artifact com.oracle:ojdbc6:jar:11.2.0.3 in central (http://repo1.maven.org/maven2) -> [Help 1]
    

Why doesn't this work? I'm ready to throw expensive computer parts across the room. This has wasted so much time. (Thank you, Oracle. How much did we pay you again?)

Is it because I'm on a Mac, perhaps?

Best Answer

It is better to add new Maven repository (preferably using your own artifactory) to your project instead of installing it to your local repository.

Maven syntax:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.2.0.3</version>
</dependency>
... 
<repositories>
    <repository>
      <id>codelds</id>
      <url>https://code.lds.org/nexus/content/groups/main-repo</url>
    </repository>
  </repositories>

Grails example:

mavenRepo "https://code.lds.org/nexus/content/groups/main-repo"
build 'com.oracle:ojdbc6:11.2.0.3'
Related Topic