cyrilou242 / jnotebook

Notebook for Java.
https://jnotebook.catheu.tech
MIT License
12 stars 3 forks source link

quickstart woes #26

Open kolia opened 5 months ago

kolia commented 5 months ago

Nice work, I love the rationale!

On linux, the quickstart steps

curl -Ls https://get.jnotebook.catheu.tech -o jnotebook
chmod +x jnotebook
./jnotebook server

do not work for me, running from /home/me/my-maven-project/ I get:

$ ./jnotebook server
[main] INFO tech.catheu.jnotebook.jshell.ShellProvider - Found a pom.xml file. Trying to add maven dependencies to the classpath...
[main] WARN tech.catheu.jnotebook.jshell.ShellProvider - Maven wrapper not found. Trying to use `mvn` directly.
[main] WARN tech.catheu.jnotebook.jshell.ShellProvider - Maven dependencies command ran successfully, but classpath is empty
[main] INFO tech.catheu.jnotebook.jshell.ShellProvider - Maven dependencies added to the classpath successfully
[main] INFO tech.catheu.jnotebook.jshell.ShellProvider - Injecting notebook utils in the classpath.
[main] WARN tech.catheu.jnotebook.Main - Using dynamic templates. This should only happen in development.
Apr 19, 2024 10:08:07 AM org.xnio.Xnio <clinit>        
INFO: XNIO version 3.8.8.Final                                                                                                                                                                
Apr 19, 2024 10:08:07 AM org.xnio.nio.NioXnio <clinit>                                                                                                                                        
INFO: XNIO NIO Implementation Version 3.8.8.Final                                                                                                                                             
Apr 19, 2024 10:08:07 AM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.5.0.Final
[main] INFO tech.catheu.jnotebook.InteractiveNotebook - Notebook server started. Go to http://localhost:5002                                                                               
Apr 19, 2024 10:08:07 AM io.undertow.Undertow start                                                                                                                                           
INFO: starting server: Undertow - 2.3.5.Final                                                                                                                                                 
Apr 19, 2024 10:08:13 AM io.undertow.server.Connectors executeRootHandler                                                                                                                     
ERROR: UT005071: Undertow request failed HttpServerExchange{ GET /}                            
gg.jte.TemplateNotFoundException: index.jte not found (tried to load file at /home/me/my-maven-project/jnotebook-core/src/main/jte/index.jte)
        at gg.jte.compiler.TemplateCompiler.resolveCode(TemplateCompiler.java:298)             
        at gg.jte.compiler.TemplateCompiler.generateTemplateCall(TemplateCompiler.java:260)    
        at gg.jte.compiler.TemplateCompiler.generate(TemplateCompiler.java:169)                
        at gg.jte.compiler.TemplateCompiler.precompile(TemplateCompiler.java:93)
        at gg.jte.compiler.TemplateCompiler.load(TemplateCompiler.java:50)                                                                                                                    
        at gg.jte.TemplateEngine.lambda$resolveTemplateOnDemand$0(TemplateEngine.java:354)     
        at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1916)
        at gg.jte.TemplateEngine.resolveTemplateOnDemand(TemplateEngine.java:347)                                                                                                             
        at gg.jte.TemplateEngine.resolveTemplate(TemplateEngine.java:337)                                                                                                                     
        at gg.jte.TemplateEngine.render(TemplateEngine.java:210)
        at tech.catheu.jnotebook.server.HtmlTemplateEngine.render(HtmlTemplateEngine.java:42)
        at tech.catheu.jnotebook.server.InteractiveServer$TemplatedHttpHandler.handleRequest(InteractiveServer.java:120)
        at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
        at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:256)
        at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
        at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:162)
        at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:100)
        at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:57)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291)
        at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286)
        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
        at org.xnio.nio.QueuedNioTcpServer2.acceptTask(QueuedNioTcpServer2.java:178)
        at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:612)
        at org.xnio.nio.WorkerThread.run(WorkerThread.java:479)

What does work for me on the other hand is to clone this jnotebook repo say to /home/me/jnotebook/, copy the jnotebook executable jar to /home/me/jnotebook/. and run ./jnotebook server -cp ... from /home/me/jnotebook/.

Am I missing something?

cyrilou242 commented 5 months ago

Hey, it is caused around here: https://github.com/cyrilou242/jnotebook/blob/5bc96ceeff374b5db879e33f42c20a67c616e98c/jnotebook-core/src/main/java/tech/catheu/jnotebook/server/HtmlTemplateEngine.java#L33

Because the RUN_IN_JAR (https://github.com/cyrilou242/jnotebook/blob/5bc96ceeff374b5db879e33f42c20a67c616e98c/jnotebook-core/src/main/java/tech/catheu/jnotebook/utils/JavaUtils.java#L14) is not correct in the if/else above.

I'll fix this. In the meantime you can do:

curl -Ls https://get.jnotebook.catheu.tech -o jnotebook.jar
chmod +x jnotebook.jar
./jnotebook.jar server