softwaremill / elasticmq

In-memory message queue with an Amazon SQS-compatible interface. Runs stand-alone or embedded.
https://softwaremill.com/open-source/
Apache License 2.0
2.51k stars 194 forks source link

java.lang.NoClassDefFoundError for embedded server #22

Closed conniec closed 10 years ago

conniec commented 10 years ago

Hi, I am trying to start an embedded ElasticMQ server for testing SQS. Following your example, I'm just doing

val server = SQSRestServerBuilder.start()

Here is my stacktrace, I'm not sure what is wrong, maybe some config is not set?

java.lang.NoClassDefFoundError: scala/Predef$any2stringadd$ at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 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) at akka.actor.RootActorPath.(ActorPath.scala:165) at akka.event.Logging$StandardOutLogger.(Logging.scala:779) at akka.event.Logging$.(Logging.scala:787) at akka.event.Logging$.(Logging.scala) at akka.event.LoggingBus$class.setUpStdoutLogger(Logging.scala:71) at akka.event.LoggingBus$class.startStdoutLogger(Logging.scala:87) at akka.event.EventStream.startStdoutLogger(EventStream.scala:26) at akka.actor.ActorSystemImpl.(ActorSystem.scala:571) at akka.actor.ActorSystem$.apply(ActorSystem.scala:141) at akka.actor.ActorSystem$.apply(ActorSystem.scala:108) at org.elasticmq.rest.sqs.TheSQSRestServerBuilder$$anonfun$getOrCreateActorSystem$2.apply(SQSRestServerBuilder.scala:171) at org.elasticmq.rest.sqs.TheSQSRestServerBuilder$$anonfun$getOrCreateActorSystem$2.apply(SQSRestServerBuilder.scala:170) at scala.Option.getOrElse(Option.scala:120) at org.elasticmq.rest.sqs.TheSQSRestServerBuilder.getOrCreateActorSystem(SQSRestServerBuilder.scala:170) at org.elasticmq.rest.sqs.TheSQSRestServerBuilder.start(SQSRestServerBuilder.scala:82) at com.twilio.auditevents.processor.SQSSendReceive$$anonfun$1.apply$mcV$sp(SQSSendReceive.scala:39)

SQSSendReceive is the file I am calling the build server method from.

adamw commented 10 years ago

Are you using Java or Scala? Could you check if you have scala-library on the classpath, and if so, which version?

conniec commented 10 years ago

I am using Scala, I didn't have scala-library explicitly added. I added version 2.11.0 as a dependency and it seems to work now. Thanks for your help!

adamw commented 10 years ago

Maybe you are using an older version of Scala then? It's quite if you are using Scala that you wouldn't have scala-library on the classpath :). Also it's better not to mix libraries for old version of Scala (e.g. 2.10) with new ones (2.11), as things stop working then.

Btw. are you using SBT or Maven pulling EMQ from a repository? It should have all the dependencies included then.

conniec commented 10 years ago

Yes I am using an older version of scala, 2.10.3, so you're saying I should use scala-library 2.10? And yup, I'm using Maven to pull from the repository, I added the softwaremill-releases in my repositories and elasticmq 2.11 version 0.8.2, is that correct?

adamw commented 10 years ago

For 2.10.3 I would recommend using elasticmq 0.7.1, not to get scala version conflicts. I think you should be fine without the additional scala-library dependency then.

Both versions live in softwaremill-releases, that's correc.t

conniec commented 10 years ago

I tried this:

   <dependency>
        <groupId>org.elasticmq</groupId>
        <artifactId>elasticmq-rest-sqs_2.10</artifactId>
        <version>0.7.1</version>
    </dependency>

And took out the scala-library dependency, but now my md5 checksum started failing for receiving a message I had sent with elasticmq:

com.amazonaws.AmazonClientException: MD5 returned by SQS does not match the calculation on the original request. (MD5 calculated by the message attributes: "505ca7b61fbeaedb4fa2b5258cbc7dfc", MD5 checksum returned: "null")

adamw commented 10 years ago

Hmm that should work, the md5 calculation logic didn't change as far as I remember for a long time. Probably the "null" is wrong :). Which library are you using to access SQS?

conniec commented 10 years ago

Hmm that is odd, I am using the Amazon java sdk v2. Somewhat unrelated question, can I use the embedded server to test the async calls provided by the Amazon SQS client? Whenever I add an AsyncHandler I get some weird error messages:

10:47:01.581 [pool-5-thread-1] DEBUG o.a.h.i.c.PoolingClientConnectionManager - Connection request: [route: {}->http://localhost:9324][total kept alive: 0; route allocated: 0 of 50; total allocated: 0 of 50] 10:47:01.584 [pool-5-thread-1] DEBUG c.a.h.c.ClientConnectionManagerFactory - java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_51]

adamw commented 10 years ago

Hmm the latest java sdk from amazon is 1.8.1 :)

Async handlers should work just fine. It's a client-side thing, so no difference to the server.

conniec commented 10 years ago

Ok, with sdk 1.8.1, elasticmq 0.7.1 and scala-library 2.10.3 I am getting the same checksum error, not sure why

adamw commented 10 years ago

The same error with a null checksum? That's very weird :/ Do you have an easy way to reproduce? Like a small project? The tests I have work just fine (the fames "works for me" ;) )

conniec commented 10 years ago

Hey Adam, I just set up a quick repo that throws the MD5 checksum error for me: https://github.com/conniec/sqstest Let me know if that works for you or if you see anything I did wrong. I run the test with mvn test in the console. Thanks!

adamw commented 10 years ago

Ah, I see where the problem lies - support for message attributes has been added in 0.8.2. Before they were ignored, hence the null checksum :) Sorry for the trouble! I guess the only solution is to upgrade to Scala 2.11

conniec commented 10 years ago

Thanks for your help, I understand the problem now. I will workaround by using the message contents instead of attributes. Thanks again!