6

I'm attempting to add Oracle JDBC to my project as a maven dependency. I've followed multiple tutorials online which suggest various means to add a third party dependency.

I've opted for the local installation method, but like (this person) I'm experiencing issues.

I run the following command to install the jar:

mvn install:install-file -Dfile={lib/ojdbc7.jar} -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar

and it succeeds with:

[INFO] --- maven-install-plugin:2.3:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /home/<myfolder>/{lib/ojdbc7.jar} to /home/<myname>/.m2/repository/com/oracle/ojdbc7/12.1.0.1/ojdbc7-12.1.0.1.jar

I have then added the following to my pom:

 <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc7</artifactId>
            <version>12.1.0.1</version>
 </dependency>

and yet when I compile I get the following:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.307s
[INFO] Finished at: Sat May 02 20:40:07 NZST 2015
[INFO] Final Memory: 8M/56M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project xxx: Could not resolve dependencies for project com.xxx:xxx:jar:1.0-SNAPSHOT: Failure to find com.oracle:ojdbc7:jar:12.1.0.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

I've played around with the -U and -o flags to no avail. I have also tried installing the jar by first cding into the lib directory (as suggested by Raghuram on the other question) with no change.

Community
  • 1
  • 1
Sam
  • 1,564
  • 4
  • 23
  • 37
  • When you executed the install command, did the jar get copied to your local M2 repository – Saurabh Jhunjhunwala May 02 '15 at 08:27
  • pwd: `/home/xxx/.m2/repository/com/oracle/ojdbc7/12.1.0.1` ls: `_maven.repositories ojdbc7-12.1.0.1.jar.lastUpdated ojdbc7-12.1.0.1.pom` – Sam May 02 '15 at 08:35
  • 1
    2 things to look at and try: First, ensure that repository in which files is installed and one used for buidling the project are same. Errors shows that maven is going to remote repos to search file which implies it doesn't get it in local. Second: run mvn clean first [I hope you are using command line mvn], and then build the project. – Lokesh May 03 '15 at 03:51
  • 1
    For those who want to add this jar in Artifactory: in libs-release-local > Deploy > select the ojdbc.jar file (groupId=com.oracle, artifactId=ojdbc7, version=12.1.0.1), then run from your local machine `mvn clean package -U` (or a similar command). – ROMANIA_engineer Feb 25 '16 at 13:48
  • Delete your /home/xxx/.m2/repository/com/oracle/ojdbc7/12.1.0.1 folder and re-run the 'mvn install:install-file' command. Check the local disk and ensure that the jar is there before re-running your compile command. – beirtipol Mar 06 '17 at 15:59

1 Answers1

1

Solution

  1. Manually place this ojdbc7-12.1.0.1.jar file in your Local Maven/Cache Repository.
  2. Use mvn deploy goal while you are using 3rd Party Jar/Proprietary JAR Files in your Local Maven Repository.
Praveen Kumar K S
  • 3,024
  • 1
  • 24
  • 31