java - What could cause InvocationTargetException and ClassCastException: -
i have fxml interface: sample.fxm
l controlled samplecontroller.java
, displays 3 textfields , it's supposed add data database, yet i'm facing 2 exceptions, 1 invocationtargetexception , other classcastexception, i'll post log below.
ps: in controller class, i'm initializing problem
object defined in entity package, along dao containing add method.
sample.fxml : http://pastebin.com/yvc2zuvg
problemdao.java :http://pastebin.com/gufb3jnd
problem: http://pastebin.com/4xeksznw
samplecontroller.java :
package gui; import entity.problem; import dao.problemdao; import java.net.url; import java.sql.date; import java.text.dateformat; import java.text.simpledateformat; import java.util.calendar; import java.util.resourcebundle; import javafx.event.actionevent; import javafx.fxml.fxml; import javafx.fxml.initializable; import javafx.scene.control.button; import javafx.scene.control.*; /** * fxml controller class * * @author h4dh */ public class samplecontroller implements initializable { @fxml private button btnajout; @fxml private textfield txtdescription; @fxml private textfield txttitre; @fxml private textfield txtmotcles; @fxml public void method(actionevent e) { //txtdescription.settext("hello"); string titre=txttitre.gettext(); string description=txtdescription.gettext(); string motcles=txtmotcles.gettext(); if(!titre.isempty() && !description.isempty() && !motcles.isempty()) //date date, string description, int id_membre, string titre { problem b = new problem (null,description,1,titre); problemdao problemdao = new problemdao(); problemdao.add(b); } } @override public void initialize(url url, resourcebundle rb) { // todo } }
and output log :
exception in thread "javafx application thread" java.lang.runtimeexception: java.lang.reflect.invocationtargetexception @ javafx.fxml.fxmlloader$methodhandler.invoke(fxmlloader.java:1774) @ javafx.fxml.fxmlloader$controllermethodeventhandler.handle(fxmlloader.java:1657) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(compositeeventhandler.java:86) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:238) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:191) @ com.sun.javafx.event.compositeeventdispatcher.dispatchbubblingevent(compositeeventdispatcher.java:59) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:58) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.eventutil.fireeventimpl(eventutil.java:74) @ com.sun.javafx.event.eventutil.fireevent(eventutil.java:49) @ javafx.event.event.fireevent(event.java:198) @ javafx.scene.node.fireevent(node.java:8411) @ javafx.scene.control.button.fire(button.java:185) @ com.sun.javafx.scene.control.behavior.buttonbehavior.mousereleased(buttonbehavior.java:182) @ com.sun.javafx.scene.control.skin.behaviorskinbase$1.handle(behaviorskinbase.java:96) @ com.sun.javafx.scene.control.skin.behaviorskinbase$1.handle(behaviorskinbase.java:89) @ com.sun.javafx.event.compositeeventhandler$normaleventhandlerrecord.handlebubblingevent(compositeeventhandler.java:218) @ com.sun.javafx.event.compositeeventhandler.dispatchbubblingevent(compositeeventhandler.java:80) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:238) @ com.sun.javafx.event.eventhandlermanager.dispatchbubblingevent(eventhandlermanager.java:191) @ com.sun.javafx.event.compositeeventdispatcher.dispatchbubblingevent(compositeeventdispatcher.java:59) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:58) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.basiceventdispatcher.dispatchevent(basiceventdispatcher.java:56) @ com.sun.javafx.event.eventdispatchchainimpl.dispatchevent(eventdispatchchainimpl.java:114) @ com.sun.javafx.event.eventutil.fireeventimpl(eventutil.java:74) @ com.sun.javafx.event.eventutil.fireevent(eventutil.java:54) @ javafx.event.event.fireevent(event.java:198) @ javafx.scene.scene$mousehandler.process(scene.java:3757) @ javafx.scene.scene$mousehandler.access$1500(scene.java:3485) @ javafx.scene.scene.impl_processmouseevent(scene.java:1762) @ javafx.scene.scene$scenepeerlistener.mouseevent(scene.java:2494) @ com.sun.javafx.tk.quantum.glassvieweventhandler$mouseeventnotification.run(glassvieweventhandler.java:352) @ com.sun.javafx.tk.quantum.glassvieweventhandler$mouseeventnotification.run(glassvieweventhandler.java:275) @ java.security.accesscontroller.doprivileged(native method) @ com.sun.javafx.tk.quantum.glassvieweventhandler.lambda$handlemouseevent$355(glassvieweventhandler.java:388) @ com.sun.javafx.tk.quantum.quantumtoolkit.runwithoutrenderlock(quantumtoolkit.java:389) @ com.sun.javafx.tk.quantum.glassvieweventhandler.handlemouseevent(glassvieweventhandler.java:387) @ com.sun.glass.ui.view.handlemouseevent(view.java:555) @ com.sun.glass.ui.view.notifymouse(view.java:937) @ com.sun.glass.ui.win.winapplication._runloop(native method) @ com.sun.glass.ui.win.winapplication.lambda$null$149(winapplication.java:191) @ java.lang.thread.run(thread.java:745) caused by: java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ sun.reflect.misc.trampoline.invoke(methodutil.java:71) @ sun.reflect.generatedmethodaccessor1.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ sun.reflect.misc.methodutil.invoke(methodutil.java:275) @ javafx.fxml.fxmlloader$methodhandler.invoke(fxmlloader.java:1769) ... 56 more caused by: java.lang.classcastexception: java.util.date cannot cast java.sql.date @ gui.samplecontroller.method(samplecontroller.java:43) ... 66 more build successful (total time: 6 seconds)
you have java.sql.date instead of java.util.date. remove import of first in samplecontroller.java , import java.util.date instead.
Comments
Post a Comment