ring-clojure / ring

Clojure HTTP server abstraction
MIT License
3.73k stars 518 forks source link

JettyWebSocketServerContainer can not implement WebSocketPolicy because it is not an interface #495

Closed jwr closed 5 months ago

jwr commented 5 months ago

I tried switching my application from ring 1.10.0 to 1.11.0 and I'm getting this error:

#error {                                                                                                               
 :cause class org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer can not implement org.eclipse.jetty.websocket.api.WebSocketPolicy, because it is not an interface (org.eclipse.jetty.websocket.api.WebSocketPolicy is in unnamed module of loader 'app')                                                                                              
 :via                                                   
 [{:type clojure.lang.Compiler$CompilerException                                                                       
   :message Syntax error macroexpanding at (ring/adapter/jetty.clj:1:1).
   :data #:clojure.error{:phase :execution, :line 1, :column 1, :source ring/adapter/jetty.clj}
   :at [clojure.lang.Compiler load Compiler.java 7665]} 
  {:type java.lang.IncompatibleClassChangeError                                                                        
   :message class org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer can not implement org.eclipse.jetty.websocket.api.WebSocketPolicy, because it is not an interface (org.eclipse.jetty.websocket.api.WebSocketPolicy is in un
named module of loader 'app')                                                                                          
   :at [java.lang.ClassLoader defineClass1 ClassLoader.java -2]}]

Not sure what is going on there.

I am using OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1) on MacOS, in case that helps.

weavejester commented 5 months ago

It looks like you have a dependency conflict. You'll want to check your app's dependency tree and see if any dependencies override Ring's Jetty dependencies with an incompatible version.

jwr commented 5 months ago

Indeed — it seems that com.bhauman/figwheel-main and com.cognitect.aws/api (through com.cognitect/http-client) rely on various jetty 9.4.36 variants. Not sure what the right move here is: force the newer version assuming other packages will not break, or stick with ring 1.10.0 for now.

weavejester commented 5 months ago

There's an open issue on the Cognitect AWS-API that has some suggestions on how to deal with this problem: https://github.com/cognitect-labs/aws-api/issues/181

jwr commented 5 months ago

Thanks! I think I'll just stay with ring 1.10.0 for now until things hopefully get resolved.