Problems upgrading from Scala 2.10 to 2.11 (using with Gatling, upgrading from 2.0.x to 2.1.0)

214 views
Skip to first unread message

Jonathan Vaughn

unread,
Jan 8, 2015, 8:49:45 PM1/8/15
to raptur...@googlegroups.com
Previously, with Scala 2.10 / Gatling 2.0.x, I was just using rapture-json using the Scala JSON backend, and everything "just worked" with only the rapture-core_2.10... and rapture-json_2.10... libraries.

Trying to move to a newer version of Gatling based on Scala 2.11, and thus to the new 2.11 libraries, I of course can't use the nonexistant Scala built in backend, but must pick another. It seemed like the easiest was Jackson (it sounded like I just needed one more rapture-json-jackson_2.11 library), but apparently it needs more. I've thrown in jackson-core-2.4.4.jar and jackson-databind-2.4.4.jar so far, but I'm still getting errors.

19:47:22.002 [ERROR] i.g.c.ZincCompiler$ - missing or invalid dependency detected while loading class file 'Serializers.class'.
Could not access term codehaus in package org,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Serializers.class' was compiled against an incompatible version of org.
19:47:22.127 [ERROR] i.g.c.ZincCompiler$ - missing or invalid dependency detected while loading class file 'Serializers.class'.
Could not access term jackson in value org.codehaus,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Serializers.class' was compiled against an incompatible version of org.codehaus.
19:47:22.159 [ERROR] i.g.c.ZincCompiler$ - /var/www/[redacted].scala:210: missing or invalid dependency detected while loading class file 'Serializers.class'.
Could not access term jackson in value org.codehaus,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Serializers.class' was compiled against an incompatible version of org.codehaus.

If I comment out all JSON related stuff and don't try to import rapture-json, it compiles and "runs" just fine.

What other libraries do I need to use the Jackson backend, or is there another easier to implement backend?

I did change the 'import rapture.json._' to 'rapture.json.jsonBackends.jackson._' ...

Jon Pretty

unread,
Jan 9, 2015, 12:19:20 PM1/9/15
to raptur...@googlegroups.com
Hi Jonathan,

It should be easier than that! You should be able to carry on using the standard library JSON library in Scala 2.11, but you'll need to include the Parser Combinators library - that's where it got moved to. If you're using SBT/Maven, then com.propensive/rapture-json already includes the dependency on Parser Combinators, so it should just work.

Jackson is a perfectly reasonable choice, and I'd recommend it over the standard library just because it's not ridiculously slow. If you depend on com.propensive/rapture-json-jackson, then that will include all the dependencies you need for Jackson. However, one problem that's unique to the Jackson integration is that it does not support mutable JSON. If you're not using `JsonBuffer`s, then that's not a problem. If you are, a good choice of backend would be Jawn.

Other than that difference with Jackson, all the different backends have the same set of supported features in Rapture JSON. Behaviour should be the same, except for subtle differences such as the order of keys in objects, and (of course) performance.

Regarding the imports, regardless of the backend, you should always have two imports: rapture.json._, and rapture.json.jsonBackends.<backend>._.

Just one other thing to check: Are you using the latest version, 1.1.0?

If you're not using SBT/Maven, then let me know and I'll work out a manual list of what dependencies you need.

Cheers,
Jon

--
You received this message because you are subscribed to the Google Groups "Rapture users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rapture-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jon Pretty | @propensive

Jonathan Vaughn

unread,
Jan 9, 2015, 2:50:41 PM1/9/15
to raptur...@googlegroups.com
Not currently using SBT/Maven though I want to get that set up in the future, at the moment throwing dependencies in manually. I set up a build.sbt with Gatling and rapture stuff in it, and tried to sbt update, and it downloaded stuff, but I have no idea where any of it went, but figuring out SBT is a low priority at the moment - just need to get my Gatling scala code working on current Gatling version so I don't have to provide old copies of gatling just so the script works :D

I re-added the import of rapture.json._ (which is what I had originally, then thought I needed to change it to rapture.json.jsonBackends.jackson._ ) but still seeing the same errors.

I am using 1.1.0 for Scala 2.11, downloaded from http://search.maven.org/#search|ga|1|g:%22com.propensive%22 .
Currently have:
lib/rapture-core_2.11-1.1.0.jar 
lib/rapture-data_2.11-1.1.0.jar 
lib/rapture-json_2.11-1.1.0.jar 
lib/rapture-json-jackson_2.11-1.1.0.jar
lib/jackson-core-2.4.4.jar
lib/jackson-databind-2.4.4.jar

Using built in Scala JSON would actually be fine for now, if it got things to work more easily, since although the point of Gatling is load testing, my load test scripts have delays built in to simulate real users (as opposed to trying to unrealisticly hammer the site), so throwing in an extra fraction of a second for Scala vs Jackson JSON doesn't matter if I can't make it work :D

Jon Pretty

unread,
Jan 9, 2015, 3:44:41 PM1/9/15
to raptur...@googlegroups.com
Hi Jonathan,

Good on you for managing your own dependencies! ;)

I think you should be able to get things working with just rapture-json and the standard library by including this JAR file on your classpath:

   http://search.maven.org/remotecontent?filepath=org/scala-lang/modules/scala-parser-combinators_2.11/1.0.3/scala-parser-combinators_2.11-1.0.3.jar

Let me know if that does it.

Cheers,
Jon

Jonathan Vaughn

unread,
Jan 9, 2015, 3:55:56 PM1/9/15
to raptur...@googlegroups.com
That almost has it! Now with the additional combinators library and not importing the jackson backend (just rapture.json._) I get:
14:49:42.299 [ERROR] i.g.c.ZincCompiler$ - [gatling script].scala:49: Cannot find rapture.json.JsonAst parser for values of type String
14:49:42.301 [ERROR] i.g.c.ZincCompiler$ -                 val json: Json = Json.parse(productConfigJson)
14:49:42.302 [ERROR] i.g.c.ZincCompiler$ -                                            ^
14:49:43.259 [ERROR] i.g.c.ZincCompiler$ - one error found


That ^ should line up with '.parse' in case it doesn't show in fixed font properly.

The line just above it is this:
val productConfigJson = session("productConfig").as[String]

This worked before, so presumably it should be able to parse a String.

Jon Pretty

unread,
Jan 9, 2015, 4:43:29 PM1/9/15
to raptur...@googlegroups.com
Hi Jonathan,

I think you just need to import the backend now:

   import rapture.json.jsonBackends.scalaJson._

Any joy?
Jon

Jonathan Vaughn

unread,
Jan 9, 2015, 4:54:08 PM1/9/15
to raptur...@googlegroups.com
A-ha! Thank you, this works now! Before, I didn't include a backend, but I suppose things have changed since I initially got the version I was using before.

Jon Pretty

unread,
Jan 9, 2015, 5:21:08 PM1/9/15
to raptur...@googlegroups.com
Hmmm... I think it's been a few versions since you could get away without specifying the backend, but I can believe that was the case once!

Let me know if you have any more issues!

Cheers,
Jon
Reply all
Reply to author
Forward
0 new messages