Support Questions

Find answers, ask questions, and share your expertise

maven build question

avatar
Super Collaborator

I can successfully build the maven package but when I run the code I am getting the error shown below. Its looking for

gson-2.2.2.jar for some reason ,where as the pom file has the version 2.2.6 and the file also exists "

/root/.m2/repository/com/google/code/gson/gson/2.6.2/gson-2.6.2.jar"

the maven version and the pom.xml files are shown below:

[root@hadoop1 hive-json-master]# bin/find-json-schema  /tmp/events.1476299830387.log
Can't find /root/.m2/repository/com/google/code/gson/gson/2.2.2/gson-2.2.2.jar. Please build.
[root@hadoop1 hive-json-master]#

[root@hadoop1 hive-json-master]# more pom.xml
<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.apache.hive</groupId>
  <artifactId>hive-json</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>Hive-JSON</name>
  <url>http://hive.apache.org</url>
  <repositories>
    <repository>
      <id>data-nucleus</id>
      <name>data-nucleus</name>
      <url>http://www.datanucleus.org/downloads/maven2/</url>
    </repository>
  </repositories>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
      <dependency>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
          <version>2.6.2</version>
      </dependency>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.5.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <!-- make a jar with the source code -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.2.1</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- make a jar with the javadoc -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <show>public</show>
          <!-- only include our source, not the protobuf -->
          <sourcepath>${basedir}/src/main/java</sourcepath>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>2.0-beta-6</version>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.5.2</version>
        <configuration>
          <xmlOutput>true</xmlOutput>
          <xmlOutputDirectory>target/site</xmlOutputDirectory>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <systemProperties>
            <name>test.tmp.dir</name>
            <value>${project.build.directory}/test/tmp</value>
            <name>test.resources.dir</name>
            <value>${basedir}/src/test/resources</value>
          </systemProperties>
          <argLine>-Xms256m -Xmx512m</argLine>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>org.apache.hadoop.hive.json.JsonSchemaFinder</mainClass>
            </manifest>
          </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> <!-- this is used for inheritance merges -->
            <phase>package</phase> <!-- bind to the packaging phase -->
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <show>public</show>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>2.5.2</version>
      </plugin>
    </plugins>
  </reporting>
</project>
[root@hadoop1 hive-json-master]#

1 ACCEPTED SOLUTION

avatar
Master Mentor

Try explicitly excluding 2.2.2 version with maven exclude dependency.

View solution in original post

2 REPLIES 2

avatar
Master Mentor

Try explicitly excluding 2.2.2 version with maven exclude dependency.

avatar
Expert Contributor

If you are trying to use this:

https://github.com/hortonworks/hive-json

these two files have 2.2.2 hardcoded:

bin/shred-json:gsonVersion = "2.2.2"

bin/find-json-schema:gsonVersion = "2.2.2"

Just change them to 2.6.2 and mvn again.