I have a program that lets users enter in a new patient, edit patient info and schedule appointments. When a user adds a new patient I have a service to see if the mrn for the new patient already exists. If the patient exists then an error will popup informing the end user. The program is running springboot and javafx. I'm using javafx version 19, java version 17 and sdk version 17.
NewPatientController.java
@FXML
public void onSaveNewPatient(ActionEvent event) throws SQLException {
try {
if (patientService.findDistinctByMrn(mrn.getText())) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("MRN Already Exists");
alert.setContentText("This patient's MRN number is already being used by another patient. ");
alert.showAndWait();
}else {
IPatientModel patient = new IPatientModel();
patient.setFirstName(fName.getText());
patient.setLastName(lName.getText());
System.out.println(lName.getText());
patient.setDob(dob.getText());
patient.setMrn(mrn.getText());
patient.setFormerLastName(formerLName.getText());
patient.setPreferredFirstName(preferredName.getText());
patientService.save(patient);
clearFields();
The error is:
java.lang.NoSuchFieldError: DIALOG
at javafx.scene.control.DialogPane.<init>(DialogPane.java:213)
at javafx.scene.control.Dialog.<init>(Dialog.java:512)
at javafx.scene.control.Alert.<init>(Alert.java:247)
at com.example.gaitlabapp.controllers.NewPatientModuleController.onSaveNewPatient(NewPatientModuleController.java:115)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:77)
at jdk.internal.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:275)
at com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1852)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1724)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8923)
at javafx.scene.control.Button.fire(Button.java:203)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)
at com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3894)
at javafx.scene.Scene.processMouseEvent(Scene.java:1887)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2620)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
at com.sun.glass.ui.View.handleMouseEvent(View.java:551)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
From JavaFX 20 to at least JavaFX 24, line 213 of DialogPane
is:
setAccessibleRole(AccessibleRole.DIALOG);
Your error is saying the AccessibleRole.DIALOG
field doesn't exist. That enum constant was added in JavaFX 20. Since DialogPane
is a class from the javafx.controls
module and AccessibleRole
is an enum from the javafx.graphics
module, this indicates you have a version mismatch between those two modules. The former must be version 20 or greater while the latter must be version 19 or lower.
The solution is to make sure all JavaFX modules are the same version and that you only have one copy of each JavaFX module on the class-path/module-path. How exactly you implement that solution depends on information you haven't provided.
As an aside, take note of this comment by @jewelsea:
The stack trace shows that JavaFX is being loaded from the classpath rather than the module path. It is not a supported configuration but could still work unless misconfigured.
Ideally, you should always configure your application to load JavaFX into named modules (i.e., from the module-path), even if your own code is non-modular.