6

I've developed a project in Java 8 and I've installed the ojdbc jar in maven when I developed the project using java 8. Now I'm converting the project into java 7. While doing so, I'm facing issue with ojdbc.jar dependency in pom.xml. Its showing:

Missing artifact com.oracle:ojdbc7:jar:12.1.0

at oracle dependency tag. When I try to run the mvn install for ojdbc jar, that also throws an error.

[ERROR] Failed to execute goal on project SlotBookingAvailability: Could not resolve dependencies for project org.logicInfo.oms:SlotBookingAvailability:war:0.0. 1-SNAPSHOT: Failure to find com.oracle:ojdbc7:jar:12.1.0 in https://repo.maven.a pache.org/maven2 was cached in the local repository, resolution will not be reat tempted until the update interval of central has elapsed or updates are forced.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>org.logicInfo.oms</groupId>
<artifactId>SlotBookingAvailability</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>SlotBookingAvailability</name>
<description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>


<properties>
    <start-class>org.logicInfo.oms.SlotBookingAvailability.SlotBookingAvailabilityApplication</start-class>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.7</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc7</artifactId>
        <version>12.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.json/json -->
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20180813</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

</project>

Can someone help me out of this?

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
Charan
  • 143
  • 1
  • 3
  • 8

3 Answers3

10

I agree with the answer of karol Dowbecki
I give you more details for install
Download the jar from oracle's website
Add ojdbc7.jar to the local maven repository.

Open cmd window

run comand: mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0 -Dpackaging=jar -Dfile=G:/Jar/ojdbc7.jar

change the jar name location version to yours

then you will find the jar in your maven local repository ,such as ${mavenrepository}/com/oracle/ojdbc7/${yourversion}/

whdeMacBook-Pro:Downloads wh$ mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.2 -Dpackaging=jar -Dfile=ojdbc7.jar 
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.newSpark:SparkLearn >-----------------------
[INFO] Building SparkLearn 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ SparkLearn ---
[INFO] Installing /Users/wh/Downloads/ojdbc7.jar to /server/mavenrepository/com/oracle/ojdbc7/12.1.0.2/ojdbc7-12.1.0.2.jar
[INFO] Installing /var/folders/fc/23q8bt313pgbrxktr9f03ms80000gn/T/mvninstall7641723653608629745.pom to /server/mavenrepository/com/oracle/ojdbc7/12.1.0.2/ojdbc7-12.1.0.2.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.564 s
[INFO] Finished at: 2018-11-04T14:33:34+08:00
[INFO] -----------------------------------

then you can use your setting in your maven pom.xml

HbnKing
  • 1,762
  • 1
  • 11
  • 25
  • When i tried to run the above command to install the package, its throwing the below exception "[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file (default-cli) on project SlotBookingAvailability: Execution defa ult-cli of goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file failed: ar:1.6: Failed to read artifact descriptor for commons-codec:commons-codec:jar:1 .6: Could not transfer artifact org.apache.commons:commons-parent:pom:22 from/to https://repo.maven.apache.org/maven2:Received fatal alert: protocol_ version" – Charan Nov 03 '18 at 23:38
  • Came to know its because of Java 7's TLSv1.2 issue, so tried to enable TLSv1.2. That also gives an exception because of missing ojdbc.jar "[ERROR] Failed to execute goal on project SlotBookingAvailability: Could not res olve dependencies for project org.logicInfo.oms:SlotBookingAvailability:war:0.0. 1-SNAPSHOT: Failure to find com.oracle:ojdbc7:jar:12.1.0 in https://repo.maven.a pache.org/maven2 was cached in the local repository, resolution will not be reat tempted until the update interval of central has elapsed or updates are forced -" – Charan Nov 03 '18 at 23:44
  • 'Failure to find com.oracle:ojdbc7:jar:12.1.0 in repo.maven.a pache.org/maven2',your jar file may has some problem ,you haven't intalled it in your maven repository correctly – HbnKing Nov 04 '18 at 07:02
8

Oracle JDBC drviers (ojdbc6.jar, ojdbc7.jar, ojdbc8.jar) are not published into Maven Central repository due to Oracle license. If it worked before you must have installed it locally (e.g. by running mvn install:install-file) or used a repository other than Maven Central which had it.

You need to download the ojdbc7 from Oracle website manually and agree to OTN License Agreement. Ideally you would download the ojdbc7 JAR to match your Oracle Database server version (SELECT * FROM v$version).

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
  • I've downloaded the ojdbc7.jar manually from the Oracle site and added when i developed my application in java 8. Do i need to install again when i convert my application into java 7? – Charan Nov 03 '18 at 23:32
  • @Charan this will depend how will you set it up. If you install it locally with `mvn install:install-file` it will be available for all your local Maven projects. – Karol Dowbecki Nov 03 '18 at 23:39
  • Can you give the exact command to install the jar locally given my jar is place in C:\Users\pboobalan\Downloads\ojdbc? – Charan Nov 03 '18 at 23:48
0

Please download the Oracle JDBC drivers from either OTN or you can download these from Oracle Maven repository (maven.oracle.com). Refer to the blog for instructions on downloading it from Oracle Maven.

Nirmala
  • 1,278
  • 1
  • 10
  • 11
  • I did, i'm getting exception while trying to add the jar in maven using mvn install:install-file -Dfile=C:\Users\pboobalan\Downloads\ojdbc\ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0 -Dpackaging=jar – Charan Nov 04 '18 at 08:16