Trying to use Maven to organize my project and I keep running into the following error. I know that this error means the file is present at compile time but for some reason it can't be found at runtime.
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
So I'm working on a project in Java that will take a user query, search Google Images and then download some of the results onto my computer. To that end I've had to use some third party libraries like JSoup, Json-Simple, and Gson.
I initially added Jsoup to my classpath manually and it worked, but then I heard about Maven and started using it instead. My issue is that when I try to run my code I get the error above.
I'm just not sure how to resolve this. I've seen a bunch of other posts about similar errors and I've tried to modify my pom.xml accordingly but
I just can't get it to work. I've tried removing the ~/.m2 file, ran mvn clean, mvn install, mvn package, mvn compile, and it all works fine. But when it comes time to run, I keep getting that error.
Here's most of my pom.xml file.
<repositories>
<repository>
<id>central</id>
<name>Maven repository</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- jsoup HTML parser library # https://jsoup.org/ -->
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
FOUND SOLUTION: So I left out some parts of the pom.xml file to make it easier to read, and because all the other parts were generated by Maven itself so I figured there couldn't be an issue with anything there. But it adds a tag called "pluginManagement" that encloses all other plugins and apparently this does not allow the Shade plugin to run.
Between ngueno's guidance and this post Maven shade plugin is not called automatically for goal "package"
I was able to figure out my issue, though I'm still not entirely sure why it is an issue. Anyways, I figured I'd update this post in case someone else with a similar problem stumbles across it. This was on Mac OS btw, in case it makes a difference. Thanks for your help everyone.
Usually NoClassDefFound errors are related to missing libraries at runtime.
Since you are running using the terminal I supose you are building your project using Maven, and running the generated JAR,
I would recommend to you to use the maven-shade-plugin and generate an uber-jar as I explained on this question.
The purpose generating a uber-jar is to carry all the needed dependencies inside of it (available on the application classpath).
Implement the plugin and try to run using the new JAR.
PS: Remember to check this section related to Executable Jars
UPDATE: Remove the <scope>provided</scope> of your jsoup dependency, to enforce Maven to package it along your app, with the provided scope you are saying that this dependency will be provided by the JDK at runtime.
The jars that you identify in your dependencies must be present in the Runtime classpath.
This is not the classpath that is available when you compile the code;
it is the classpath on the host where you run the application.
You must install these jars on the target host.
Edit: More details
You must do the following:
Identify the runtime host.
Create a directory on the runtime host into which you will install the dependent jar files.
Include every jar in the classpath.
Consider abandoning the "roll-your-own" path.
If you use Spring Boot
(I like it,
I don't work for them).
One feature of spring boot is a reinvented "Fat Jar" that will include the dependencies inside one deliverable artifact (the fat jar) and will add them to the classpath at startup.
Edit:
The Spring boot executable jar file is not a "Fat Jar",
instead it includes the dependencies in a directory in the
executable jar and adds said jars to the classpath on startup.
I've see you can add dependencies element of the plugin element in a pom.
Question: What's for? Should'nt all the lib used by a plugin be include inside it? Do it surcharge some lib used by the plugin?
<plugin>
<groupId>org.raml.plugins</groupId>
<artifactId>raml-jaxrs-maven-plugin</artifactId>
<version>1.3.4</version>
<dependencies>
<dependency>
<groupId>org.raml</groupId>
<artifactId>raml-parser-2</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
From official Maven POM Reference documentation:
dependencies: Dependencies are seen a lot within the POM, and are an element under all plugins element blocks. The dependencies have the same structure and function as under that base build. The major difference in this case is that instead of applying as dependencies of the project, they now apply as dependencies of the plugin that they are under. The power of this is to alter the dependency list of a plugin, perhaps by removing an unused runtime dependency via exclusions, or by altering the version of a required dependency.
That is, you can exclude some libraries from the plugin classpath or override certain versions, within the scope of that specific plugin.
Adding dependencies to a plugin would not alter the classpath of the application being built. The dependencies for a plugin is an entry point for further configurability, to directly change its classpath.
In most of the cases you would not need to work at that level of granularity, but indeed is quite useful in some cases and some plugin would actually need or recommend to add specific dependencies, for example plugins working on transformation or code generation (WSDL to Java, e.g.) would probably need a further dependency (you choose which one and which version) and so on.
A further official example is provided by the official Maven - Guide to configure plugins documentation:
You could configure the dependencies of the Build plugins, commonly to use a more recent dependency version.
For instance, the Maven Antrun Plugin version 1.2 uses Ant version 1.6.5, if you want to use the latest Ant version when running this plugin, you need to add <dependencies> element.
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2</version>
...
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-launcher</artifactId>
<version>1.7.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
...
</project>
Another example is provided by the official Exec Maven Plugin documentation in case you want to use its java goal to execute a Java program and you actually need to add libraries to its classpath but you don't want to alter the classpath of the application under build: this is a much cleaner and reasonable approach.
Dependency in plugin element allows you to define a specific version you will like the plugin to use.
Here is a good example on maven.apache.org
For instance, the Maven Antrun Plugin version 1.2 uses Ant version 1.6.5, if
you want to use the latest Ant version when running this plugin, you need to add <dependencies> element
While i'm trying generate some classes by Hibernate using existing db relation it generates some error:
org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
java.lang.NoClassDefFoundError: org/apache/commons/collections/MultiMap
org/apache/commons/collections/MultiMap
java.lang.ClassNotFoundException: org.apache.commons.collections.MultiMap cannot be found by org.jboss.tools.hibernate.runtime.v_5_1_5.0.1.Final-v20160331-1852-B88
org.apache.commons.collections.MultiMap cannot be found byorg.jboss.tools.hibernate.runtime.v_5_1_5.0.1.Final-v20160331-1852-B88
My maven file:
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.firebirdsql.jdbc</groupId>
<artifactId>jaybird-jdk18</artifactId>
<version>2.2.10</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
I see apache common-collections jar in Maven Dependencies and i am able to use apache's MultiMap in my code.
I had the same issue. Here is how I fixed it:
Open Edit Configuration dialog and go to Classpath tab, remove project-name (default classpath), click the button "Add Projects..." to add your project.
Then it works.
Or you can try using previous version instead of v5.1. In hibernate perspective, "your configuration" / Edit configuration, Change hibernate version to previous version like v4.3.
Just to chime in: Eclipse Mars. Hibernate 5.1.0. JDK 8. As Gordon and Kevin mentioned above, changing the version of Hibernate to 4.3 in in Edit Configuration worked for me.
I changed the hibernate version of 5.1 to 4.3 in Console Configuration file.
Set hibernate perspective
Open Hibernate configuration tab
Click right on your configuration
Select Edit configuration
Change Hibernate Version of 5.1 to 4.3
Fix for me: Mars worked with Hibernate Tools plugin v. 5.1.4. I just needed to click "update" after "search for updates"
I have wanted to learn Spring MVC and I took look at javavids - YouTube, I wanted to follow along with this series but I have multiple problems/issues
First I rebuild the Global repo in Maven Repositories
Solved
then I created Maven project but structure in videos was
but I have this instead
Solved
OK now I want to add plugins to pom.xml but getting this dialog
in videos it shows :
UPDATE
I don't get any plug-in to select from
Solved
I also have compiler compliance
when I set compiler to java 1.7 then I get
Solved
and at last when I tried to update STS 3.6.3 It freezes and shows
OK
I have proxy settings as
Update
I make changes and add dependency according to this Answer
I get this error:
Now I don't see resources which can help me to get these remaining issues resolved!
any help is highly appreciated.
First maven default compiler level is set to 1.5.
In order to set it to 1.7 either configure maven-compiler-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
or add the following properties.
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
After setting java version press Alt+F5 to update maven project.
In order to search for dependency or plugins go to Window -> Preferences -> Maven and check Download repository index update on startup
Restart STS, wait for index updates to complete.
Regarding your project structure check do have <packaging>war</packaging> in your pom.xml. By default it will be jar type.
then I created Maven project but structure in videos was
You be able to switch the perspective in the ide (eclipse). In the video that is the Java EE-Perspective.
That what you got is the Spring-Perspective, don't worry about that.
Window -> Open Perspective
OK now I want to add plugins to pom.xml but getting this dialog
Ok, what is wrong with that?
If you searching for a dependency on MVN Repository there you got all informationen to fill out the informations you see in the dialog. Otherwise you can open the pom-file and paste the dependency directly.
I also have compiler compliance
Assuming that you are using the m2e plugin in Eclipse, you'll need to specify the source and target versions as 1.7 for maven-compiler-plugin.
specify it with this:
<properties>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>
And update your project Right click on project -> maven -> update project (Alt F5)
The network seems to be ok. Are you on a privat or office network?
I would also like to recommend to get started with Spring using the Spring Tool Suite by using Spring Boot and the guides at http://spring.io/guides. You can import those guides directly into STS and start from there (assuming you have network connectivity).
I think the solution I am providing here will dam sure will work for you.
If you have downloaded Spring STS successfully then you have to follow these steps only.
After creation of project right click on project and Update Maven Project
For Integrating it with Google App Engine it is very Simple. You have to just declare the google app engine dependency in you pom.xml. I am providing you the structure of my Google App engine Spring project.
Please follow these steps
1. create appengine-wex.xml under WEB-INF Folder
2. Create logging.properties file under WEB-INF Folder
3. Insert Google App engine dependecies
Here is sample appengine-web.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xml>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>make-me</application>
<version>2</version>
<!--
Allows App Engine to send multiple requests to one instance in parallel:
-->
<threadsafe>true</threadsafe>
<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
<!--
HTTP Sessions are disabled by default. To enable HTTP sessions specify:
<sessions-enabled>true</sessions-enabled>
It's possible to reduce request latency by configuring your application to
asynchronously write HTTP session data to the datastore:
<async-session-persistence enabled="true" />
With this feature enabled, there is a very small chance your app will see
stale session data. For details, see
http://code.google.com/appengine/docs/java/config/appconfig.html#Enabling_Sessions
-->
</appengine-web-app>
Pom dependency
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.1</version>
</dependency>
<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>1.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>1.9.1</version>
<scope>test</scope>
</dependency>
Final Structure
I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14.
In MVNrepository site the dependency to put in the POM is:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>
of course this does't work as it is not in the central repository used by maven.
2 questions:
How do I find a repository (if any) that contains this artifact?
How do I add it so that Maven will use it?
How do I find a repository (if any) that contains this artifact?
Unfortunately due the binary license there is no public repository with the Oracle Driver JAR. This happens with many dependencies but is not Maven's fault. If you happen to find a public repository containing the JAR you can be sure that is illegal.
How do I add it so that Maven will use it?
Some JARs that can't be added due to license reasons have a pom entry in the Maven Central repo. Just check it out, it contains the vendor's preferred Maven info:
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
...and the URL to download the file which in this case is
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html.
Once you've downloaded the JAR just add it to your computer repository with (note I pulled the groupId, artifactId and version from the POM):
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
-Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar -DgeneratePom=true
The last parameter for generating a POM will save you from pom.xml warnings
If your team has a local Maven repository this guide might be helpful to upload the JAR there.
The Oracle JDBC Driver is now available in the Oracle Maven Repository (not in Central).
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
The Oracle Maven Repository requires a user registration. Instructions can be found in:
https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides
Update 2019-10-03
I noticed Spring Boot is now using the Oracle JDBC Driver from Maven Central.
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.3.0.0</version>
</dependency>
For Gradle users, use:
implementation 'com.oracle.ojdbc:ojdbc10:19.3.0.0'
There is no need for user registration.
Update 2020-03-02
Oracle is now publishing the drivers under the com.oracle.database group id. See Anthony Accioly answer for more information. Thanks Anthony.
Oracle JDBC Driver compatible with JDK6, JDK7, and JDK8
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
Oracle JDBC Driver compatible with JDK8, JDK9, and JDK11
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
Oracle JDBC Driver compatible with JDK10 and JDK11
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.3.0.0</version>
</dependency>
For whatever reason, I could not get any of the above solutions to work. (Still can't.)
What I did instead was to include the jar in my project (blech) and then create a "system" dependency for it that indicates the path to the jar. It's probably not the RIGHT way to do it, but it does work. And it eliminates the need for the other developers on the team (or the guy setting up the build server) to put the jar in their local repositories.
UPDATE: This solution works for me when I run Hibernate Tools. It does NOT appear to work for building the WAR file, however. It doesn't include the ojdbc6.jar file in the target WAR file.
1) Create a directory called "lib" in the root of your project.
2) Copy the ojdbc6.jar file there (whatever the jar is called.)
3) Create a dependency that looks something like this:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
<scope>system</scope>
<systemPath>${basedir}/lib/ojdbc6.jar</systemPath> <!-- must match file name -->
</dependency>
Ugly, but works for me.
To include the files in the war file add the following to your pom
<build>
<finalName>MyAppName</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${basedir}/src/main/java</directory>
<targetPath>WEB-INF/classes</targetPath>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.css</include>
<include>**/*.html</include>
</includes>
</resource>
<resource>
<directory>${basedir}/lib</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Download the jar and place it in your project src/lib. Now you can use the maven installer plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>install-oracle-jdbc</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>clean</phase>
<configuration>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
<createChecksum>true</createChecksum>
<file>${project.basedir}/src/lib/ojdbc6.jar</file>
</configuration>
</execution>
</executions>
</plugin>
Now you only have to execute mvn clean once and the oracle lib is installed in your local maven repository.
Oracle is now exposing a maven repository at maven.oracle.com
However you need to be authenticated.
See https://blogs.oracle.com/WebLogicServer/entry/weblogic_server_and_the_oracle
According to the comments in the blog post the ojdbc driver should be available at the following coordinates:
<groupId>com.oracle.weblogic</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.3-0-0</version>
<packaging>jar</packaging>
Try with:
<repositories>
<!-- Repository for ORACLE ojdbc6. -->
<repository>
<id>codelds</id>
<url>https://code.lds.org/nexus/content/groups/main-repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
</dependencies>
1. How do I find a repository (if any) that contains this artifact?
As DavidS has commented the line I quoted at the time I answered is no longer present in the current (at the time I'm writing now) OTN License Agreement agreement I linked. Consider this answer only for older version of the artifact, as the 10.2.0.3.0 and the like.
All Oracle Database JDBC Drivers are distribuited under the OTN License Agreement.
If you read the OTN License Agreement you find this license term:
You may not:
...
- distribute the programs unless accompanied with your applications;
...
so that's why you can't find the driver's jar in any public Maven Repository, because it would be distributed alone, and if it happened it would be a license violation.
Adding the dependency:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>
(or any later version) make Maven downloads the ojdbc14-10.2.0.3.0.pom only, and in that pom you can read:
...
<licenses>
<license>
<name>Oracle Technology Network Development and Distribution License Terms</name>
<url>http://www.oracle.com/technology/software/htdocs/distlic.html</url>
</license>
</licenses>
...
which informs you about the OTN License.
2. How do I add it so that Maven will use it?
In order to make the above dependency works I agree with victor hugo who were suggesting you here to manually install the jar into your local Maven repository (the .m2 directory) by running:
mvn install:install-file -Dfile={Path_to_your_ojdbc.jar} -DgroupId=com.oracle
-DartifactId=ojdbc -Dversion=10.2.0.3.0 -Dpackaging=jar
but I want to add that the license term above doesn't limit only where you can't find the JDBC jar, but it limits where you install it too!
In fact your local Maven repository must be private and not shared because if it was shared it would be a kind of distribution in which the jar is distributed alone, even if to a little group of people into your local area network, and this represent a OTN License Agreement violation.
Moreover I think you should avoid installing the JDBC jar in your corporation repository manager (such as Artifactory or Nexus) as a single artifact because if it was installed it would be still distributed alone, even if to people in your organization only, and this represents a OTN License Agreement violation.
You can use Nexus to manage 3rd party dependencies as well as dependencies in standard maven repositories.
As of today (27, February 2020) Oracle announced that it has published all JDBC client libraries from version 11.2.0.4 (e.g. ojdbc6) to 19.3.0 (e.g. ojdbc10) on Maven Central under the group id com.oracle.database:
Example:
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.3.0.0</version>
</dependency>
Up to now, its not possible to use maven repositories. I'm using ivy as dependency management tool, but also use maven2' s ibiblio repositories. And this is working for ivy:
<dependency org="oracle" name="ojdbc14" rev="10.2.0.2" conf="*->default"/>
Maven2' s dependency could be something like that:
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.2</version>
</dependency>
Notice that i define http://download.java.net/maven/2/ and http://mirrors.ibiblio.org/pub/mirrors/maven/mule/dependencies/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext] as external maven2 repos on my ivy settings.
The Oracle JDBC drivers are now available in Maven Central.
Here is the Link:
Oracle JDBC Drivers - Maven Central
Oracle developers article announcing the availability of the Oracle JDBC drivers in Maven Central:
Oracle announcing - Oracle JDBC drivers available in Maven Central
Example:
<!-- https://mvnrepository.com/artifact/com.oracle.jdbc/ojdbc10 -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.3.0.0</version>
</dependency>
Good news everyone! Finally we can use Oracle's official repo:
https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides
In my case it works for me after adding this below version dependency(10.2.0.4). After adding this version 10.2.0.3.0 it doesn't work due to .jar file not avail in repository path.
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4</version>
I ship opensource under LGPLv2 and even after several email conversations with Oracle they were unclear whether I was allowed to ship their binary JDBC driver with my distribution. The issue related to whether my license was compatible with their OTN terms so they suggested I was not permitted to ship the driver. Presumably related to this part
(b) to distribute the programs with applications you have developed to your customers provided that each such licensee agrees to license terms consistent with the terms of this Agreement
So even if you manage to publish the driver legally in your exclusive/local maven repository there is still the restriction on what you are permitted to do with that artifact. Seems absurd that even if I ship their driver in binary form along with the full OTN license file I still can't use it and must force my users to manually download the Oracle driver and drop into my library path before they can use my software.
There is one repo that provides the jar. In SBT add a resolver similar to this:
"oracle driver repo" at "http://dist.codehaus.org/mule/dependencies/maven2"
and a dependency:
"oracle" % "ojdbc14" % "10.2.0.2"
You can do the same with maven. pom.xml and jar are available (http://dist.codehaus.org/mule/dependencies/maven2/oracle/ojdbc14/10.2.0.2/).
If you are using Netbeans, goto Dependencies and manually install artifact. Locate your downloaded .jar file and its done. clean build will solve any issues.
Please try below:
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
This worked for me like charm. I went through multiple ways but then this helped me.
Make sure you follow each step and name the XML files exactly same.
https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides
The process is a little tedious but yes it does work.
You can find a Github simple sample project for use a Oracle JDBC Driver on Maven Project here.
You can find all explication for your continous integration + a sample and run on Travis-CI.
DEMO
pom.xml
<properties>
<oracle.driver.version>12.2.0.1</oracle.driver.version>
</properties>
<repositories>
<repository>
<id>maven.oracle.com</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>https://maven.oracle.com</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven.oracle.com</id>
<url>https://maven.oracle.com</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>${oracle.driver.version}</version>
</dependency>
</dependencies>
mvnsettings.xml
<settings>
<servers>
<server>
<id>maven.oracle.com</id>
<username>${OTN_USERNAME}</username>
<password>${OTN_PASSWORD}</password>
<configuration>
<basicAuthScope>
<host>ANY</host>
<port>ANY</port>
<realm>OAM 11g</realm>
</basicAuthScope>
<httpConfiguration>
<all>
<params>
<property>
<name>http.protocol.allow-circular-redirects</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>
</settings>
How to use on local environment
change ${OTN_USERNAME} by your Oracle login in test/mvnsettings.xml file
change ${OTN_PASSWORD} by your Oracle password in test/mvnsettings.xml file
mvn clean install --settings test/mvnsettings.xml
For dependency
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
Try
<repository>
<id>mvnrepository</id>
<url>http://nexus.saas.hand-china.com/content/repositories/rdc</url>
</repository>
SOLVED
Please do following settings to resolve the error
This repository needs to be enable for finding Oracle 10.0.3.0 dependecies (this setting needs to be done in Buildconfig.groovy
grails.project.dependency.resolver = "ivy" // or ivy
Also use following setting for compile time Oracle driver download
runtime "com.oracle:ojdbc:10.2.0.3.0"
This should solve your issue for not finding the Oracle driver for grails application