Dealing with “Could not find artifact com.oracle:ojdbc6:jar”

Introduction

Chris Georgoulis and I describe solutions to working around the following maven error:

Could not find artifact com.oracle:ojdbc6:jar:11.2.0.4.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

Below I describe 3 ways how to handle this but there are also other solutions available. Check reference at the bottom.

If you plan on using your Project as a dependency:

The simplest solution is to manually install the JAR into the local maven repository. Using the example from stackoverflow:

With the maven entry:

<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>

Run the following command in the command line:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
     -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar -DgeneratePom=true

If you plan on using your Project as a dependency & want the process automated:

Instead of installing the JAR to the repository manually, there’s actually a plugin for that – thanks Chris for the info.

Add the following entry:

<build>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-install-plugin</artifactId>
 <inherited>false</inherited>
 <executions>
 <execution>
 <id>install-external</id>
 <phase>clean</phase>
 <configuration>
 <file>${basedir}/lib/ojdbc14.jar</file>
 <repositoryLayout>default</repositoryLayout>
 <groupId>com.oracle</groupId>
 <artifactId>ojdbc14</artifactId>
 <version>10.2.0.3.0</version>
 <packaging>jar</packaging>
 <generatePom>true</generatePom>
 </configuration>
 <goals>
 <goal>install-file</goal>
 </goals>
 </execution>
 </executions>
 </plugin>
 </plugins>
 </build>

If your don’t plan on using your Project as a dependency in another project:

More