B4J Question Jetty Server 12.1

hatzisn

Expert
Licensed User
Longtime User
Deal all or @Erel,

As I am losing money right now, because I cannot get to the market with an end of life Jetty Server, which I will be forced to replace and maybe change also my code later, I uploaded to ChatGPT the files of java code in the GitHub of Anywhere Software for Server and also the programming documentation of jetty server 12.1. It processed it thoroughly, made the necessary changes and it gave me back four of the files changed with the new requirements. I am not familiar with Eclipse nor do I know how to check it myself if it compiles and works correctly. Is anyone of you available and capable to check if it compiles? The code is in the attached zip file (the jetty12_1_... from chatgpt contains also the migration procedure).

Here is what ChatGPT wrote at the end:

I updated the Jetty-facing files from your uploaded set, especially JServlet, ServerWrapper, WebSocket, and WebSocketModule .

Main changes follow Jetty 12.1’s EE11 split: org.eclipse.jetty.ee11.servlet.*, org.eclipse.jetty.ee11.websocket.server.*, Handler.Sequence, server-level request logging, and Jakarta Servlet multipart Part handling. Jetty’s docs show EE11 servlet artifact/package usage and ServletContextHandler setup, plus Handler.Sequence and the Jetty WebSocket servlet pattern.

I could not compile-test because the sandbox lacks the B4X/AnywhereSoftware and Jetty jar dependencies.



Thanks in advance
 

Attachments

  • jetty12_1_updated_sources.zip
    21.6 KB · Views: 23
Last edited:

tchart

Well-Known Member
Licensed User
Longtime User
Deal all or @Erel,

As I am losing money right now, because I cannot get to the market with an end of life Jetty Server, which I will be forced to replace and maybe change also my code later, I uploaded to ChatGPT the files of java code in the GitHub of Anywhere Software for Server and also the programming documentation of jetty server 12.1. It processed it thoroughly, made the necessary changes and it gave me back four of the files changed with the new requirements. I am not familiar with Eclipse nor do I know how to check it myself if it compiles and works correctly. Is anyone of you available and capable to check if it compiles? The code is in the attached zip files (the jetty12_1_... from chatgpt contains also the migration procedure).

Thanks in advance
@hatzisn i have similar issues with you.

I tried to port Jetty 12 over December but didn’t get anywhere

I have wrapped Undertow as an alternative. I’ve made the API as close as possible to jserver. I will post it here this weekend.



The only reason I haven’t released it is because of the threading model it can’t be used in debug mode :(

Also the latest version of undertow doesn’t work with Java 11
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
@hatzisn i have similar issues with you.

I tried to port Jetty 12 over December but didn’t get anywhere

I have wrapped Undertow as an alternative. I’ve made the API as close as possible to jserver. I will post it here this weekend.



The only reason I haven’t released it is because of the threading model it can’t be used in debug mode :(

Also the latest version of undertow doesn’t work with Java 11

Thank you for the reply... I have removed my file and kept only the original downloaded from ChatGPT. I also added in the original post what the ChatGPT reported. Can you check if it compiles?
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User

Thanks for this. For now I will try to stick with Jetty Server. When you have time, please try to compile it and let me know if it works ok...
Also, I have removed my file from the first post and kept only the original downloaded from ChatGPT. I also added in the first post what the ChatGPT reported. I am rewritting it in order to be sure you have seen what ChatGPT reports.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Here is my trial. ChatGPT did make many mistakes (mixing Jetty 11 and Jetty 12 java code which failed compiling). In Jetty 12 they completely have rewritten WebSockets. Unzip it in libraries (it creates a folder jServer12.1.10) and the library jServer12.1.10.jar and jServer12.1.10.xml.


This is the first project after my brain surgery, so use carefully :cool:

Note: Needs Java 17+

EDIT Updated it to c3p0-0.14.1 and mchange-commons-java-0.6.1
 
Last edited:
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Here is my trial. ChatGPT did make many mistakes (mixing Jetty 11 and Jetty 12 java code which failed compiling). In Jetty 12 they completely have rewritten WebSockets. Unzip it in libraries (it creates a folder jServer12.1.10) and the library jServer12.1.10.jar and jServer12.1.10.xml.


This is the first project after my brain surgery, so use carefully :cool:

Note: Needs Java 17

Great work @alwaysbusy. You have got too much further than me.
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Thanks for this. For now I will try to stick with Jetty Server.
No problem. Like I said it’s not for everyone. My experience with Undertow has been very positive but the lack of debugging is problematic.

I hope the members in here get Jetty 12 working so that we have more options 🍀
 
Upvote 0

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
B4X:
    ws = WebSocket1
    Dim MaxSize As Long = 5 * 1024 * 1024 '
    Dim jo As JavaObject = ws
    jo = jo.GetFieldJO("session").RunMethod("getPolicy", Null)
    jo.RunMethod("setMaxTextMessageSize", Array(MaxSize))

Error:
java.lang.RuntimeException: Method: getPolicy not found in: org.eclipse.jetty.websocket.common.WebSocketSession
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:390)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:140)
at com.appweb.luzhor.jhr.iniciowebpagews$ResumableSub_WebSocket_Connected.resume(iniciowebpagews.java:6360)
at com.appweb.luzhor.jhr.iniciowebpagews._websocket_connected(iniciowebpagews.java:6314)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:117)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:104)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:236)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:121)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:183)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:117)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:104)
at com.appweb.luzhor.jhr.main.main(main.java:29)
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
GetPolicy() is completely removed from Jetty 12. setMaxTextMessageSize is directly on the session object.

