question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ExceptionInInitializerError because it did not find MessageBufferU

See original GitHub issue

Hi,

I’m trying to upgrade from msgpack 0.5.3 to 0.7.0-M6.

Followed the example from: https://github.com/msgpack/msgpack-java/blob/v07-develop/msgpack-core/src/test/java/org/msgpack/core/example/MessagePackExample.java, but my app always crashes with this error:

08-22 19:47:37.532 9501-9501/com.myapp.dev E/AndroidRuntime? FATAL EXCEPTION: main java.lang.ExceptionInInitializerError at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35) at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153) at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158) at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448) Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.msgpack.core.buffer.MessageBufferU at org.msgpack.core.buffer.MessageBuffer.<clinit>(MessageBuffer.java:141)             at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35)             at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153)             at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158)             at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448) Caused by: java.lang.ClassNotFoundException: org.msgpack.core.buffer.MessageBufferU at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:204) at java.lang.Class.forName(Class.java:169) at org.msgpack.core.buffer.MessageBuffer.<clinit>(MessageBuffer.java:127)             at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35)             at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153)             at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158)             at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448) Caused by: java.lang.NoClassDefFoundError: org/msgpack/core/buffer/MessageBufferU             at java.lang.Class.classForName(Native Method)             at java.lang.Class.forName(Class.java:204)             at java.lang.Class.forName(Class.java:169)             at org.msgpack.core.buffer.MessageBuffer.<clinit>(MessageBuffer.java:127)             at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35)             at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153)             at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158)             at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448) Caused by: java.lang.ClassNotFoundException: Didn't find class "org.msgpack.core.buffer.MessageBufferU" on path: DexPathList[[zip file "/data/app/com.myapp.dev-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.myapp.dev-1, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461)             at java.lang.Class.classForName(Native Method)             at java.lang.Class.forName(Class.java:204)             at java.lang.Class.forName(Class.java:169)             at org.msgpack.core.buffer.MessageBuffer.<clinit>(MessageBuffer.java:127)             at org.msgpack.core.buffer.OutputStreamBufferOutput.next(OutputStreamBufferOutput.java:35)             at org.msgpack.core.MessagePacker.ensureCapacity(MessagePacker.java:153)             at org.msgpack.core.MessagePacker.writeByte(MessagePacker.java:158)             at org.msgpack.core.MessagePacker.packArrayHeader(MessagePacker.java:448)

Do i have to add some extra stuff in the app’s dependencies? It fails when i try to do any kind of packing.

Any suggestions on how to fix this ? Thanks

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
radu-mereutacommented, Nov 25, 2022

@akanshSirohi Oh boy. That was such a long time ago 😄

The issue was that we were using Proguard to obfuscate the code and msgpack didn’t like the fact that it’s classes had their name changed (or they would outright not be bundled in the resulting apk). The fix was to just mark the particular class to be kept with the same name & to be bundled in the apk.

Something like -keep class javax.** { *; }

Can’t give you the exact example as i’m no longer working on that project and i don’t have access to the source code anymore

0reactions
akanshSirohicommented, Nov 25, 2022

@MereutaRadu Thank you so much for this elaborated and quick reply!!! I really appreciate it! 😁 I got it working using the rule below, hope it helps someone in future.

-keep class org.msgpack.** {
    *;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.ExceptionInInitializerError with gradle - Stack Overflow
Upgrading Gradle to 4.10.2 version and Java JDK 8 to 1.8.0_191 version worked for me. ... It can be because of [Could not...
Read more >
How to Resolve Java.lang.ExceptionInInitializerError In Java?
We can resolve the java.lang.ExceptionInInitializerError by ensuring that static initializer block of classes does not throw any Runtime ...
Read more >
How to Handle the Exception In Initializer Runtime Error in Java
Java's ExceptionInInitializerError occurs when an unchecked exception takes place in a static initializer or static variable assignment.
Read more >
When Does Java Throw the ExceptionInInitializerError?
The ExceptionInInitializerError indicates that an unexpected exception has occurred in a static initializer. Basically, when we see this ...
Read more >
ExceptionInInitializerError (Java Platform SE 7 )
Signals that an unexpected exception has occurred in a static initializer. An ExceptionInInitializerError is thrown to indicate that an exception occurred ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found