B4J Library jServer (5) based on Jetty 12.1

This is a beta version.

Download link:

Copy the files to the internal libraries folder (keep the inner jserver folder). The files are different than jServer(4) files so both will work together.
The library is named jServer5. It will be renamed to jServer with the next release of B4J.

Java 17+ is required.

There is a new optional event for WebSocket handlers:
B4X:
'Return False to reject the upgrade request.
Private Sub WebSocket_Upgrade (UpgradeRequest As ServletRequest) As Boolean
    Return True
End Sub
You can use it to create a http session and to reject upgrade requests.

WebSocket.Flush is no longer needed and the method doesn't do anything.

If you used JavaObject to access Jetty APIs then they might need to be updated. Other than that, existing projects should work with no changes.

Standalone package declarations:
B4X:
#PackagerProperty: AdditionalModuleInfoString = provides org.slf4j.spi.SLF4JServiceProvider with org.eclipse.jetty.logging.JettyLoggingServiceProvider;
#PackagerProperty: AdditionalModuleInfoString = exports anywheresoftware.b4j.object;
#PackagerProperty: AdditionalModuleInfoString = provides org.eclipse.jetty.io.ssl.ALPNProcessor.Server with org.eclipse.jetty.alpn.java.server.JDK9ServerALPNProcessor;
#PackagerProperty: AdditionalModuleInfoString = provides org.eclipse.jetty.http.HttpFieldPreEncoder with org.eclipse.jetty.http.Http10FieldPreEncoder, org.eclipse.jetty.http.Http11FieldPreEncoder;
#PackagerProperty: AdditionalModuleInfoString = uses org.eclipse.jetty.util.security.CredentialProvider;
#PackagerProperty: AdditionalModuleInfoString = uses org.eclipse.jetty.io.ssl.ALPNProcessor.Server;
#PackagerProperty: IncludedModules = jdk.charsets, jdk.crypto.ec
#CustomBuildAction: After Packager, %WINDIR%\System32\robocopy.exe, www temp\build\bin\www /E

v5.02 - Fixes the debugger issue with WebSockets and filters. Thank you @Chris2 for the detailed report.
 
Last edited:

Chris2

Well-Known Member
Licensed User
Longtime User
j.GetRequest.SetContentType("application/octet-stream") '<----
Just going back to this addition to SendJob in the DBRequestManager class, am I correct to say that this is backward compatible in that adding it won't do any harm when connecting to jServer 4
I can't see any issues under testing but though I'd check.
 

aeric

Expert
Licensed User
Longtime User
1785440235174.png

Hi Erel, please update the link. Thanks.
 

teddybear

Well-Known Member
Licensed User
A trivial bug related to Http2Enabled: when set to true, the browser receives ERR_HTTP2_PROTOCOL_ERROR.
The issue occurs because, when #MergeLibraries: True, the org.eclipse.jetty.http2.hpack.HpackFieldPreEncoder is missing from
META-INF\services\org.eclipse.jetty.http.HttpFieldPreEncoder inside the merged JAR.
My fix is to add it to jetty-http-12.1.10.jar.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
jWebSocketClient v2.50 was added to the zip. This is the client WebSocket implementation based on Jetty 12.

https://www.b4x.com/b4j/files/jserver5.zip

For standalone packages:
B4X:
#PackagerProperty: AdditionalModuleInfoString = provides org.slf4j.spi.SLF4JServiceProvider with org.eclipse.jetty.logging.JettyLoggingServiceProvider;
#PackagerProperty: AdditionalModuleInfoString = uses org.eclipse.jetty.compression.Compression;
#PackagerProperty: AdditionalModuleInfoString = exports anywheresoftware.b4j.object;
#PackagerProperty: IncludedModules = jdk.charsets, jdk.crypto.ec


Note that jServer5 was renamed to jServer as this becomes the default version. The current jServer will be renamed to jServer4.
 
Last edited:

Alessandro71

Well-Known Member
Licensed User
Longtime User
The current jServer will be renamed to jServer4.
so it will remain available in the next B4J version and those unable to update should only deselect jServer in Libraries tab and select jServer4?
is this correct?
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
Yes*
* - you will need to download it separately.

With that said, there is no reason not to upgrade.
no reason except time, since it's simultaneous with SDK36 (not related at all, except human bottleneck)
 

Chris2

Well-Known Member
Licensed User
Longtime User
jWebSocketClient v2.50 was added to the zip. This is the client WebSocket implementation based on Jetty 12.
If you used JavaObject to access Jetty APIs then they might need to be updated.
I've found that the existing Accept All Certificates code needs a line changed for for Jetty 12:
B4X:
'change'
HttpTransport.InitializeNewInstance("org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic", Array(ClientConnector, Infos))
'to...'
HttpTransport.InitializeNewInstance("org.eclipse.jetty.client.transport.HttpClientTransportDynamic", Array(ClientConnector, Infos))
The jetty.org site seems to be down at the moment so I couldn't access the migration document they have - I got the new location of HttpClientTransportDynamic from Claude AI.

I've started a thread to house this type of API change - https://www.b4x.com/android/forum/t...rver-4-jetty-11-to-jserver-5-jetty-12.171805/
 
Top