Exception in thread "main" - NoClassDefFoundError - java

After using java -jar tracker-server.jar "configuration.xml"
I got:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/netty/bootstrap/Bootstrap
at org.traccar.Main.main(Main.java:26)
Caused by: java.lang.ClassNotFoundException: org.jboss.netty.bootstrap.Bootstrap
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
... 1 more
I found only its some about third party library. But I'm not friendly with Java.

The ClassNotFoundException is caused by there soem jar file missing from the classpath. Search for the jar what includes the missing class and make it available for the enviroment.
See this thread: java.lang.NoClassDefFoundError: org.jboss.netty.bootstrap.ClientBootstrap

Related

Jar not running on Unix Server

I am running the jar on unix server and getting the following exception. It was working earlier
Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.log4j.Logger
at bo.ExecuteScheduler.<clinit>(ExecuteScheduler.java:25)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:172)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader.findClass(URLClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
... 6 more

Creating a server using QuickServer

I am following this tutorial:
https://code.google.com/p/quickserver/wiki/QuickStartTutor
but when I execute java -jar QuickServer.jar -load HelloWorld.xml
I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/pool/PoolableObjectFactory at
java.lang.Class.getDeclaredMethods0(Native Method) at
java.lang.Class.privateGetDeclaredMethods(Class.java:2531) at
java.lang.Class.getMethod0(Class.java:2774) at
java.lang.Class.getMethod(Class.java:1663) at
sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494) at
sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.pool.PoolableObjectFactory 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) ... 6 more
How can I solve that?
The exception exactly says your problem: that class cannot be found on the application classpath, hence the ClassNotFoundException.
You need to put all the dependent jars onto the application classpath. In this exact exception, the commons-pool.jar Apache library is missing.
The developers guide states, that the Digester and Pool Jakarta Commons Components are dependencies of QuickServer.
It sounds like you are executing this from a folder that does not also have the supporting jars. Ie, the following files must be in the same folder as QuickServer.jar as well:
commons-digester.jar
commons-collections.jar
commons-beanutils.jar
commons-logging.jar
commons-pool.jar

Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/util/Nested RuntimeException

When I start my jBoss5.x server I get the following exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/util/Nested
RuntimeException
at org.jboss.bootstrap.AbstractServerImpl.doInit(AbstractServerImpl.java
:190)
at org.jboss.bootstrap.AbstractServerImpl.init(AbstractServerImpl.java:1
73)
at org.jboss.bootstrap.AbstractServerImpl.init(AbstractServerImpl.java:1
43)
at org.jboss.Main.boot(Main.java:218)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.jboss.util.NestedRuntimeExcepti
on
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:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
I have set my java class path
I am fresher with jBoss so I cant understand the reason for the issue.
Any help would be highly appreciated
In my case, twiddle script throws the same exception. After some struggle I found that jbossall-client.jar was missing. I copied it under client folder and it worked as expected.

ClassNotFoundException in java?

I am trying to run example from this particular site:
https://github.com/larsgeorge/hbase-book/tree/master/ch07
Now.. it compiles succesfully
But when I try to run an example, it gives me the following exception:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:115)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:719)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370)
at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:416)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1093)
at org.apache.hadoop.mapred.Child.main(Child.java:249)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:113)
... 7 more
Caused by: java.lang.NoClassDefFoundError: org/json/simple/parser/JSONParser
at mapreduce.ParseJson2$ParseMapper.<init>(ParseJson2.java:48)
... 12 more
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.JSONParser
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 13 more
Now from the pom in this file, I can see that simple json is included but I am not sure why is it throwing this issue.?
I would say that the problem is that when run under map-reduce the jar you need is not in scope (i.e. not found). One way to fix that is to create a jar with all the dependencies and submit that as the job. Other options are to make sure it is available in each node and deploying the depdndecies to Hadoops' distribtued cache (but the first is the simplest - though it makes for slower job starts since the jar is bigger)

Adding multiple jar files into classpath

I am trying to add all the jar files in the directory below but I get
Exception in thread "main" java.lang.NoClassDefFoundError: twitter4j/TwitterException error.
I am sure there is TwitterException class inside the .jar file. Is there any error in my classpath syntax ?
mahmut#ubuntu:~/Desktop/Java/TwitterDeneme/bin$ java -classpath "~/twitter4j-2.2.6/lib/*.jar:." GetHashtag
Exception in thread "main" java.lang.NoClassDefFoundError: twitter4j/TwitterException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getMethod0(Class.java:2685)
at java.lang.Class.getMethod(Class.java:1620)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:488)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480)
Caused by: java.lang.ClassNotFoundException: twitter4j.TwitterException
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 6 more
I am using ubuntu and jdk 1.7. I tried the same command in windows and it works flawlessly. Is there anything special to do related to Ubuntu OS?
The * syntax for classpaths is rather limited. Try:
java -classpath "~/twitter4j-2.2.6/lib/*:." GetHashtag

Categories