perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.64k stars 1.56k forks source link

Websocket HowTo seems to be outdated... #957

Closed neilyoung closed 6 years ago

neilyoung commented 6 years ago

Well... sort of.

I'm referring to the Websocket part here:

http://sparkjava.com/documentation#websockets

The strange thing: Everything works as expected, if I create a JAR containing this snippet.

But once I obfuscate it using proguard I'm getting this at runtime:

Exception in thread "main" java.lang.IllegalArgumentException: WebSocket handler must implement 'WebSocketListener' or be annotated as '@WebSocket'
    at spark.embeddedserver.jetty.websocket.WebSocketHandlerWrapper.validateHandlerClass(WebSocketHandlerWrapper.java:22)
    at spark.embeddedserver.jetty.websocket.WebSocketHandlerClassWrapper.<init>(WebSocketHandlerClassWrapper.java:11)
    at spark.Service.webSocket(Service.java:301)
    at spark.Spark.webSocket(Spark.java:1138)
    at com.myCompany.myProject.f.<init>(Unknown Source)
    at com.myCompany.myProject.MainApp.<init>(Unknown Source)
    at com.myCompany.myProject.MainApp.main(Unknown Source)

I had no choice, I had to (slightly) refactor my code in order to implement WebsocketListener instead to overcome this.

Gillingham commented 6 years ago

Verify your obfuscator isn't removing or changing the decorator. If the jar works before you change it, the problem is in your obfuscator.

neilyoung commented 6 years ago

Hehe, I can't even remember to have had this kind of problem. Too long ago :) Thanks anyway

Gillingham commented 6 years ago

You should probably close it then