kitlangton / zio-app

Quickly create and develop full-stack Scala apps with ZIO and Laminar.
124 stars 33 forks source link

zio-app dev won't launch - dist/index.html not found #18

Closed softdevca closed 11 months ago

softdevca commented 3 years ago

zio-app dev starts but when the link is opened an exception results because dist/index.html is not on the classpath.

zio-app is built from the latest source as of 2021-06-16.

sheldon@blackbird:~/code/scratch/newapp$ zio-app dev
Running Dev Mode     
http://localhost:9630
STARTING SERVER ON PORT 9630
Jun 16, 2021 10:30:23 AM io.netty.channel.DefaultChannelPipeline onUnhandledInboundException
WARNING: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.io.FileNotFoundException: resource 'dist/index.html' was not found in the classpath from the given classloader.
    at scala.io.Source$.fromResource(Source.scala:183)
    at zio.app.Backend$$anonfun$app$1.applyOrElse(Backend.scala:57)
    at zio.app.Backend$$anonfun$app$1.applyOrElse(Backend.scala:43)
    at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:35)
    at zhttp.http.Http.execute(Http.scala:181)
    at zhttp.http.Http.execute$(Http.scala:174)
    at zhttp.http.Http$Collect.execute(Http.scala:197)
    at zhttp.service.server.ServerRequestHandler.executeAsync(ServerRequestHandler.scala:38)
    at zhttp.service.server.ServerRequestHandler.channelRead0(ServerRequestHandler.scala:62)
    at zhttp.service.server.ServerRequestHandler.channelRead0(ServerRequestHandler.scala:16)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at io.netty.handler.codec.http.HttpServerKeepAliveHandler.channelRead(HttpServerKeepAliveHandler.java:64)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:834)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
kitlangton commented 3 years ago

Ah, I must upgrade the instructions even more :P Try running ./release.sh, this will build the frontend, put the dist/index.html in the right place, and then run nativeImage.

softdevca commented 3 years ago

Is there a way to modify the build process so the step isn't necessary instead? The only thing better than documentation is not needing documentation. :)

I haven't run release.sh yet but I suspect something is amiss with this line:

mv ./cli-frotnend/dist ./cli/src/main/resources/dist

On Wed, 16 Jun 2021 at 15:04, Kit Langton @.***> wrote:

Ah, I must upgrade the instructions even more :P Try running ./release.sh, this will put the dist/index.html in the right place.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kitlangton/zio-app/issues/18#issuecomment-862759813, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR5U7SBLHXLFB7RQBLSWTLTTENVTANCNFSM46Z5H3ZA .

kitlangton commented 3 years ago

😆 Yeah. frotnend... doh.

kitlangton commented 3 years ago

I'm not sure. I'd have to see if I can make an sbt command that will basically do what that script does. Good idea though.

mtjon commented 3 years ago

I encountered the same issue as OP, but looking at release.sh I see several issues that may need to be addressed:

I did get the zio-app dev to run after taking care of this.

mtjon commented 3 years ago

I'm not sure. I'd have to see if I can make an sbt command that will basically do what that script does. Good idea though.

We could perhaps make use of sbt's support for external processes to run the yarn exec -- vite build, and

tar -czf zio-app.gz zio-app
echo $(shasum -a 256 zio-app.gz)

Using the nativeImageOutput configuration should help us get rid of

cd cli/target/native-image
mv zio-app-cli zio-app

altogether.

And wrap it all up into a custom sbt task.

kitlangton commented 3 years ago

Thanks for exploring this @mtjon! I'll look into wrapping this into an sbt task :)