I have a deployable maven project where I'm trying to connect to a hive server using JDBC. This is my pom file:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc -->
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>2.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.test.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
This generates a jar file which has a manifest.mf which is like this:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: test
Class-Path: hive-jdbc-2.1.1.jar hive-common-2.1.1.jar ...
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_72
Main-Class: com.test.Main
Now, when I try to run the jar file using java -jar test.jar
, I get
java.lang.ClassNotFoundException: org.apache.hadoop.hive.jdbc.HiveDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
Why do I get this exception even though the jar file is configured properly in the classpath of the manifest file?
Thanks.