B4J Question ZXing QR lib. problem with standalone package

Mostez

Well-Known Member
Licensed User
Longtime User
I'm using ZXing library to generate QR code on socket server page, the code runs OK in debug or release mode, but when I generate standalone package I get this error:
any ideas how to fix that?
TIA
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
at b4j/anywheresoftware.b4a.BA$3.run(Unknown Source)
at b4j/anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(Unknown Source)
at b4j/anywheresoftware.b4a.StandardBA.startMessageLoop(Unknown Source)
at b4j/anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(Unknown Source)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
at b4j/com.google.zxing.qrcode.encoder.Encoder.chooseMode(Unknown Source)
at b4j/com.google.zxing.qrcode.encoder.Encoder.encode(Unknown Source)
at b4j/com.google.zxing.qrcode.QRCodeWriter.encode(Unknown Source)
at b4j/com.puterise.zxing.createQRImage(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at b4j/anywheresoftware.b4j.object.JavaObject.RunMethod(Unknown Source)
at b4j/com.puterise.zxing._qrcode(Unknown Source)
at b4j/etime.server2.qrlogin._vvvvvvvvvvvvvv3(Unknown Source)
at b4j/etime.server2.qrlogin$ResumableSub_Upload_Click.resume(Unknown Source)
at b4j/anywheresoftware.b4a.BA.checkAndRunWaitForEvent(Unknown Source)
... 10 more
Caused by: java.nio.charset.UnsupportedCharsetException: EUC_JP
at java.base/java.nio.charset.Charset.forName(Unknown Source)
at b4j/com.google.zxing.common.StringUtils.<clinit>(Unknown Source)
... 23 more
B4X:
private Sub GenerateQR(Val As String,QRname As String)   
    'Val is the QR string,
    'QRname is the qr generated image name, we need that to delete if exists
    
    Dim img As String = File.Combine(Main.AssetFolder, "qrlogin")
    Dim generate As ZXing

    generate.Initialize
    
        File.Delete(img, $"${QRname}.png"$)
        generate.QrCode(Val, 256, File.Combine(img, $"${QRname}.png"$), "png")
        'set HTML of image <dev> on page
        Dim Html As String = $"<img id="qrimg" src="${QRname}.png" title="qrcode" width="256" height="256"/>
                            <style > #qrimg {
                              margin-top: 5px;
                              border: 1px solid #CCC;
                               border-radius: 1em;
                                                 }
                                </style>     
                            "$
        devqrcodeimg.SetHtml(Html)
        ws.Flush
    
End Sub
 

teddybear

Well-Known Member
Licensed User
You need to add the packager properties
B4X:
#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.http2.hpack.HpackFieldPreEncoder, org.eclipse.jetty.http.Http1FieldPreEncoder;
#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
 
Upvote 0

Mostez

Well-Known Member
Licensed User
Longtime User
You need to add the packager properties
I included these two properties already:
B4X:
    #PackagerProperty: AdditionalModuleInfoString = uses org.eclipse.jetty.websocket.common.RemoteEndpointFactory;
    #PackagerProperty: IncludedModules = jdk.crypto.ec
then I included all of the properties you've recommended, I also modified the code according to @Erel's recommendations here, but still get the error
 
Upvote 0

Mostez

Well-Known Member
Licensed User
Longtime User

Attachments

  • Image1.jpg
    Image1.jpg
    40.7 KB · Views: 88
Upvote 0
Top