Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError when using system scope

Tags:

java

maven

I am currently facing and issue when using Maven with NetBeans 7.1 - I have included a lib that I can't place into a Maven repository in the System scope. It looks something like the following:

 <dependency>
    <groupId>org.company</groupId>
    <artifactId>FBTM</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/FBTM-1.0-SNAPSHOT.jar</systemPath>
</dependency>

The IDE seems to pick up this dependency fine, as it shows in Dependencies folder (Project view) and I am able to view the jar contents. I can also import classes from the jar without any issues.

However, when I attempt to run my project (and the runtime has any of the classes in use) I get a NoClassDefFoundError for the class in question. It can be any class.

Stacktrace:

Exception in thread "main" java.lang.NoClassDefFoundError: com/company/otaupdate/sim/commands/Select at com.company.fbtranslationlibrary.mc.scripts.UserData$1.<init>(UserData.java:30) at com.company.fbtranslationlibrary.mc.scripts.UserData.<init>(UserData.java:28) at com.company.fbtranslationlibrary.mc.MS.get_profile_script(MuscadeScript.java:80) at com.company.fbtranslationlibrary.mc.MS.access$300(MS.java:16)

Any help or pointers would be greatly appreciated!

like image 696
chrisburke.io Avatar asked Nov 03 '22 21:11

chrisburke.io


1 Answers

For system scope:

Maven Doc says:

system

This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.

Your IDE provides the jar somehow. But when running you need to provide it.

Try with the default scope (that is no scope tag at all).

edit: If you want maven to keep the system scope, you need to provide the jar runtime via the classpath.

like image 148
esej Avatar answered Nov 09 '22 14:11

esej