Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 运行在Glass Fish服务器上的Web服务上的Netbeans中的FileNotFoundException_Java_Web Services_Serialization_Netbeans_Filenotfoundexception - Fatal编程技术网

Java 运行在Glass Fish服务器上的Web服务上的Netbeans中的FileNotFoundException

Java 运行在Glass Fish服务器上的Web服务上的Netbeans中的FileNotFoundException,java,web-services,serialization,netbeans,filenotfoundexception,Java,Web Services,Serialization,Netbeans,Filenotfoundexception,当在GUI上单击该按钮时,此事件处理程序将被激活。实现声明的 @在课堂上使用WebMethod private void btn_loginActionPerformed(java.awt.event.ActionEvent evt) { int result; String username = us_textField.getText(); String password = ne

当在GUI上单击该按钮时,此事件处理程序将被激活。实现声明的 @在课堂上使用WebMethod

private void btn_loginActionPerformed(java.awt.event.ActionEvent evt) {                                          

    int result;

    String username = us_textField.getText();
    String password = new String(pw_textField.getPassword());

    try {
        result = employeeLogin(username, password);
    } catch (IOException_Exception ex) {
        Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        result = 0;
    } catch (FileNotFoundException_Exception ex) {
        Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        result = 0;
    } catch (ClassNotFoundException_Exception ex) {
        Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        result = 0;
    }

    if (result == 0) {
        lbl_loginStatus.setText("Invalid Inputs");
    } else if (result == 1) {
        lbl_loginStatus.setText("Username and password does not match!");
    } else {
        lbl_loginStatus.setText("Login Successful!");
        new Choose().setVisible(true);
        this.dispose();
    }

}
这是在同一类中声明web服务的方式

private static int employeeLogin(java.lang.String username, java.lang.String password) throws IOException_Exception, FileNotFoundException_Exception, ClassNotFoundException_Exception {
    ws_employee.CWWsEmployee_Service service = new ws_employee.CWWsEmployee_Service();
    ws_employee.CWWsEmployee port = service.getCWWsEmployeePort();
    return port.employeeLogin(username, password);
}
这是Web服务代码

EmployeeMainController controller = new EmployeeMainController();
@WebMethod(operationName = "EmployeeLogin")
public int EmployeeLogin(@WebParam(name = "username") String username, @WebParam(name = "password") String password) throws IOException, FileNotFoundException, ClassNotFoundException {
    //TODO write your implementation code here:
    return controller.EmployeeLogin(username, password);
}
这是
EmployeeMainController.java
类中声明的
EmployeeLogin(用户名、密码)
方法。在此方法中,由
LoadData()
方法初始化的ArrayList

public int EmployeeLogin(String username, String password) throws FileNotFoundException, IOException, ClassNotFoundException {

    // Loading to the array list from the text file.
    ArrayList<EmployeeStruct> loadArray = new ArrayList<EmployeeStruct>();
    loadArray = LoadList();

    for (EmployeeStruct val : loadArray) {
        if (val.getEmpUsername().equals(username) && val.getEmpPassword().equals(password)) {
            return 2;
        } else if (val.getEmpUsername().equals(username) || val.getEmpPassword().equals(password)) {
            return 1;
        }
    }

    return 0;
}
但是当执行代码时,
ws_employee.FileNotFoundException\u Exception:cw_employeeData.txt(系统找不到指定的文件).
控制台中出现错误

甚至我也在根目录中的
root/src
文件夹旁边找到了
cw_employeeData.txt
文件

public ArrayList<EmployeeStruct> LoadList() throws FileNotFoundException, IOException, ClassNotFoundException {

    ArrayList<EmployeeStruct> employeeList = new ArrayList<EmployeeStruct>();
    File file = new File(filename);
    FileInputStream fis = new FileInputStream(file);
    ObjectInputStream ois = new ObjectInputStream(fis);
    try {
        while (true) {
            EmployeeStruct x = (EmployeeStruct) ois.readObject();
            // System.out.println(x.toString());
            employeeList.add(x);

        }
    } catch (EOFException e) {
        // TODO Auto-generated catch block
        System.out.println("Completed reading from the file " + filename);
    }

   // employeeList.add(admin);
    return employeeList;
}