Question

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?

Était-ce utile?

La solution

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.

Autres conseils

In such cases, I normally import the JAR file into the local repository. You can use this command:

mvn install:install-file -Dfile=name-of-your-jar.jar -DgroupId=your-group-id -DartifactId=your-artifact-id -Dversion=your-version -Dpackaging=jar

So, if we take the snippet you put, the command will be:

mvn install:install-file -Dfile=commons-validator-1.4.0.jar -DgroupId=jFuzzyLogic_core -DartifactId=jFuzzyLogic_core -Dversion=2.0.7 -Dpackaging=jar

Once done, you can setup the dependance without any system path.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top