Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stock guestbook app crashes when running as uberjar #133

Closed
philipmw opened this issue Feb 21, 2024 · 8 comments
Closed

Stock guestbook app crashes when running as uberjar #133

philipmw opened this issue Feb 21, 2024 · 8 comments

Comments

@philipmw
Copy link
Contributor

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
Copy link
Contributor Author

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

pom.xml.txt

@gerdint
Copy link
Contributor

gerdint commented Feb 21, 2024 via email

@markokocic
Copy link
Member

markokocic commented Feb 21, 2024

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
Copy link
Collaborator

yogthos commented Feb 21, 2024

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

@markokocic
Copy link
Member

I already committed the fix directly to master 1249b3f

@yogthos
Copy link
Collaborator

yogthos commented Feb 21, 2024

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

@philipmw
Copy link
Contributor Author

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

Does Kit support merging updates to templates into existing apps?

@markokocic
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants