B4J Question (Solved) Dim job as Httpjob causes runtime error

johnerikson

Active Member
Licensed User
Longtime User
Dim job as Httjob causes error on runtime!
I don't understand what's going wrong!

B4X:
Sub UpdateIp_Tick()
    Dim job As HttpJob
    job.Initialize("", Me)    'Error occurred on line: 168 (Main) java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/scene/control/Dialog
    job.Download2("http://www.duckdns.org/update", Array As String("domains", domain, "token", token, "ip", ""))
    wait for (job) JobDone(job As HttpJob)
    If job.Success = True Then
        Log("Update DuckDNS: " & job.GetString)
    Else
        Log("Error updating Duck DNS: " & job.ErrorMessage)
    End If
    job.Release
End Sub

Is it a java related error or what else?
I use Java 11.0.1 and B4j 10.0


The beginning of error massage......

Error occurred on line: 168 (Main)
java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/scene/control/Dialog
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:140)
at b4j.example.httpjob.innerInitialize(httpjob.java:22)
at b4j.example.httpjob._initialize(httpjob.java:199)
at Geo.EasyMedia.main$ResumableSub_UpdateIp_Tick.resume(main.java:322)
at Geo.EasyMedia.main._updateip_tick(main.java:296)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 

drgottjr

Expert
Licensed User
Longtime User
Error occurred on line: 168 (Main)

line 168 in main.java? or line 168 in the ide?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Are you using Dialog in a non UI app?

The error seems to imply you have a non-UI app and trying to display a dialog box (Don't think non UI can do that unless you use AWT/Swing components)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I don't understand what's going wrong!
We either. The code you posted CAN NOT raise the error you posted!

Create a small project showing the problem. Upload the project.
 
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
This is a non UI project.
Before previous versions, I haven't used 'Wait for' and it has worked.
Notice that the line number I entered is from the IDE

In the attached project code below, I get the same error. I've downloaded Java 14, but don't get any changes.
What to do?

B4X:
'Non-UI application (console / server application)

#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Private updateIp As Timer
    Private domain As String = "Pelle"
    Private token As String = "00000-00000-00000"

End Sub

Sub AppStart (Args() As String)
    Log("Hello world!")
    
    ' Timer för Duckdns
    updateIp.Initialize("UpdateIp", 10 * 60 * 1000) '10 minutes
    updateIp.Enabled = True
    UpdateIp_Tick
    StartMessageLoop

End Sub

Sub UpdateIp_Tick()
    
    Dim job As HttpJob
    job.Initialize("", Me)
    job.Download2("http://www.duckdns.org/update", Array As String("domains", domain, "token", token, "ip", ""))
    wait for (job) JobDone(job As HttpJob)
    If job.Success = True Then
        Log("Update DuckDNS: " & job.GetString)
    Else
        Log("Error updating Duck DNS: " & job.ErrorMessage)
    End If
    job.Release
End Sub
 
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
I don't understand what you mean by reference to Dialog?
This is a major ABMaterial project references. They could be features of ABMaterial you mean.

However, the code that I sent earlier today causes the same error that has
no references to dialog library at all only jCore and jHTTP, try it!


Regarding Updateip_tick called here in the tests to avoid waiting 10 min after starting, does not affect the problem.

Has anyone tried the code? For checking if the same error occurs for everyone!
 
Last edited:
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
Thank you for that! That's good to know!

I feel right now that I don't know how to move forward with the project. I have two computers that I can do tests on, which I have already tried.
I Don't Give Up!
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
I've downloaded Java 14, but don't get any changes.
Did you get Java 14 from here or somewhere else?
It looks like is missing the JavaFX part.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
This is an old library. One should be using OkHttp. jHttp is based on an older version of a Java library that may not be compatible anymore with more modern versions of Java (guess).
 
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User

( Solved ) Dim job as Httpjob causes runtime error​


I started by trying to switch to lib jOkHttp but showed the same error! After researching, it turned out that I had an old httpjob module with source code loaded in the IDE. This project was started 10 years ago. The fact that I had a source code version was not in my memory at all. After removing the module and ticking jOkHttpUtils2 in the Libraries Manager, it all works fine!
I would like to thank everyone involved in the case, otherwise I do not know if I have come to a solution!
 
Upvote 1
Top