Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON serialize fails - could not find implicit evidence #38

Closed
MLnick opened this issue Jul 5, 2016 · 9 comments
Closed

JSON serialize fails - could not find implicit evidence #38

MLnick opened this issue Jul 5, 2016 · 9 comments

Comments

@MLnick
Copy link

MLnick commented Jul 5, 2016

Am I doing something daft? From the example:

object AvroTest extends App {
  import com.sksamuel.avro4s.AvroOutputStream

  case class Composer(name: String, birthplace: String, compositions: Seq[String])
  val ennio = Composer("ennio morricone", "rome", Seq("legend of 1900", "ecstasy of gold"))

  val baos = new ByteArrayOutputStream()
  val output = AvroOutputStream.json[Composer](baos)
  output.write(ennio)
  output.close()
  println(baos.toString("UTF-8"))
}

gives

Error:(14, 47) could not find implicit value for evidence parameter of type com.sksamuel.avro4s.ToRecord[AvroTest.Composer]
  val output = AvroOutputStream.json[Composer](baos)
                                              ^

Error:(14, 47) not enough arguments for method json: (implicit evidence$5: com.sksamuel.avro4s.SchemaFor[AvroTest.Composer], implicit evidence$6: com.sksamuel.avro4s.ToRecord[AvroTest.Composer])com.sksamuel.avro4s.AvroJsonOutputStream[AvroTest.Composer].
Unspecified value parameter evidence$6.
  val output = AvroOutputStream.json[Composer](baos)
                                              ^

using sbt:

 sbt compile
[info] Loading project definition from /Users/nick/workspace/scala/avro4s-example/project
[info] Set current project to avro4s-example (in build file:/Users/nick/workspace/scala/avro4s-example/)
[info] Updating {file:/Users/nick/workspace/scala/avro4s-example/}avro4s-example...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/nick/workspace/scala/avro4s-example/target/scala-2.11/classes...
[error] /Users/nick/workspace/scala/avro4s-example/src/main/scala-2.11/AvroTest.scala:12: could not find implicit value for evidence parameter of type com.sksamuel.avro4s.ToRecord[AvroTest.Composer]
[error]   val output = AvroOutputStream.json[Composer](baos)
[error]                                               ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 5 s, completed 05 Jul 2016 4:28:07 PM
@sksamuel
Copy link
Owner

sksamuel commented Jul 5, 2016

I get same error when I try a package outside of com.sksamuel.avro, which all the tests are using. Strange.

@sksamuel
Copy link
Owner

sksamuel commented Jul 5, 2016

It seems to work if I undo the recent caching changes. Perhaps something in there isn't being properly scoped @jeroentervoorde

@MLnick
Copy link
Author

MLnick commented Jul 6, 2016

yeah I tried 1.4.3 and it does work.

@jeroentervoorde
Copy link
Contributor

jeroentervoorde commented Jul 7, 2016

Yes. Problem was in ToRecord macro not using a fully qualified name for SchemaFor
Sorry for not noticing this before. I had an "import com.sksamuel.avro4s._" in my test code.

I made a PR (#39) to fix this.

I could add a test containing the examples from the README in another package to avoid this. What
do you think?

@sksamuel
Copy link
Owner

sksamuel commented Jul 7, 2016

Yes that seems like a good idea.
On 7 Jul 2016 21:17, "jeroentervoorde" notifications@github.com wrote:

Yes. Problem was in ToRecord macro not using a fully qualified name for
SchemaFor
Sorry for not noticing this before. I had a import com.sksamuel.avro4s._
in my test code.

I made a PR (#39 #39) to fix
this.

I could add a test containing the examples from the README in another
package to avoid this. What
do you think?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#38 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAtZGpG_vw8p9dOm7wLOMaNStvdFKRUOks5qTV7kgaJpZM4JFLCi
.

@jeroentervoorde
Copy link
Contributor

Alright. I'll do that tomorrow.

@jeroentervoorde
Copy link
Contributor

I submitted a PR for the tests

@sksamuel
Copy link
Owner

sksamuel commented Jul 9, 2016

All fixed now in 1.5.1

@dileepprasad-developer
Copy link

dileepprasad-developer commented May 3, 2017

I was trying the same with 1.6.3 and got below error

Error:(102, 49) Could not find implicit SchemaFor[Composer]
val output = AvroOutputStream.jsonComposer
Error:(102, 49) not enough arguments for method json: (implicit evidence$5: com.sksamuel.avro4s.SchemaFor[Composer], implicit evidence$6: com.sksamuel.avro4s.ToRecord[Composer])com.sksamuel.avro4s.AvroJsonOutputStream[Composer].
Unspecified value parameters evidence$5, evidence$6.
val output = AvroOutputStream.jsonComposer

Am I doing anything bad or should I write explicit converters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants