Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Local Dependency

I have a jar included under src/libs. This is necessary because when I run my application on the intended server it will not be able to download external dependencies. I am receiving the following error when building from the command line: NoClassDefFoundError. The dependency in my pom:

<dependency>
     <groupId>jFuzzyLogic_core</groupId>
     <artifactId>jFuzzyLogic_core</artifactId>
     <scope>system</scope>
     <version>2.0.7</version>
     <systemPath>${basedir}\src\libs\jFuzzyLogic_core.jar</systemPath>
  </dependency>

I have read conflicting posts on whether or not this is correct and I can not figure out what to do.

The command line as requested:

Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/jFuzz
yLogic/FIS
        at noobbot.Main.<init>(Main.java:41)
        at noobbot.Main.main(Main.java:30)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.jFuzzyLogic.FIS
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more

Also relevant,

[WARNING] 'dependencies.dependency.systemPath' for jFuzzyLogic_core:jFuzzyLogic_
core:jar should not point at files within the project directory, ${basedir}\src\
libs\jFuzzyLogic_core.jar will be unresolvable by dependent projects @ line 24,
column 22

can anyone else suggest how to do this if this is in fact not the correct way?

like image 415
PandaBearSoup Avatar asked Apr 29 '14 05:04

PandaBearSoup


1 Answers

Try specifying your lib directory as a repository in your pom.xml :

<repository>
    <id>project_lib</id>
    <name>Repository in project's lib dir</name>
    <layout>default</layout>
    <url>file:///${project.basedir}/lib</url>
</repository>

Then in dependency I don't think you'll need to add <systemPath> for that Jar.

like image 117
gaganbm Avatar answered Oct 06 '22 00:10

gaganbm