I am working on a maven project for which I am using a custom jar file and I included that in pom.xml as
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-migrations</artifactId>
<scope>system</scope>
<version>0.7.0</version>
<systemPath>${basedir}/dropwizard-migrations-0.7.0.jar</systemPath>
</dependency>
but after mvn package
and Compiling I am getting the NoClassDefFoundError
Exception in thread "main" java.lang.NoClassDefFoundError: io/dropwizard/migrations/MigrationsBundle
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at in.myGroupID.Artifact.game.myApplication.initialize(myApplication.java:48)
at io.dropwizard.Application.run(Application.java:70)
at in.myGroupID.Artifact.game.myApplication.main(myApplication.java:44)
Caused by: java.lang.ClassNotFoundException: io.dropwizard.migrations.MigrationsBundle
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 15 more
I think everything is all right in your case. But please make sure that the location of your jar is correct. I mean in ${basedir}/dropwizard-migrations-0.7.0.jar ${baseDir} means project home directory and your jar must be in your project home directory . If it is not in project home directory, put it there or change systemPath value to point actual location to the jar file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.