IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaFX Discussion :

Exception in Application start method


Sujet :

JavaFX

  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2019
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : Togo

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2019
    Messages : 1
    Points : 2
    Points
    2
    Par défaut Exception in Application start method
    Bonsoir, je suis sur un projet avec JavaFX et j'ai quelques erreurs. J'ai lu les réponses à des questions similaires, mais aucune des solutions ne semble fonctionner. J'espère sincèrement pouvoir trouver de l'aide. Voici le code:

    ListController.java
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    public class ListController implements Initializable {
     
        @FXML
        private TableView<Category> categoriesTable;
        @FXML
        private TableColumn<Category, Integer> idColumn;
        @FXML
        private TableColumn<Category, String> nameColumn;
        @FXML
        private TableColumn<Category, String> descriptionColumn;
     
        ObservableList<Category> FXCategories = FXCollections.observableArrayList();
        @FXML
        private TextField searchField;
     
        /**
         * Initializes the controller class.
         * @param url
         * @param rb
         */
        @Override
        public void initialize(URL url, ResourceBundle rb) {
            initCol();
            loadData();
        }    
     
        private void initCol() {
            idColumn.setCellValueFactory(new PropertyValueFactory<>("id"));
            nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
            descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description"));
        }
     
        private void loadData() {
            CategoryDAO categoryDAO = new CategoryDAO();
            List<dev.stekos.cashregister.entities.Category> categories;
            categories = categoryDAO.getAll();
     
            categories.forEach((category) -> {
                FXCategories.add(new Category(category.getId(), category.getName(), category.getDescription()));
            });
     
            categoriesTable.getItems().setAll(FXCategories);
        }
     
        @FXML
        private void search(ActionEvent event) {
        }
     
        class Category {
            private final IntegerProperty id;
            private final StringProperty name;
            private final StringProperty description;
     
            public Category(int id, String name, String descriptoin) {
                this.id = new SimpleIntegerProperty(id);
                this.name = new SimpleStringProperty(name);
                this.description = new SimpleStringProperty(descriptoin);
            }
     
            public int getId() {
                return id.get();
            }
     
            public String getName() {
                return name.get();
            }
     
            public String getDescription() {
                return description.get();
            }
        }
    }
    ListLoader.java
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    public class ListLoader extends Application {
     
        @Override
        public void start(Stage primaryStage) throws IOException {
            URL url = ListLoader.class.getResource("list.fxml");
            if (url == null) {
                System.out.println("Can't load FXML file");
                Platform.exit();
            }
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(url);
            loader.setController(new ListController());
            BorderPane root;
            root = (BorderPane) loader.load();
            Scene scene = new Scene(root);
            primaryStage.setScene(scene);
            primaryStage.show();
        }
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            launch(args);
        }
     
    }
    Voici la pile d'erreurs que j'ai obtenues lors de l'exécution du code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    warning: Supported source version 'RELEASE_6' from annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source '1.8'
    warning: The following options were not recognized by any processor: '[eclipselink.canonicalmodel.use_static_factory]'
    1 warning
    compile-single:
    run-single:
    Can't load FXML file
    Exception in Application start method
    java.lang.reflect.InvocationTargetException
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    	at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
    Caused by: java.lang.RuntimeException: Exception in Application start method
    	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$159(LauncherImpl.java:182)
    	at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.IllegalStateException: Location is not set.
    	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
    	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
    	at dev.stekos.cashregister.views.category.ListLoader.start(ListLoader.java:35)
    	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$166(LauncherImpl.java:863)
    	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$179(PlatformImpl.java:326)
    	at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294)
    	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    	at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
    	... 1 more
    Exception running application dev.stekos.cashregister.views.category.ListLoader
    D:\MyProjects\JAVA\JAVAFX\CashRegister\nbproject\build-impl.xml:1340: The following error occurred while executing this line:
    D:\MyProjects\JAVA\JAVAFX\CashRegister\nbproject\build-impl.xml:981: Java returned: 1
    BUILD FAILED (total time: 14 seconds)
    Cliquer https://github.com/StephaneKuma/CashRegister pour voir le projet sur github

    C'est mon problème, j'espère avoir de l'aide bientôt.

  2. #2
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 854
    Points
    22 854
    Billets dans le blog
    51
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    loader.setController(new ListController());
    Pourquoi est-ce que tu specifies un controller dans ton code alors que tu en as déjà un qui est déclaré dans ton FXML ?
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

Discussions similaires

  1. Réponses: 9
    Dernier message: 06/02/2019, 14h58
  2. Exception in Application start method
    Par Hind4Dev dans le forum JavaFX
    Réponses: 2
    Dernier message: 07/03/2017, 16h53
  3. Problème:Exception in Application start method
    Par Bagginssou dans le forum JavaFX
    Réponses: 1
    Dernier message: 14/12/2016, 23h35
  4. [Data] Gestion des exceptions dans applications Spring Hibernate Struts
    Par coco-sup dans le forum Spring
    Réponses: 4
    Dernier message: 09/12/2012, 12h58
  5. Exception d'application avec EPrinter
    Par Masmeta dans le forum C++Builder
    Réponses: 14
    Dernier message: 12/12/2006, 15h21

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo