Bug 65075 - My program works well on my operating system. But when I test it on another system, sometimes the output Word file is not generated
Summary: My program works well on my operating system. But when I test it on another s...
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 4.1.2-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-12 12:26 UTC by abed shams
Modified: 2021-01-23 13:11 UTC (History)
0 users



Attachments
The libraries I used in the project (17.21 KB, image/png)
2021-01-12 12:26 UTC, abed shams
Details

Note You need to log in before you can comment on or make changes to this bug.
Description abed shams 2021-01-12 12:26:28 UTC
Created attachment 37701 [details]
The libraries I used in the project

Hi friends I have a big problem I wrote a program in Java with javafx and apache poi and got the output file using launch4j. My program works well on my operating system. But when I test it on another system, sometimes the output Word file is not generated.

I noticed that when I send the information of a row from the table to the new controller and I want to create a Word file in the new controller, the Word file is not created. Of course, there is no problem in my system and it does not run on other systems. I used the try-catch command around the document created with apache poi and got the IllegalArgumentException error. My codes are as follows First we send the information of one of the rows of the table to the destination controller as below

@FXML
    void onNewAmrieEnteghaliItemClick(ActionEvent event) {
        try{
            TablePosition pos = soldierTable.getSelectionModel().getSelectedCells().get(0);
            int row = pos.getRow();
            
            FXMLLoader loader = new FXMLLoader(getClass().getResource("GetAmrieEnteghal.fxml"));
            loader.setControllerFactory(new Callback<Class<?>, Object>() {
                public Object call(Class<?> controllerClass) {
                    if (controllerClass == GetAmrieEnteghalController.class) {
                        GetAmrieEnteghalController ctrl = new GetAmrieEnteghalController();
                        ctrl.setP(
                                code_meliCol.getCellData(row)
                        );
                        return ctrl ;
                    } else {
                        try {
                            return controllerClass.newInstance();
                        } catch (Exception exc) {
                            throw new RuntimeException(exc); // just bail
                        }
                    }
                }
            });
            Parent root = loader.load();
            Stage stage = new Stage();
            stage.getIcons().add(APPLICATION_ICON);
            Scene scene = new Scene(root);

            stage.setScene(scene);
            stage.show();
        }catch(Exception e){
            e.printStackTrace();
            noSelectedSoldier();
        }
    }
In GetAmrieEnteghalController we give the selected row information to the database and receive other record information and then place it in the object created with apache poi as below

package javafxapplication3;

import com.jfoenix.controls.JFXTextField;
import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.stage.Stage;
import javafxapplication3.Models.MyAlert;
import javafxapplication3.Reports.AmrieEnteghal;

public class GetAmrieEnteghalController implements Initializable {
    private String s_code_meli;
    public void setP(String code_meli){
        s_code_meli = code_meli;
    }
    @FXML
    private JFXTextField be;

    @FXML
    private JFXTextField girande;
    
    @FXML
    private JFXTextField sh_nameh;

    @FXML
    private JFXTextField t_kasr_az_amar;


    @FXML
    void onGetFormBtnClick(ActionEvent event) {
        String daraje = null, name= null, pedar= null, t_ezam= null, sh_amrie= null, t_amrie= null, t_enteghal= null;
        if(SQLiteDB.setConnection()){
            if(SQLiteDB.selectQuery("select * from soldiers where code_meli = '"+s_code_meli+"';")){
                ResultSet res = SQLiteDB.getResultSet();
                try {
                    while(res.next()){
                        daraje = res.getString("daraje");
                        name = res.getString("name");
                        pedar = res.getString("pedar");
                        t_ezam = res.getString("t_e");
                        sh_amrie = res.getString("sh_amrie_enteghal");
                        t_amrie = res.getString("t_amrie_enteghal");
                        t_enteghal = res.getString("t_enteghal");
                        
                    }
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }
            }
        }
        try{
            AmrieEnteghal form = new AmrieEnteghal(daraje, name, pedar, s_code_meli, t_ezam, sh_nameh.getText(), be.getText(), girande.getText(), sh_amrie, t_amrie, t_enteghal, t_kasr_az_amar.getText());
            form.create();
        }catch(Exception e){
            e.printStackTrace();
        }
        SQLiteDB.Disconnect();
    }  
    
}
I put the AmrieEnteghal object in try-catch and got the following error on other systems with different offices
java.lang.illegalargumentexception file "docs/AmrieEnteghal.docx" does not exist
 
Where do you think the problem is? Please help me. Could there be a problem with jre? Please forgive me for poor English
Comment 1 Sayi 2021-01-15 02:12:48 UTC
Hi,
I think you should focus on whether it's a POI bug, rather than giving too much irrelevant code.
Comment 2 Dominik Stadler 2021-01-23 13:11:47 UTC
As far as I can see this looks very much like some local problem. If it works on one machine and not on another it is very likely to be caused by some local difference in your environment.

If you can narrow down the problem to an actual problem with Apache POI, then please try to provide some way of properly reproducing the problem, i.e. a sample or test-case which can be executed without your application-specific code being involved and then reopen this bug with the additional information.