Java.lang.NoClassDefFoundError after using maven for the first time? -
i've been creating soap server java company , switched on using bone-cp , maven import required 3rd party programs. after finished implementing bone-cp used server command
jar -cvfm soapserver.jar manifest.txt soapserver
and when transfered server , tried run got error:
exception in thread "main" java.lang.noclassdeffounderror: soapserver/soapserver (wrong name: com/test/soapserver/soapserver) @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:791) @ java.security.secureclassloader.defineclass(secureclassloader.java:142) @ java.net.urlclassloader.defineclass(urlclassloader.java:449) @ java.net.urlclassloader.access$100(urlclassloader.java:71) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:423) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:356) @ sun.launcher.launcherhelper.checkandloadmain(launcherhelper.java:482)
the think can think of causing problem maven doesn't package required jars program? if that's case need download them , add them class path?
if need of dependencies packed in executable jar configure pom like
<build> <plugins> <plugin> <artifactid>maven-jar-plugin</artifactid> <configuration> <archive> <manifest> <addclasspath>true</addclasspath> <classpathprefix>lib/</classpathprefix> <mainclass>com.something.yourmainclass</mainclass> </manifest> </archive> </configuration> </plugin> </plugins> </build>
above block add library in lib/ classpath in manifest classpath entry
and copy dependencies lib directory
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-dependency-plugin</artifactid> <version>2.1</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputdirectory>${project.build.directory}/lib</outputdirectory> <overwritereleases>false</overwritereleases> <overwritesnapshots>false</overwritesnapshots> <overwriteifnewer>true</overwriteifnewer> </configuration> </execution> </executions> </plugin>
Comments
Post a Comment