简体   繁体   中英

Javassist Runtime Error with msgpack-java

I am trying to use messagepack to send data back and forth between an Arduino and a Java application, and I am having trouble setting up the java implementation of messagepack: msgpack-java ( https://github.com/msgpack/msgpack-java/wiki/QuickStart ).

I wanted to avoid building the entire library myself, so I used v0.6.8 from here .

The sample code compiles successfully but at runtime I get

java.lang.NoClassDefFoundError: javassist/ClassPath

specifically at the line

MessagePack msgpack = new MessagePack();

I tried just building the msgpack jar myself, but I got compile errors on the source code because it is missing javassist packages. I do not know where to get the correct packages, and unfortunately the developers don't mention that in the documentation. I couldn't find a comments section on their page so I was hoping that someone on here could help me get msgpack working.

I also looked at this question ( Using MessagePack with Android ) but it was not really clear about where I can get the libraries I need.

I guess this was a fairly obvious question but I'll answer it here in case anybody else is having troubles like me. I ended up learning about the dependencies I needed by looking at the Maven POM file. This file told me that I needed the json-simple library and the javassist library. I just downloaded the .jar files for these two libraries and added them to the eclipse build path and everything ran just fine.

As an alternative, consider sirbrialliance's stripped-down static implementation: https://bitbucket.org/sirbrialliance/msgpack-java-lite This is a bit better documented and easier to set-up initially.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM