These are chat archives for sbt/sbt-web

14th
Oct 2017
Matthew de Detrich
@mdedetrich
Oct 14 2017 18:25
Okay, so I have this very weird problem
I am combined sbt-digest with scala-js, specifically I am adding sbt-digest to https://github.com/vmunier/akka-http-with-scalajs-example
And I set pipelineAssets like so
  pipelineStages := Seq(digest)
Now everything gets digested as expected
The biggest issue is that, for some reason, I can’t load a specific file in the classloader resource
specifically "/public/8582ad69409ecf661cc901a281d8a30c-client-fastopt.js”
I have manually unzipped the packaged web assets file (i.e. server_2.12-0.1-SNAPSHOT-web-assets.jar)
and when I do something like
val stream = getClass.getResourceAsStream("/public/8582ad69409ecf661cc901a281d8a30c-client-fastopt.js”)
It can’t find the resource
However every other resource I can find fine in the .jar
as an example, if I manually inflate the server_2.12-0.1-SNAPSHOT-web-assets.jar file I get the following files
[/p/v/f/9/z/T/s/t/fad8e55b]─> unzip server_2.12-0.1-SNAPSHOT-web-assets.jar
Archive:  server_2.12-0.1-SNAPSHOT-web-assets.jar
  inflating: META-INF/MANIFEST.MF
   creating: public/
   creating: public/1c6152a81d0149fa3405/
   creating: public/1c6152a81d0149fa3405/example/
   creating: public/2396c1fa822f36b24385/
   creating: public/2396c1fa822f36b24385/shared/
   creating: public/stylesheets/
  inflating: public/stylesheets/main.less
  inflating: public/8582ad69409ecf661cc901a281d8a30c-client-fastopt.js
  inflating: public/client-fastopt.js.map.md5
  inflating: public/1c6152a81d0149fa3405/example/ScalaJSExample.scala
  inflating: public/stylesheets/c9078c57e54ef9e2c3e69adc9bc21e38-main.css.map
  inflating: public/2396c1fa822f36b24385/shared/SharedMessages.scala
  inflating: public/client-fastopt.js.md5
  inflating: public/2396c1fa822f36b24385/shared/7cb38f3ca4e8fd18d1e8052e1ae4202c-SharedMessages.scala
  inflating: public/stylesheets/main.css.map.md5
  inflating: public/stylesheets/main.less.md5
  inflating: public/2396c1fa822f36b24385/shared/SharedMessages.scala.md5
  inflating: public/stylesheets/main.css.md5
  inflating: public/1c6152a81d0149fa3405/example/ScalaJSExample.scala.md5
  inflating: public/stylesheets/main.css
  inflating: public/stylesheets/main.css.map
  inflating: public/c83d5ec20f6efeba5873040e77f819de-client-fastopt.js.map
  inflating: public/stylesheets/5f59caadb44c8d720a2a5d9fc948eed0-main.less
  inflating: public/1c6152a81d0149fa3405/example/e2a7c3ea2325d3f58a43f254e36e7086-ScalaJSExample.scala
  inflating: public/client-fastopt.js
  inflating: public/stylesheets/5f59caadb44c8d720a2a5d9fc948eed0-main.css
  inflating: public/client-fastopt.js.map
And this is the exact same jar that gets loaded into the classpath, i.e.
[debug]   Classpath:
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/job-1/target/78c4612d/server_2.12-0.1-SNAPSHOT.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/6be8524c/shared_2.12-0.1-SNAPSHOT.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/fe978017/scala-library-2.12.2.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/0d7241e1/twirl-api_2.12-1.3.12.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/e22de336/scala-xml_2.12-1.0.6.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/4cbea03a/akka-http_2.12-10.0.10.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/eb51e977/akka-http-core_2.12-10.0.10.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/b6ba857b/akka-parsing_2.12-10.0.10.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/d352c9f6/akka-actor_2.12-2.4.19.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/f533aa6e/config-1.3.0.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/1e6f1e74/scala-java8-compat_2.12-0.8.0.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/04c33cbb/akka-stream_2.12-2.4.19.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/14b8c877/reactive-streams-1.0.0.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/7497c001/ssl-config-core_2.12-0.2.1.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/7c5f25a2/scala-parser-combinators_2.12-1.0.4.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/cb7fb9dc/scalajs-scripts_2.12-1.1.0.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/247e20ee/akka-http-versioned-assets_2.12.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/9ce04e34/commons-codec-1.9.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/2852e6e0/commons-io-2.5.jar
[debug]         /var/folders/9l/z3wrf4_96cv3kzdg7lp65vr40000gn/T/sbt_8ae0424b/target/fad8e55b/server_2.12-0.1-SNAPSHOT-web-assets.jar
[debug] Waiting for thread run-main-0 to terminate.
Matthew de Detrich
@mdedetrich
Oct 14 2017 18:31
Any idea what is causing this? I have lost all day on it
Its just this one specifical file (i.e. the md5’ed digest of client-fastopt.js which I can’t find
It works with play so I assume they are doing some magic here?
Matthew de Detrich
@mdedetrich
Oct 14 2017 18:36
@vmunier Any idea?
This is related to vmunier/akka-http-with-scalajs-example#4
Matthew de Detrich
@mdedetrich
Oct 14 2017 19:02
I am creating a reproducable project now
Matthew de Detrich
@mdedetrich
Oct 14 2017 19:24
@jamesward Do you have any idea, I suppose you had similar issues when working with webjars and finding assets?
James Ward
@jamesward
Oct 14 2017 19:27
Hmm.. I haven't run into this. Not sure what the deal is.
Matthew de Detrich
@mdedetrich
Oct 14 2017 19:31
@jamesward Does it look like I am doing anything stupid?
James Ward
@jamesward
Oct 14 2017 19:32
No that all looks right.
Matthew de Detrich
@mdedetrich
Oct 14 2017 19:33
I think that @jroper may know something
He must have done some magic to get it working in play (since it does work in Play)
James Ward
@jamesward
Oct 14 2017 19:35
Yeah, I'm not sure what they did to make this work. There is the special asset controller that works with digest assets. Can check out the source for that.
Matthew de Detrich
@mdedetrich
Oct 14 2017 19:35
Yeah I tried looking at it but it appears to be a bit convoluted
There is a lot of custom DI in play, the important thing seems to be the classloader that is being used
James Ward
@jamesward
Oct 14 2017 19:48
yeah. sorry I'm not more helpful.
Matthew de Detrich
@mdedetrich
Oct 14 2017 19:49
No worries, think I will need someone from Play framework who knows more
James Roper
@jroper
Oct 14 2017 22:55
I know nothing.
I've never used scala.js so I'm not aware of anything specific to it. My first suggestion would be try Classloader.getResources to see if that returns something different - for example, if there's a directory named /public/8582ad69409ecf661cc901a281d8a30c-client-fastopt.js on the classpath, that's gonna stuff everything up. check the actual contents of the file in the in the jar, make sure it's as expected.
James Roper
@jroper
Oct 14 2017 23:00
also try printing the URL returned by ClassLoader.getResource for the assets that are found, maybe they are coming from a location that you're not expecting (ie, perhaps the web-assets jar isn't actually on the classpath, it's just in the lib directory but your startup script isn't adding that jar to the classpath, while the scala.js resources are actually being bundled in another jar as well, and that's where the classloader is finding them).