I am working with Apache Spark through Maven, and I am trying to modify the source by including a 3rd party jar and trying to utilize some methods within it.
I get the following error when compiling the Spark project using
mvn -Dhadoop.version=2.2.0 -Dscala-2.11 -DskipTests clean package
not found: object edu
[ERROR] import edu.xxx.cs.aggr._
I modified ResultTask.scala
to contain an import statement. So, maven is unable to find the jar I am trying to use and link it with the project.
I have added a dependency to the pom.xml file such as this:
<dependency>
<groupId>edu.xxx.cs</groupId>
<artifactId>aggr</artifactId>
<version>0.99</version>
<scope>system</scope>
<systemPath>${basedir}/aggr.jar</systemPath>
</dependency>
The jar file I am trying to link is located in the same directory as the spark pom.xml file. I added this dependency to pom.xml. I inserted it in between 2 existing dependencies within the pom.xml file. I'm not sure whats wrong, but I would just like the jar to get linked for now, so that I can use the methods within it. I'm also not sure if I should be using anything specific for the groupId, artifactId, and version. edu.xxx.cs.aggr is the root package which contains other source files and packages. I would appreciate any help.
UPDATE
I used
mvn install:install-file -Dfile=<path-to-file> -DgroupId=edu.xxx.cs -DartifactId=aggr -Dversion=0.99 -Dpackaging=jar to install the jar to the .m2 repo. I checked the repo to see if it was installed, and it was.
I changed the dependency in pom.xml to
<dependency>
<groupId>edu.purdue.cs</groupId>
<artifactId>aggr</artifactId>
<version>0.99</version>
</dependency>
I still get the same error.
this is how I add system dependency to my maven pom.xml. with in the project root path, I have created lib directory and there I have placed my jar file.
<dependency>
<groupId>com.sshx</groupId>
<artifactId>sshx</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/sshxcute-1.0.jar</systemPath>
</dependency>
if still you face the same issue try adding the dependency manually by issuing the following command from the jar file location
mvn install:install-file -Dfile=sshxcute-1.0.jar -DgroupId=com.sshx -DartifactId=sshx -Dversion=1.0 -Dpackaging=jar
this command will add the jar to your .m2 repository as a dependency and you need to change the pom.xml dependency as follows:
<dependency>
<groupId>com.sshx</groupId>
<artifactId>sshx</artifactId>
<version>1.0</version>
</dependency>
once you are done, issue mvn clean install
command from command prompt and build your application.
However, another option is to create a local repository. See at this thread: How to include local jar files in Maven project
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With