B4X:
Dim MaxSize As Long = 5 * 1024 * 1024
Dim jo As JavaObject = ws

Dim session As JavaObject = jo.GetFieldJO("session")

session.RunMethod("setMaxTextMessageSize", Array(MaxSize))
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
No problem. Like I said it’s not for everyone. My experience with Undertow has been very positive but the lack of debugging is problematic.

I hope the members in here get Jetty 12 working so that we have more options 🍀

@alwaysbusy has achieved making Jetty 12 working. In this post.
 
Upvote 0

zhangbao

Member
Debugging is normal, but there is an error in building the independent software packagedebug ok ,build standalone package
B4X:
B4JPackager11 Version 1.50
Exe name: FFHZB.exe
build folder: G:\B4X\FFHZB~1\Objects\temp\build
InputJar: G:\B4X\FFHZB(20260522)\Objects\FFHZB.jar
Running: G:\B4X\FFHZB~1\Objects\temp\FindDosPath.exe
Running: D:\Program Files\jdk-19.0.2\bin\jar
Non-UI program
Package name: b4j.example
Running: D:\Program Files\jdk-19.0.2\bin\jdeps
Exception in thread "main" java.lang.module.FindException: Module org.eclipse.jetty.http2.hpack not found, required by org.eclipse.jetty.http2.common
    at java.base/java.lang.module.Resolver.findFail(Resolver.java:892)
    at java.base/java.lang.module.Resolver.resolve(Resolver.java:192)
    at java.base/java.lang.module.Resolver.resolve(Resolver.java:141)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:420)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:254)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:564)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:604)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:558)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:534)
    at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:50)
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Debugging is normal, but there is an error in building the independent software packagedebug ok ,build standalone package
B4X:
B4JPackager11 Version 1.50
Exe name: FFHZB.exe
build folder: G:\B4X\FFHZB~1\Objects\temp\build
InputJar: G:\B4X\FFHZB(20260522)\Objects\FFHZB.jar
Running: G:\B4X\FFHZB~1\Objects\temp\FindDosPath.exe
Running: D:\Program Files\jdk-19.0.2\bin\jar
Non-UI program
Package name: b4j.example
Running: D:\Program Files\jdk-19.0.2\bin\jdeps
Exception in thread "main" java.lang.module.FindException: Module org.eclipse.jetty.http2.hpack not found, required by org.eclipse.jetty.http2.common
    at java.base/java.lang.module.Resolver.findFail(Resolver.java:892)
    at java.base/java.lang.module.Resolver.resolve(Resolver.java:192)
    at java.base/java.lang.module.Resolver.resolve(Resolver.java:141)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:420)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:254)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:564)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:604)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:558)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:534)
    at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:50)

If it is not in there then you can go to jetty server site in downloads and download the compressed file. All binaries are in the folder bin. There is though in the compressed file of @alwaysbusy the jetty-http2-hpack-12.1.10.jar.

Also in the library xml there is this:

B4X:
<dependsOn>jserver12.1.10/jetty-http2-hpack-12.1.10</dependsOn>
 
Upvote 0
Top