线程错误 - 本地异常堆栈中的异常

时间:2018-03-07 12:35:40

标签: java netbeans

我有一个JFRAME表单,用于在mysql数据库中注册car和stroe信息。
表单包含以下代码:

package parkingSystem;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.persistence.*;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Dennis
 */
public class RegisterCars extends javax.swing.JFrame {

    /**
     * Creates new form RegisterCars
     */
    //Database connection variables
    Connection myConn;
    Statement stmt;
    String sql;
    ResultSet rs;

    public RegisterCars() {
        initComponents();
        try {
            Class.forName("com.mysql.jdbc.Driver"); // 
            myConn = DriverManager.getConnection("jdbc:mysql://localhost/parkingsystem", "root", ""); // 
            stmt = myConn.createStatement();
            loadCars();
        } catch (ClassNotFoundException e) {
            System.out.println("Driver not found" + e.getMessage());
        } catch (SQLException e) {
            System.out.println("Database connection Error:" + e.getMessage());
        }
        System.out.println("DB CONNECTED");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jDesktopPane1 = new javax.swing.JDesktopPane();
        entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("parkingsystem?zeroDateTimeBehavior=convertToNullPU").createEntityManager();
        carsQuery = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT c FROM Cars c");
        carsList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : carsQuery.getResultList();
        jPanel1 = new javax.swing.JPanel();
        lblLogo = new javax.swing.JLabel();
        lblCar = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        lblPlate = new javax.swing.JLabel();
        lblSlot = new javax.swing.JLabel();
        lblClient = new javax.swing.JLabel();
        txfModel = new javax.swing.JTextField();
        txfPlate = new javax.swing.JTextField();
        txfColour = new javax.swing.JTextField();
        cbxRegistered = new javax.swing.JComboBox();
        lblRegistered = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        btnDelete = new javax.swing.JButton();
        btnEdit = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();
        btnShowCars = new javax.swing.JButton();
        btnClose = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setBackground(new java.awt.Color(51, 102, 255));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/parkingSystem/images/jkuat-logo.png"))); // NOI18N
        jPanel1.add(lblLogo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, -1, -1));

