Jetty 10 still has the concept of a WebSocketServlet.
But it's no longer generic and functions for all implementations/apis.

With that said, you appear to be using the Jetty implementation/apis.
So, switch to `org.eclipse.jetty.websocket.server.JettyWebSocketServlet`
instead.

Found in websocket-jetty-server.jar
See:
https://search.maven.org/search?q=fc:org.eclipse.jetty.websocket.server.JettyWebSocketServlet

JSON classes were moved out from jetty-util to jetty-util-ajax back in
Jetty 9.0.0
You can find it at `org.eclipse.jetty.util.ajax.JSON`
See: https://search.maven.org/search?q=fc:org.eclipse.jetty.util.ajax.JSON

Note: that the static method JSON.parse(String) doesn't exist in Jetty 10.
The static methods on JSON couldn't handle the various configurations for
collections/maps/lists/pojos etc.
And the error messages were woefully inadequate as a result.

So you'll need to change your usage a small bit.
The closest usage would be ...
JSON json = new JSON();
// configure json here
Map<String, String> myMap = (Map<String, String>) json.fromJSON(str);






Joakim Erdfelt / joa...@webtide.com


On Tue, Aug 31, 2021 at 9:36 AM Alexander Farber <alexander.far...@gmail.com>
wrote:

> Hello,
>
> I am trying to migrate a war servlet from 9.4.43.v20210629 to 10.0.6 and
> have read
>
> https://www.eclipse.org/jetty/documentation/jetty-10/programming-guide/index.html#pg-migration-94-to-10
>
> But unfortunately I still have questions - in my servlet I have:
>
> public class MyServlet extends WebSocketServlet {
>     @Override
>     public void configure(WebSocketServletFactory factory) {
>         mLanguage = System.getenv("COUNTRY");
>         mBundle = ResourceBundle.getBundle("strings",
> LOCALES.get(mLanguage));
>         factory.getPolicy().setIdleTimeout(IDLE_TIMEOUT_SECONDS * 1000);
>         factory.getPolicy().setMaxBinaryMessageSize(0);
>         factory.getPolicy().setMaxTextMessageSize(64 * 1024);
>         factory.register(MyListener.class);
>         factory.setCreator(new MyCreator(this,
> mBundle.getString(STR_DATABASE_URL)));
>     }
>     @Override
>     protected void doGet(HttpServletRequest httpReq, HttpServletResponse
> httpResp) throws ServletException, IOException {
>        // ....
>     }
> }
>
> What is the class to use in Jetty 10 instead of WebSocketServlet?
>
> Also, I use the following code in few spots to parse JSON strings:
>
>         Map<String, String> myMap = (Map<String, String>) JSON.parse(str);
>
> but now I get the compile error: String cannot be converted to Source
>
> Is there a new parser, should I maybe use AsyncJSON and how?
>
> Best regards
> Alex
>
>
>
> _______________________________________________
> jetty-users mailing list
> jetty-users@eclipse.org
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
jetty-users@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to