java.lang.NoClassDefFoundError

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

Look if your classpath is correct, and check if the versions of your libraries match the version you described in your pom.xml

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • Since 1.1.7, LS introduce introduced a flusher thread so as to flush the last event in multiline filter. However, the flusher would bring in unexpected event break. For example, supposing we have below log to tail: {code} Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld (wrong name: org/xuwei/HelloWorld) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: HelloWorld. Program will exit. {code} When first 4 rows is loaded into multiline filter and flusher runs, the event will be break down into two events: {code} Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld (wrong name: org/xuwei/HelloWorld) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) {code} {code} at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: HelloWorld.  Program will exit. {code} Original code: {code:title=filterworker.rb|borderStyle=solid} @flusher = Thread.new { interval(5) { flusher } } {code} {code:title=multiline.rb|borderStyle=solid} # Flush any pending messages. This is generally used for unit testing only. public def flush events = [] @pending.each do |key, value| value.uncancel events << value end # pending messages as well as fresh messages were flushed @pending.clear return events end # def flush {code} PS: I'm currently using below code in my instance. The idea is to, in the end of every flush take a snapshot of the pending messages in multiline filter (1st flush won't flush any message), in the next flush if a message is unchanged, then we can flush it safely. {code:title=multiline.rb|borderStyle=solid} public def initialize(config = {}) ... @capture = Hash.new end # def initialize # Flush pending messages public def flush events = [] @pending.each do |key, value| # flushes keys that're not changed in last 5s next unless value == @capture[key] @pending.delete(key) value.uncancel events << value end # capture current keys in @pending @capture = @pending.clone return events end # def flush {code}
    via by luoxinwei1,
  • Since 1.1.7, LS introduce introduced a flusher thread so as to flush the last event in multiline filter. However, the flusher would bring in unexpected event break. For example, supposing we have below log to tail: {code} Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld (wrong name: org/xuwei/HelloWorld) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: HelloWorld. Program will exit. {code} When first 4 rows is loaded into multiline filter and flusher runs, the event will be break down into two events: {code} Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld (wrong name: org/xuwei/HelloWorld) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) {code} {code} at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: HelloWorld.  Program will exit. {code} Original code: {code:title=filterworker.rb|borderStyle=solid} @flusher = Thread.new { interval(5) { flusher } } {code} {code:title=multiline.rb|borderStyle=solid} # Flush any pending messages. This is generally used for unit testing only. public def flush events = [] @pending.each do |key, value| value.uncancel events << value end # pending messages as well as fresh messages were flushed @pending.clear return events end # def flush {code} PS: I'm currently using below code in my instance. The idea is to, in the end of every flush take a snapshot of the pending messages in multiline filter (1st flush won't flush any message), in the next flush if a message is unchanged, then we can flush it safely. {code:title=multiline.rb|borderStyle=solid} public def initialize(config = {}) ... @capture = Hash.new end # def initialize # Flush pending messages public def flush events = [] @pending.each do |key, value| # flushes keys that're not changed in last 5s next unless value == @capture[key] @pending.delete(key) value.uncancel events << value end # capture current keys in @pending @capture = @pending.clone return events end # def flush {code}
    via by luoxinwei1,
  • Issue Loading JarFile From Memory
    via Stack Overflow by user1681891
    ,
    • java.lang.NoClassDefFoundError: HelloWorld (wrong name: org/xuwei/HelloWorld) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    GhostsGhosts
    12 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    davidvanlaatumdavidvanlaatum
    1 times, last one,
    139 more bugmates