jvm - Why can I not pickle my case classes? What should I do to solve this manually next time? -
edit 2: observations , questions
i pretty sure along commenter below justin problem due errant
build.sbt
configuration. however, first time have seen errantbuild.sbt
configuration literally works everything else except pickers. maybe becaus use macros , rule avoid them.why matter whether
flow.merge
used vsflow.map
if problemsbt
?suspicious build.sbt extract
lazy val server = project .dependson(sharedjvm, client)
suspicious stack trace
so top of stack: goes method cannot find linking environment string encoding utils. ok.
server java.lang.runtimeexception: stub
huh? stub
?
server @ scala.sys.package$.error(package.scala:27) server @ scala.scalajs.runtime.package$.linkinginfo(package.scala:143) server @ scala.scalajs.runtime.package$.environmentinfo(package.scala:137)
huh?
server @ scala.scalajs.js.dynamic$.global(dynamic.scala:78)
???
server @ boopickle.stringcodec$.encodeutf8(stringcodec.scala:56)
edit 1: big , beautiful build.sbt might problem
what cannot see organized in project
folder:
jvmdependencies.scala
has regular jvm dependenciessjsdependencies.scala
hasdef.settingskey
s oflibrarydependencies
onjsmoduleid
swebjardependencies.scala
has javascripts , css's
build.sbt
lazy val shared = (crossproject.crosstype(crosstype.pure) in file("shared")) .configure(_.enableplugins(scalajsplugin)) .settings(sjsdependencies.pickling.tosettingsdefinition(): _*) .settings(sjsdependencies.tagsanddom.tosettingsdefinition(): _*) .settings(sjsdependencies.css.tosettingsdefinition(): _*) lazy val sharedjvm = shared.jvm lazy val sharedjs = shared.js lazy val cmdlne = project .dependson(sharedjvm) .settings( librarydependencies ++= ( jvmdependencies.commandline ++ jvmdependencies.logging ++ jvmdependencies.akka ++ jvmdependencies.serialization ) ) lazy val client = project .enableplugins(scalajsplugin, sbtweb, sbtsass) .dependson(sharedjs) .settings( (sjsdependencies.shapeless ++ sjsdependencies.audiovideo ++ sjsdependencies.databind ++ sjsdependencies.functional ++ sjsdependencies.lensing ++ sjsdependencies.logging ++ sjsdependencies.reactive).tosettingsdefinition(), jsdependencies ++= webjardependencies.js, librarydependencies ++= webjardependencies.notjs, persistlauncher in compile := true ) lazy val server = project .dependson(sharedjvm, client) .enableplugins(sbtnativepackager) .settings( copywebjarresources := { streams.value.log("copying webjar resources") val `web modules target directory` = (resourcemanaged in compile).value / "assets" val `web modules source directory` = (webkeys.assets in assets in client).value / "lib" final class usefulfilefilter(acceptable: string*) extends filefilter { // todo adjust exclude js map files import scala.collection.javaconversions._ def accept(file: file) = (file.isdirectory && fileutils.listfiles(file, acceptable.toarray, true).nonempty) || acceptable.contains(file.ext) && !file.name.contains(".js.") } val `file filter` = new usefulfilefilter("css", "scss", "sass", "less", "map") io.createdirectory(`web modules target directory`) io.copydirectory(source = `web modules source directory`, target = `web modules target directory` / "script") fileutils.copydirectory(`web modules source directory`, `web modules target directory` / "style", `file filter`) }, // run copy after compile/assets before managed resources copywebjarresources <<= copywebjarresources dependson(compile in compile, webkeys.assets in compile in client, fastoptjs in compile in client), managedresources in compile <<= (managedresources in compile) dependson copywebjarresources, watchsources <++= (watchsources in client), resourcegenerators in compile <+= def.task { val files = ((crosstarget in(client, compile)).value ** ("*.js" || "*.map")).get val mappings: seq[(file,string)] = files pair rebase((crosstarget in(client, compile)).value, ((resourcemanaged in compile).value / "assets/").getabsolutepath ) val map: seq[(file, file)] = mappings.map { case (s, t) => (s, file(t))} io.copy(map).toseq }, restart <<= restart dependson (managedresources in compile), librarydependencies ++= ( jvmdependencies.akka ++ jvmdependencies.jarlocating ++ jvmdependencies.functional ++ jvmdependencies.serverpickling ++ jvmdependencies.logging ++ jvmdependencies.serialization ++ jvmdependencies.testing ) )
edit 0: obscure chat thread has guy saying feeling: no, not **** scala, but
mark eibes @i-am-the-slime oct 15 2015 09:37 @ochrons i'm still fighting. can't seem pickle anymore. https://gitter.im/scala-js/scala-js/archives/2015/10/15
i have rather simple requirement - have 1 web socket route on akka
http server defined akkaserverlogeventtomessagehandler()
:
object akkaserverlogeventtomessagehandler extends directives { val sourceoflogs = source.actorpublisher[akkaserverlogmessage](akkaserverlogeventpublisher.props) map { event ⇒ binarymessage( bytestring( pickle.intobytes[akkaserverlogmessage](event) ) ) } def apply(): server.route = { handlewebsocketmessages( flow[message].merge(sourceoflogs) ) } }
this fits tiny set of routes in obvious way.
now why cannot boopickle
, upickle
, or prickle
serialize simple stupid case class?
sealed case class akkaserverlogmessage( message: string, level: int, timestamp: long )
- no nesting
- all primitive types
- no generics
- only 3 of them
these produced same error
- using 3 of common picklers write
- using
textmessage
instead ofbinarymessage
, correspondingupickle
orprickle
writejs
or whatever methods - varying
case class
down nothing (nothing, in no members) - varying input
case class
- importing various permutations of
implicits
, underscore stuff
... specifically, gave me variations on same stupid error (not same error, considerably similar)
server [error] [04/21/2016 22:04:00.362] [app-akka.actor.default-dispatcher-7] [akka.actor.actorsystemimpl(app)] websocket handler failed stub server java.lang.runtimeexception: stub server @ scala.sys.package$.error(package.scala:27) server @ scala.scalajs.runtime.package$.linkinginfo(package.scala:143) server @ scala.scalajs.runtime.package$.environmentinfo(package.scala:137) server @ scala.scalajs.js.dynamic$.global(dynamic.scala:78) server @ boopickle.stringcodec$.encodeutf8(stringcodec.scala:56) server @ boopickle.encoder.writestring(codecs.scala:338) server @ boopickle.basicpicklers$stringpickler$.pickle(pickler.scala:183) server @ boopickle.basicpicklers$stringpickler$.pickle(pickler.scala:134) server @ boopickle.picklestate.pickle(pickler.scala:511) server @ shindig.clientaccess.handler.akkaserverlogeventtomessagehandler$$anonfun$1$pickler$macro$1$2$.pickle(akkaserverlogeventtomessagehandler.scala:35) server @ shindig.clientaccess.handler.akkaserverlogeventtomessagehandler$$anonfun$1$pickler$macro$1$2$.pickle(akkaserverlogeventtomessagehandler.scala:35) server @ boopickle.pickleimpl$.apply(default.scala:70) server @ boopickle.pickleimpl$.intobytes(default.scala:75) server @ shindig.clientaccess.handler.akkaserverlogeventtomessagehandler$$anonfun$1.apply(akkaserverlogeventtomessagehandler.scala:35) server @ shindig.clientaccess.handler.akkaserverlogeventtomessagehandler$$anonfun$1.apply(akkaserverlogeventtomessagehandler.scala:31)
this worked
- not using
flow.merge
(defeats purpose, want keep sending out put logs) - using static value
- other useless things
appeal
please let me know , why stupid... spent 4 hours on problem today in different forms, , driving me nuts.
in build.sbt
, have:
lazy val shared = (crossproject.crosstype(crosstype.pure) in file("shared")) .configure(_.enableplugins(scalajsplugin))
do not this. must not enable scala.js plugin on cross-project, ever. adds jvm side, wreak havoc. notably, cause %%%
resolve scala.js artifacts of dependencies in jvm project, , bad. causes issue.
crossproject
adds scala.js plugin js part, , one. remove enableplugins
line.
Comments
Post a Comment