        lblCar.setFont(new java.awt.Font("Verdana", 1, 24)); // NOI18N
        lblCar.setForeground(new java.awt.Color(255, 255, 255));
        lblCar.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblCar.setText("CAR REGISTRATION");
        jPanel1.add(lblCar, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 80, 340, 60));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 670, 210));

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblPlate.setText("Plate Number");
        jPanel2.add(lblPlate, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 80, 110, 34));

        lblSlot.setText("Colour");
        jPanel2.add(lblSlot, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, 110, 41));

        lblClient.setText("Model");
        jPanel2.add(lblClient, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 140, 110, 37));

        txfModel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txfModelActionPerformed(evt);
            }
        });
        jPanel2.add(txfModel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 80, 211, 45));

        txfPlate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txfPlateActionPerformed(evt);
            }
        });
        jPanel2.add(txfPlate, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 140, 211, 40));

        txfColour.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txfColourActionPerformed(evt);
            }
        });
        jPanel2.add(txfColour, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 20, 211, 41));

        cbxRegistered.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxRegisteredActionPerformed(evt);
            }
        });
        jPanel2.add(cbxRegistered, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 210, 210, 40));

        lblRegistered.setText("Registered Cars");
        jPanel2.add(lblRegistered, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 210, 90, 35));

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Action"));

        btnDelete.setText("DELETE");
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });

        btnEdit.setText("EDIT");
        btnEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditActionPerformed(evt);
            }
        });

        btnSave.setText("SAVE");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        btnShowCars.setText("Show Registered Cars");
        btnShowCars.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnShowCarsActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(38, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btnShowCars, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(btnSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnDelete, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
                        .addComponent(btnEdit, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(21, 21, 21))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnShowCars, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(19, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 10, 280, 260));

        btnClose.setText("Close");
        btnClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCloseActionPerformed(evt);
            }
        });
        jPanel2.add(btnClose, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 280, 80, 30));

        getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 210, 670, 320));

        setSize(new java.awt.Dimension(685, 569));
        setLocationRelativeTo(null);
    }// </editor-fold>                        

    private void txfModelActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
    }                                        

    private void txfPlateActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
    }                                        

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {                                        
        if (evt.getSource().equals(btnSave)) {
            JOptionPane.showMessageDialog(this, "Successfully Saved Car");
            System.out.println("Saving the new car: ");
            System.out.println(txfModel.getText() + " is now Saved");
            String userInput = txfModel.getText();

            if (userInput.length() > 0) {
                try {
                    String sql = "INSERT INTO cars(model,colour,Plate_number)VALUES('" + txfModel.getText() + "','" + txfColour.getText() + "','" + txfPlate.getText() + "')";
                    System.out.println(sql);
                    stmt.execute(sql);

                    txfModel.setText("");
                    txfColour.setText("");
                    txfPlate.setText("");
                    loadCars();
                } catch (SQLException x) {
                    System.out.println("SQL Error while loading Cars:" + x.getMessage());
                }
            } else {
                System.out.println("You have not entered anything");
            }
        }
        System.out.println("SAVING LOADED");// TODO add your handling code here:
    }                                       

    private void txfColourActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
    }                                         

    private void cbxRegisteredActionPerformed(java.awt.event.ActionEvent evt) {                                              
        // TODO add your handling code here:
    }                                             

    private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {                                        
        if (evt.getSource().equals(btnEdit)) {
            JOptionPane.showMessageDialog(this, "Successfully Edited Car");
            try {
                String carModel = cbxRegistered.getSelectedItem().toString();
                String carColour = cbxRegistered.getSelectedItem().toString();
                String sql = "UPDATE cars SET Plate_number='" + txfPlate.getText() + "' WHERE Plate_number='" + cbxRegistered.getSelectedItem().toString() + "'";
                //String sql2 = "UPDATE cars SET colour='" + txfColour.getText() + "' WHERE Plate_number='" + cbxRegistered.getSelectedItem().toString() + "'";
                //String sql3 = "UPDATE cars SET model='" + txfModel.getText() + "' WHERE Plate_number='" + cbxRegistered.getSelectedItem().toString() + "'";

                stmt.execute(sql);
                //stmt.execute(sql2);
                //stmt.execute(sql3);
                txfPlate.setText("");
                loadCars();
            } catch (SQLException x) {
                System.out.println("Error while editing " + x.getMessage());
            }
        }
        System.out.println("EDIT LOADED");// TODO add your handling code here:
    }                                       

    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {                                          
        if (evt.getSource().equals(btnDelete)) {
            JOptionPane.showMessageDialog(this, "Successfully Deleted Car");
            try {
                String sql = "UPDATE cars SET isactive=0 WHERE Plate_number='" + cbxRegistered.getSelectedItem().toString() + "'";
                stmt.execute(sql);
                txfColour.setText("");
                txfModel.setText("");
                txfPlate.setText("");
                loadCars();
            } catch (SQLException x) {
                System.out.println("Error while deleting a departments:" + x.getMessage());
            }
        }        // TODO add your handling code here:
    }                                         

    private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {                                         
        dispose();        // TODO add your handling code here:
    }                                        

    private void btnShowCarsActionPerformed(java.awt.event.ActionEvent evt) {                                            
        new CarsTable().setVisible(true);        // TODO add your handling code here:
    }                                           
    private void loadCars() {
        try {
            cbxRegistered.removeAllItems();
            System.out.println("Loading saved cars");
            String sql;
            sql = "SELECT * FROM cars WHERE isactive = 1";
            System.out.println(sql);
            rs = stmt.executeQuery(sql);
            while (rs.next()) {
                cbxRegistered.addItem(rs.getString("Plate_number"));
            }
        } catch (SQLException x) {
            System.out.println("SQL Error while loading cars: " + x.getMessage());
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(RegisterCars.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(RegisterCars.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(RegisterCars.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(RegisterCars.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new RegisterCars().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton btnClose;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnEdit;
    private javax.swing.JButton btnSave;
    private javax.swing.JButton btnShowCars;
    private java.util.List<parkingSystem.Cars> carsList;
    private javax.persistence.Query carsQuery;
    private javax.swing.JComboBox cbxRegistered;
    private javax.persistence.EntityManager entityManager;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JLabel lblCar;
    private javax.swing.JLabel lblClient;
    private javax.swing.JLabel lblLogo;
    private javax.swing.JLabel lblPlate;
    private javax.swing.JLabel lblRegistered;
    private javax.swing.JLabel lblSlot;
    private javax.swing.JTextField txfColour;
    private javax.swing.JTextField txfModel;
    private javax.swing.JTextField txfPlate;
    // End of variables declaration                   
}

----------获得以下输出--------

Exception in thread "AWT-EventQueue-0" Local Exception Stack: 
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@42a57993
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [parkingsystem?zeroDateTimeBehavior=convertToNullPU] failed.
Internal Exception: Exception [EclipseLink-7155] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The type [class javax.swing.JLabel] for the attribute [jLabel2] on the entity class [class parkingSystem.RegisterDepartments] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface.
    at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
    at parkingSystem.RegisterCars.initComponents(RegisterCars.java:54)
    at parkingSystem.RegisterCars.<init>(RegisterCars.java:30)
    at parkingSystem.loggedInAdmin.lblCarsMousePressed(loggedInAdmin.java:239)
    at parkingSystem.loggedInAdmin.access$400(loggedInAdmin.java:14)
    at parkingSystem.loggedInAdmin$5.mousePressed(loggedInAdmin.java:180)
    at java.awt.Component.processMouseEvent(Component.java:6530)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2237)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2295)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4523)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
    at java.awt.Container.dispatchEventImpl(Container.java:2281)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [parkingsystem?zeroDateTimeBehavior=convertToNullPU] failed.
Internal Exception: Exception [EclipseLink-7155] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The type [class javax.swing.JLabel] for the attribute [jLabel2] on the entity class [class parkingSystem.RegisterDepartments] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface.
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1954)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1945)
    at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:96)
    ... 39 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [parkingsystem?zeroDateTimeBehavior=convertToNullPU] failed.
