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

Problem passing jetty adapter options as :adapter map using ring by server-headless #206

Open
erkkikeranen opened this issue Feb 21, 2019 · 2 comments

Comments

@erkkikeranen
Copy link

erkkikeranen commented Feb 21, 2019

According to the README you can provide the following as general options to project.clj:

:adapter - A map of options to be passed to the Ring adapter. This has no effect if you're deploying your application as a war-file.

Here's my project.clj

:ring {
  :handler myapp.states.ring/ap
  :adapter {:configurator (ring-jetty-ws.ws/configurator myapp.handlers.ws/ws-handler)}
  :init myapp.core/setup
  :destroy myapp.core/teardown
  :port 3000
  :nrepl {:start? true :port 7000}}

When running with the command lein ring server-headless, jetty starts but doesn't run the configurator so I can't get websocket endpoints/servlets running.

In the compiled artifact everything works when jetty is started as follows:

(run-jetty myapp.states.ring/app
  {:port 3000
   :join? true
   :configurator (ring-jetty-ws.ws/configurator myapp.handlers.ws/ws-handler)})

Maybe I've misunderstood something from the documentation how the :adapter map is supposed to work? Is this working as intended?

@erkkikeranen erkkikeranen changed the title :adapter doesn't seem to pass anything to server-headless :adapter doesn't seem to pass anything as jetty adapter options started by server-headless Feb 21, 2019
@erkkikeranen
Copy link
Author

erkkikeranen commented Feb 21, 2019

some progress (might be that I had a mess in my project or dependencies):

Now it seems to have an effect of having the :adapter map because including it causes:

Exception in thread "main" Syntax error compiling at (/private/var/folders/0y/g6kx6w112zndgv908np1skg43swtbm/T/form-init11360811749677766763.clj:1:126).
	at clojure.lang.Compiler.load(Compiler.java:7647)
	at clojure.lang.Compiler.loadFile(Compiler.java:7573)
	at clojure.main$load_script.invokeStatic(main.clj:452)
	at clojure.main$init_opt.invokeStatic(main.clj:454)
	at clojure.main$init_opt.invoke(main.clj:454)
	at clojure.main$initialize.invokeStatic(main.clj:485)
	at clojure.main$null_opt.invokeStatic(main.clj:519)
	at clojure.main$null_opt.invoke(main.clj:516)
	at clojure.main$main.invokeStatic(main.clj:598)
	at clojure.main$main.doInvoke(main.clj:561)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:705)
	at clojure.main.main(main.java:37)
Caused by: java.lang.ClassCastException: class clojure.lang.PersistentList cannot be cast to class clojure.lang.IFn (clojure.lang.PersistentList and clojure.lang.IFn are in unnamed module of loader 'app')
	at ring.adapter.jetty$run_jetty.invokeStatic(jetty.clj:169)
	at ring.adapter.jetty$run_jetty.invoke(jetty.clj:127)
	at ring.server.standalone$serve$fn__4182.invoke(standalone.clj:103)
	at ring.server.standalone$try_port.invokeStatic(standalone.clj:15)
	at ring.server.standalone$try_port.invoke(standalone.clj:10)
	at ring.server.standalone$serve.invokeStatic(standalone.clj:100)
	at ring.server.standalone$serve.doInvoke(standalone.clj:75)
	at clojure.lang.RestFn.invoke(RestFn.java:423)
	at ring.server.leiningen$serve.invokeStatic(leiningen.clj:19)
	at ring.server.leiningen$serve.invoke(leiningen.clj:16)
	at user$eval37688.invokeStatic(form-init11360811749677766763.clj:1)
	at user$eval37688.invoke(form-init11360811749677766763.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)
	at clojure.lang.Compiler.eval(Compiler.java:7166)
	at clojure.lang.Compiler.eval(Compiler.java:7166)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	... 12 more

Commenting it starts the jetty, but of course does not include websockets.

@erkkikeranen erkkikeranen changed the title :adapter doesn't seem to pass anything as jetty adapter options started by server-headless Problem passing jetty adapter options as :adapter map using ring by server-headless Feb 22, 2019
@weavejester
Copy link
Owner

The data from the :adapter key is just passed verbatim to the adapter. Lein-Ring doesn't currently do anything to evaluate lists or symbols, or require the relevant namespaces.

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

2 participants