POJO / DTO类不会加载到我的javafx RMI项目中

时间:2018-01-24 15:10:23

标签: hibernate javafx netbeans runtimeexception

我正在开发JavaFx RMI-远程方法调用,以及#34;图书馆管理系统。"。我使用Hibernate。那里有3个项目,LMS-Client,LMS-Common,LMS-Server。

我有FXML视图文件,AdministratorAddBookController.fxml。在那里,当我点击保存按钮使用休眠保存书籍详细信息到我的数据库,但BookDTO不加载。任何必需的库也在项目库中。

这是错误,

xception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
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:8413)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
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 javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
... 48 more
  

这是我的AdministratorAddBook.fxml

//=============================
private final boolean update = false;

/**
 * Initializes the controller class.
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}

@FXML
private void btnSaveBookAction(ActionEvent event) {

   // JOptionPane.showMessageDialog(null, "btnSaveBookAction");

    String condition = "" + cmbCondition.getSelectionModel();
    String format = "" + cmbFormat.getSelectionModel();

    lk.ijse.lms.dto.BookDTO book = new lk.ijse.lms.dto.BookDTO(
            Integer.parseInt(txtBookAccessionNo.getText()),
            txtDate.getText(),
            txtLanguage.getText(),
            txtEdition.getText(),
            txtAuthor_1.getText(),
            txtAuthor_2.getText(),
            txtAuthor_3.getText(),
            txtAuthor_4.getText(),
            txtBookTitle.getText(),
            txtSubTitle.getText(),
            txtYear.getText(),
            txtPublisher.getText(),
            txtPublisherPlace.getText(),
            Integer.parseInt(txtPages.getText()),
            txtSubject.getText(),
            condition,
            format,
            txtBillNo.getText(),
            txtBillDate.getText(),
            Double.parseDouble(txtPrice.getText()),
            txtNote.getText()
    );

    try {

        boolean result = false;

        if (!update) {
            result = lk.ijse.lms.controller.ManageBookController.addBook(book);
        } else {
            result = ManageBookController.updateBook(book);
        }

        if (result) {
            JOptionPane.showMessageDialog(null, "Book has been saved successfully");
        } else {
            JOptionPane.showMessageDialog(null, "Failed to save the book");
        }

    } catch (Exception ex) {
        Logger.getLogger(AdministratorAddBookController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

}

  

这是ManageBookController.class的addBook()方法。

public static boolean addBook(BookDTO bookDTO) throws Exception{
    BookService bookService=(BookService) ProxyHandler.getInstance().getService(ServiceFactory.ServiceTypes.BOOK);
    return bookService.addBook(bookDTO);        
}  

任何必需的库也有项目库,但为什么会出现这个错误?请帮我。我是javafx和hibernate的新人。

谢谢!

0 个答案:

没有答案