3

I know this question has been asked a lot, but none of the solutions worked for me. I have a maven dependency to retrieve the OJDBC jar file for my project. The dependency looks like this:

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>

The jar file is being downloaded into the .m2 folder absolutely fine and it shows up in the maven dependencies of the project. I know it is retrieving it OK because if I remove it from the pom.xml it is removed from the maven dependencies. However no matter what I have done, I cannot get rid of the following error:

Missing artifact com.oracle:ojdbc6:jar:11.2.0.3

Can somebody please help. This is the same in all of my projects!!!

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
DaRoGa
  • 2,196
  • 8
  • 34
  • 62
  • Do you only have a single pom.xml? Maybe a typo somewhere? Try mvn clean package -U. – Adrian Dec 09 '13 at 07:36
  • I think you'll have to show the pom-files and some debug output from the maven command you're running. – Paaske Dec 09 '13 at 07:36
  • Hm, btw. are you really really really sure it is downloaded? Typically you have to provide this dependency manually in some way. – Adrian Dec 09 '13 at 07:38
  • I have one pom.xml for each project. There is no option for that under right click project -> maven – DaRoGa Dec 09 '13 at 07:38
  • Its not occuring when I run any particular maven command, its just always there. And yes the jar file is downloaded, it is in .m2 -> repository -> com -> oracle -> ojdbc6 ->11.2.0.3 -> ojdbc6-11.2.0.3.jar – DaRoGa Dec 09 '13 at 07:39
  • Even if the jar-file is there, it might be empty, or at least missing the actual driver. – Paaske Dec 09 '13 at 07:42
  • I have just downloaded a version of the driver manually, and refreshed everything in eclipse after placing it in the .m2 repository and that did not solve the problem – DaRoGa Dec 09 '13 at 07:45

2 Answers2

2

Due to binary licences , the Oracle driver is not present in the maven central repository. You can find some public repos that have hosted this jar to be made available for use but it is illegal as per the license.

it is obviously finding the jar file and downloading it as it is in my .m2 folder

There can be reasons why that jar is there ( or atleast you think it is )

  1. Whenever maven fails to find some jar ( due to any reason whatsoever ) , it does generate the maven2 hierarchy of folders in the .m2/ but if you look closely you will notice that its not exactly a jar , but its extension will be like "someJarName.1.1.1.jar.lastUpdated". This is not a jar, this is just a convention used by maven to keep track of what jars it needs to re-download and re-check
  2. The second possibility is that the jar must have been manually inserted into the repository ( by the mvn install:install-file command and that is the reason its there. of-course I am assuming the fact that you haven't configured any other repository besides the default mvn central

If you have the jar file in your local m2 repo ( I suggest you verify by expanding it, making sure all its package contents are in order and also the size of the jar ) then you may have to tell Eclipse to look for the jar again. To do this goto Window -> Preferences -> Maven -> User settings -> hit the re-index button and wait for a couple of minutes . And then see if this helps solve your problem

Edit

Another possible solution would be to use the system scope and specify the path of the jar on the local machine , although I highly discourage this.

Saif Asif
  • 5,516
  • 3
  • 31
  • 48
  • The size of the jar file is 2,651kb and it does not have the last updated extension on the end. It is just .jar, I have done the reindex to no effect. How do i "expand" the jar? – DaRoGa Dec 09 '13 at 08:15
  • You can expand by any zip archive reader (winzip,winrar) – Saif Asif Dec 09 '13 at 08:20
  • Ok and what do I compare this to? – DaRoGa Dec 09 '13 at 08:23
  • Compare the package contents with a jar downloaded directly from the Oracle site – Saif Asif Dec 09 '13 at 08:26
  • Having done this, the two files look exactly the same. Same classes and same sizes – DaRoGa Dec 09 '13 at 08:32
  • And i wont be able to do the system fix because it will not be running on this computer ultimately – DaRoGa Dec 09 '13 at 08:33
  • Remove the jar from .m2/ along with its parent folders ( move it to some other place) and then run `maven clean install` . I want to see what maven says in the logs – Saif Asif Dec 09 '13 at 08:36
  • Ok something I did within these instructions seems to have worked as I am no longer getting the error, even though I am not exactly sure what solved it, I was solved whilst working through your instructions so I will accept your answer. thanks – DaRoGa Dec 09 '13 at 08:37
0

Actually, it seems like the Oracle driver is not actually in the maven repository due to some binary licenses.

In short you'll have to download the jar-file manually and install it into your local maven repository.

See this answer: Find Oracle JDBC driver in Maven repository

Community
  • 1
  • 1
Paaske
  • 4,345
  • 1
  • 21
  • 33
  • It is within the companys repo and it is being downloaded from there. I would understand giving that answer if it wasnt being downloaded but it is obviously finding the jar file and downloading it as it is in my .m2 folder – DaRoGa Dec 09 '13 at 07:42
  • Ok, good to see that you solved your issue! – Paaske Dec 12 '13 at 12:25