kit-clj / kit

Lightweight, modular framework for scalable web development in Clojure
https://kit-clj.github.io/
MIT License
476 stars 44 forks source link

Stock guestbook app crashes when running as uberjar #133

Closed philipmw closed 7 months ago

philipmw commented 7 months ago

I am following the Guestbook tutorial.

I create the app:

% clojure -Tclj-new create :template io.github.kit-clj :name kit/guestbook
Downloading: io/github/kit-clj/lein-template/maven-metadata.xml from clojars
Generating kit project.

I package it:

% clj -Sforce -T:build all
Cleaning target
Writing Pom...
Compiling Clojure...
Making uberjar...

I start it:

% java -jar target/guestbook-standalone.jar
725   INFO  kit.guestbook.env -
-=[guestbook started successfully]=-
726   INFO  kit.config - Reading config system.edn
788   INFO  org.xnio - XNIO version 3.8.8.Final
876   INFO  org.jboss.threads - JBoss Threads version 3.5.0.Final
930   INFO  kit.edge.server.undertow - server started on port 3000

I make a request:

% curl -v http://localhost:3000/api/health
*   Trying [::1]:3000...
* Connected to localhost (::1) port 3000
> GET /api/health HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.4.0
> Accept: */*
>
< HTTP/1.1 500 Internal Server Error
< Connection: keep-alive
< Content-Length: 0
< Date: Wed, 21 Feb 2024 03:15:27 GMT
<
* Connection #0 to host localhost left intact

In the JRE, I see this exception:

11455 ERROR io.undertow.request - UT005071: Undertow request failed HttpServerExchange{ GET /api/health}
java.lang.IllegalArgumentException: No implementation of method: :match-by-path of protocol: #'reitit.core/Router found for class: kit.guestbook.web.handler$fn__11575$router__11577

However, it works fine when started using (go) in the REPL.

I will try to attach target/classes/META-INF/maven/kit/guestbook/pom.xml.

philipmw commented 7 months ago

Github doesn't support XML files, but here it is with the TXT extension.

pom.xml.txt

gerdint commented 7 months ago

May have sth to do with https://github.com/kit-clj/kit/pull/130 I also observed the above error when I manually applied the changes in my current project, but I assumed I did sth wrong and didn't think more about it.

@markokocic?

-Tobias

ons 21 feb. 2024 kl. 04:21 skrev Philip White @.***>:

Github doesn't support XML files, but here it is with the TXT extension.

pom.xml.txt https://github.com/kit-clj/kit/files/14353619/pom.xml.txt

— Reply to this email directly, view it on GitHub https://github.com/kit-clj/kit/issues/133#issuecomment-1955806327, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAADU5TG7MASEG2XLP74RVLYUVR4VAVCNFSM6AAAAABDSIXVQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJVHAYDMMZSG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

markokocic commented 7 months ago

You are right, I pushed a fix to git.

@yogthos , we may need a new release.

@philipmw In the meantime, you can fix the issue by redefining :router/core in handler.clj with the following code:

(defmethod ig/init-key :router/core
  [_ {:keys [routes env] :as opts}]
  (if (= env :dev)
    #(ring/router ["" opts routes])
    (constantly (ring/router ["" opts routes]))))
yogthos commented 7 months ago

Ah ok makes sense, just ping me when you've got a pr up and I can push a release out then.

markokocic commented 7 months ago

I already committed the fix directly to master 1249b3f3e4a9f8c0f28ee5c754edff6b5fb795f0

yogthos commented 7 months ago

Awesome, just pushed out a new template with a fix.

philipmw commented 7 months ago

Thanks -- making the suggested fix manually to my existing app solved the problem.

Does Kit support merging updates to templates into existing apps?

markokocic commented 7 months ago

No. Once the app is generated from the template, only manual changes are possible.