4 Replies Latest reply: Oct 26, 2012 6:30 PM by 966626 RSS

    Controller method not found

    966626
      I am using NetBeans 7.2 with some maven projecs.. after a lot of work i have a fxml project witha basic window displayed and an access to a springframework managed singletons (JDBCDAOSupport) to access emmbeded Derby. And it works!!!!
      The problem is presented when i add a handler to a button on the FXML file, it seams to load the Controller but it can't find the method:
      for the XML:
      <AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity"
      minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
      prefWidth="728.0" styleClass="root"
      xmlns:fx="http://javafx.com/fxml"
      fx:controller="mx.gob.scjn.iusjfx.presentacion.Presentacion">
      .......
      <Button fx:id="btnConsultaRegresa" maxHeight="40.0" maxWidth="1.7976931348623157E308" minHeight="40.0" minWidth="130.0" mnemonicParsing="false" onAction="#btnRegresarConsultasAction" prefHeight="40.0" prefWidth="130.0" text="%btnCRegresa" textAlignment="CENTER" wrapText="true">
      <VBox.margin>
      <Insets top="10.0" />
      </VBox.margin>
      </Button>
      ....
      </children>
      <stylesheets>
      <URL value="@/mx/gob/scjn/iusgraphresources/css/IUS.css" />
      </stylesheets>
      </AnchorPane>



      On the java file:





      package mx.gob.scjn.iusjfx.presentacion;

      import java.awt.event.ActionEvent;
      import java.io.IOException;
      import java.net.URL;
      import java.util.ResourceBundle;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javafx.fxml.FXML;
      import javafx.fxml.FXMLLoader;
      import javafx.fxml.Initializable;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import mx.gob.scjn.ius_common.entrypoint.IUSEntryPoint;

      /**
      *
      * @author charly
      */
      public class Presentacion implements Initializable {
      protected Stage currentStage;
      @FXML
      private Label actualizado;
      @FXML
      private VBox menuConsulta;
      @FXML
      private VBox menuInfo;
      @FXML
      private VBox menuPrincipal;


      @FXML
      private void btnConsultasAction(ActionEvent event) {

      this.menuPrincipal.setVisible(false);
      this.menuConsulta.setVisible(true);

      }

      @FXML
      private void btnRegresarConsultasAction(ActionEvent event) {

      this.menuPrincipal.setVisible(true);
      this.menuConsulta.setVisible(false);

      }

      @FXML
      private void btnConsultaTradicionalAction(ActionEvent event) {
      try {
      Parent root = FXMLLoader.load(getClass().getResource("/mx/gob/scjn/iusjfx/presentacion/ConsultaTradicional.fxml"));
      Scene scene = ((Button)event.getSource()).getScene();
      scene.setRoot(root);
      //Stage stage = getCurrentStage();

      // stage.setScene(scene);
      // stage.show();
      } catch (IOException ioex) {
      Logger.getLogger(Presentacion.class.getName()).log(Level.SEVERE, null, ioex);
      }
      }

      @Override
      public void initialize(URL url, ResourceBundle rb) {
      menuConsulta.setVisible(false);
      menuInfo.setVisible(false);
      IUSEntryPoint fac = new IUSEntryPoint();
      this.actualizado.setText(fac.actualizadoA());

      }

      public Stage getCurrentStage() {
      return currentStage;
      }

      public void setCurrentStage(Stage value){
      currentStage = value;
      }
      }

      Thanks in advance... if you need any other info please let me know.

      Edited by: user4270122 on 25/10/2012 09:51 AM
        • 1. Re: Controller method not found
          David Grieve
          Try making the handler protected rather than private
          • 2. Re: Controller method not found
            966626
            I already tryed even sith public with no results.... i found in other forums tat i should reinstall javafx, thn i saw my pom.xml and the javafx runtime jar was as "compile" in the scope, i changed it for System, but now i have a class not def exception... here's the pom.xml and the exception:
            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>

            <groupId>mx.gob.scjn</groupId>
            <artifactId>IUSJFX</artifactId>
            <version>1.0-SNAPSHOT</version>
            <packaging>jar</packaging>

            <name>IUSJFX</name>
            <url>http://maven.apache.org</url>
            <build>
            <resources
            directory="src/main/resources">
            </resources>
            <plugins>
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
            <source>1.7</source>
            <target>1.7</target>
            <showDeprecation>true</showDeprecation>
            </configuration>
            </plugin>
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
            <execution>
            <phase>package</phase>
            <configuration>
            <target>
            <taskdef name="jfxdeploy" classname="com.sun.javafx.tools.ant.DeployFXTask"
            classpathref="maven.plugin.classpath"/>

            <taskdef name="jfxsignjar" classname="com.sun.javafx.tools.ant.FXSignJarTask"
            classpathref="maven.plugin.classpath"/>

            <jfxdeploy width="800" height="600" outdir="${project.build.directory}/deploy"
            outfile="${project.build.finalName}">
            <info title="${project.name}"/>
            <application name="${project.name}" mainclass="webmap.WebMap"/>
            <resources>
            <fileset dir="${project.build.directory}" includes="*.jar"/>
            <fileset dir="${project.build.directory}/dependency"
            includes="*.jar"/>
            </resources>
            <platform javafx="2.2">
            <jvmarg value="-Xms64m"/>
            <jvmarg value="-Xmx256m"/>
            </platform>
            </jfxdeploy>
            <jfxsignjar destdir="${project.build.directory}/deploy"
            keystore="${project.basedir}/src/main/java/jnlp/keystore.jks"
            storepass="superpass" alias="signFiles" keypass="superpass">
            <fileset dir="${project.build.directory}/deploy" includes="*.jar"/>
            </jfxsignjar>
            </target>
            </configuration>
            <goals>
            <goal>run</goal>
            </goals>
            </execution>
            </executions>
            <dependencies>
            <dependency>
            <groupId>com.oracle.javafx</groupId>
            <artifactId>ant-javafx</artifactId>
            <version>2.2</version>
            <systemPath>${ant.javafx.jar}</systemPath>
            <scope>system</scope>
            </dependency>
            </dependencies>
            </plugin>

            </plugins>
            </build>
            <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <javafx.rt.jar>C:\Program Files\Java\jre7\lib\jfxrt.jar</javafx.rt.jar>
            <ant.javafx.jar>C:\Program Files\Java\jdk1.7.0_07\lib\ant-javafx.jar</ant.javafx.jar>
            </properties>

            <dependencies>
            <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
            </dependency>
            <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>javafx</artifactId>
            <version>2.2</version>
            <systemPath>${javafx.rt.jar}</systemPath>
            <scope>system</scope>
            </dependency>
            <dependency>
            <groupId>mx.gob.scjn.ius_common</groupId>
            <artifactId>IUSGraphResources</artifactId>
            <version>1.0-SNAPSHOT</version>
            </dependency>
            <dependency>
            <groupId>mx.gob.scjn.ius_common</groupId>
            <artifactId>ius_common</artifactId>
            <version>1.0-SNAPSHOT</version>
            </dependency>
            </dependencies>
            <reporting>
            <plugins>
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.9.1</version>
            <configuration>
            <configLocation>config/sun_checks.xml</configLocation>
            </configuration>
            </plugin>
            </plugins>
            </reporting>
            </project>



            [exec:exec]
            java.lang.NoClassDefFoundError: javafx/application/Application
                 at java.lang.ClassLoader.defineClass1(Native Method)
                 at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
                 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
                 at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
                 at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
                 at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
                 at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
                 at java.security.AccessController.doPrivileged(Native Method)
                 at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
                 at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
                 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
                 at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
                 at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480)
            Caused by: java.lang.ClassNotFoundException: javafx.application.Application
                 at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
                 at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
                 at java.security.AccessController.doPrivileged(Native Method)
                 at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
                 at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
                 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
                 at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
                 ... 13 more
            Exception in thread "main" [INFO] ------------------------------------------------------------------------
            BUILD FAILURE
            ------------------------------------------------------------------------
            Total time: 5.974s
            Finished at: Thu Oct 25 11:07:17 CDT 2012
            Final Memory: 7M/20M
            ------------------------------------------------------------------------
            Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:exec (default-cli) on project IUSJFX: Command execution failed. Process exited with an error: 1(Exit value: 1) -> [Help 1]

            To see the full stack trace of the errors, re-run Maven with the -e switch.
            Re-run Maven using the -X switch to enable full debug logging.

            For more information about the errors and possible solutions, please read the following articles:
            [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
            • 3. Re: Controller method not found
              David Grieve
              This is not an FXML issue - you aren't getting that far. Make sure jfxrt.jar is on your classpath.
              • 4. Re: Controller method not found
                966626
                At last i abandon maven... thanks for the try... but netbeans-maven-javafx integration needs to be worked.... a lot.