Internal Exception: Exception [EclipseLink-7155] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The type [class javax.swing.JLabel] for the attribute [jLabel2] on the entity class [class parkingSystem.RegisterDepartments] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface.
    at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:230)
    ... 43 more
Caused by: Exception [EclipseLink-7155] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The type [class javax.swing.JLabel] for the attribute [jLabel2] on the entity class [class parkingSystem.RegisterDepartments] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface.
    at org.eclipse.persistence.exceptions.ValidationException.invalidTypeForSerializedAttribute(ValidationException.java:1139)
    at org.eclipse.persistence.internal.jpa.metadata.converters.SerializedMetadata.process(SerializedMetadata.java:99)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processSerialized(MappingAccessor.java:1948)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processMappingConverter(MappingAccessor.java:1775)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processMappingValueConverter(MappingAccessor.java:1796)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.BasicAccessor.process(BasicAccessor.java:419)
    at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.processMappingAccessors(MetadataDescriptor.java:1536)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.processMappingAccessors(ClassAccessor.java:1648)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processMappingAccessors(EntityAccessor.java:1234)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:697)
    at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1793)
    at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:576)
    at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:585)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1869)
    ... 41 more
Java Result: 1

1 个答案:

答案 0 :(得分:0)

Exception Description: The type [class javax.swing.JLabel] for the attribute [jLabel2] on the entity class [class parkingSystem.RegisterDepartments] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface.

从异常堆栈跟踪中,我认为是类中的jLabel2 parkingSystem.RegisterDepartments.jLabel2您正在尝试序列化它。 哪个无效?。为什么要序列化JLabel?