This is my first JavaFX program and I want to accept the username via eUser and password via ePass. When I try to check if the textfield is empty using validate I get this error:
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$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException:
file:/Users/dylan/NetBeansProjects/JavaFXApplication2/dist/run350595374/JavaFXApplication2.jar!/javafxapplication2/FXMLDocument.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at javafxapplication2.JavaFXApplication2.start(JavaFXApplication2.java:23)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Caused by: java.lang.NullPointerException
at javafxapplication2.FXMLDocumentController.initialize(FXMLDocumentController.java:48)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 14 more
Exception running application javafxapplication2.JavaFXApplication2
Java Result: 1
When I comment out eUser.getValidators().add(vali); from Controller.java file and the lines that follow it, then no errors show up.
This is my FXMLDocumentController.java file:
public class FXMLDocumentController implements Initializable {
#FXML
private JFXTextField eUser;
#FXML
private JFXTextField ePass;
#FXML
private void handleClose(MouseEvent event) {
System.exit(0);
}
#Override
public void initialize(URL url, ResourceBundle rb) {
RequiredFieldValidator vali = new RequiredFieldValidator();
eUser.getValidators().add(vali);
vali.setMessage("No Input Given");
vali.focusedProperty().addListener(new ChangeListener<Boolean>(){
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if(!newValue)
{
eUser.validate();
}
}});}}
Main class:
public class JavaFXApplication2 extends Application {
#Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
stage.initStyle(StageStyle.UNDECORATED);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Maybe this could be the problem. In your FXML file, check if you set those ID's to the relevant textfields. That might possibly be the thing which is causing the NullPointerException.
If you're using SceneBuilder, click on the relevant textfield -> Code and set the fx:id of those textFields.
And by the way, you can probably use a PasswordField instead of a TextField :)
Related
As a new one to Google Guice, I try to use it in my JavaFX project,the purpose is to inject service to a controller class. But java.lang.reflect.InvocationTargetException always appears. The main part is here:
public class App extends Application {
private static Scene scene;
private static Injector injector;
#Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("ui"), 640, 480);
stage.setScene(scene);
stage.show();
}
private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
fxmlLoader.setControllerFactory(initilizedClass->{
return injector.getInstance(initilizedClass);
});
return fxmlLoader.load();
}
public static void main(String[] args) {
launch();
}
public void init() {
App.injector = Guice.createInjector(new DiModule());
}
//...
}
//
public class DiModule extends AbstractModule {
#Override
protected void configure() {
bind(IUserListService.class).to(BroadcastUserListService.class);
}
}
//
public interface IUserListService {}
public class BroadcastUserListService implements IUserListService {}
//
public class UIController {
#FXML
private ListView listView;
#Inject
private IUserListService us;
public void initialize() {
//listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
us.sendOnlineMessage();
}
}
I use modules and the error details are :
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.ExceptionInInitializerError
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2199)
at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827)
at guice#4.0/com.google.inject.internal.FailableCache.get(FailableCache.java:48)
at guice#4.0/com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:50)
at guice#4.0/com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:136)
at guice#4.0/com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:547)
at guice#4.0/com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:884)
at guice#4.0/com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:805)
at guice#4.0/com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:282)
at guice#4.0/com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:214)
at guice#4.0/com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:890)
at guice#4.0/com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46)
at guice#4.0/com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50)
at guice#4.0/com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:134)
at guice#4.0/com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
at guice#4.0/com.google.inject.Guice.createInjector(Guice.java:96)
at guice#4.0/com.google.inject.Guice.createInjector(Guice.java:73)
at guice#4.0/com.google.inject.Guice.createInjector(Guice.java:62)
at com.freelance.ChatterBox/com.freelance.ChatterBox.App.main(App.java:43)
... 11 more
Caused by: java.lang.ExceptionInInitializerError
at guice#4.0/com.google.inject.internal.cglib.reflect.$FastClassEmitter.<init>(FastClassEmitter.java:67)
at guice#4.0/com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass(FastClass.java:72)
at guice#4.0/com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at guice#4.0/com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at guice#4.0/com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:64)
at guice#4.0/com.google.inject.internal.BytecodeGen.newFastClass(BytecodeGen.java:204)
at guice#4.0/com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:54)
at guice#4.0/com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:159)
at guice#4.0/com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:90)
at guice#4.0/com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
at guice#4.0/com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37)
at guice#4.0/com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
at guice#4.0/com.google.inject.internal.FailableCache$1.load(FailableCache.java:37)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
... 32 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to module guice
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
at guice#4.0/com.google.inject.internal.cglib.core.$ReflectUtils$2.run(ReflectUtils.java:56)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at guice#4.0/com.google.inject.internal.cglib.core.$ReflectUtils.<clinit>(ReflectUtils.java:46)
... 49 more
Exception running application com.freelance.ChatterBox.App
This question already has an answer here:
Convert between LocalDate and sql.Date [duplicate]
(1 answer)
Closed 4 years ago.
hello i need to display a date column in a tableview; in the database I declare the field fecha_nacimiento as date , i used a datepicker to insert that data into the database, so far its Ok with that operation so the next step was formatting the tableview cell to display the date data correctly, with the help of this site i did that, but when i need to retrieve the date data from the database i am getting an error, something like this:
Caused by: java.lang.UnsupportedOperationException
at java.sql.Date.toInstant(Unknown Source)
this is some of my controller code
public void initialize(URL arg0, ResourceBundle arg1) {
clienteid.setCellValueFactory(new PropertyValueFactory <Persona, Integer>("id_cliente"));
nombrescol.setCellValueFactory(new PropertyValueFactory <Persona, String>("nombres"));
apellidoscol.setCellValueFactory(new PropertyValueFactory <Persona, String>("apellidos"));
//fechacli.setCellValueFactory(new PropertyValueFactory <Persona, LocalDate>("fechacliente"));//
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
fechacli.setCellFactory(column -> {
return new TableCell<Persona, LocalDate>() {
#Override
protected void updateItem(LocalDate item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
} else {
setText(formatter.format(item));
}
}
};
});
seleccionaregistros();
seleccionanombre();
seleccionapellido();
}
public void seleccionaregistros() {
ObservableList <Persona> data =FXCollections.observableArrayList();
Connection conn=null;{
try {
conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=prueba", "sa", "milkas87");
Statement mostrar=conn.createStatement();
ResultSet rs;
rs= mostrar.executeQuery("select * from cliente");
while ( rs.next() )
{
data.add(new Persona(
rs.getString("nombre"),
rs.getString("apellido"),
rs.getInt("id"),
rs.getDate(4).toInstant().atZone(ZoneId.systemDefault()).toLocalDate())
);
tablacliente.setItems(data);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
this is my persona class code
package application;
import java.time.LocalDate;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class Persona {
private StringProperty nombres;
private StringProperty apellidos;
private IntegerProperty id_cliente;
private ObjectProperty <LocalDate>fechacliente;
public Persona (String nombres, String apellidos, Integer id_cliente, LocalDate fechacliente) {
this.nombres= new SimpleStringProperty (nombres);
this.apellidos= new SimpleStringProperty ( apellidos);
this.id_cliente=new SimpleIntegerProperty (id_cliente);
this.fechacliente= new SimpleObjectProperty<>(fechacliente);
}
public LocalDate getFechaCliente() {
return fechacliente.get();
}
public void setFechaCliente(LocalDate fechacliente) {
this.fechacliente = new SimpleObjectProperty<>(fechacliente);
}
public ObjectProperty<LocalDate> fechaClienteProperty() {
return fechacliente;
}
public String getNombres() {
return nombres.get();
}
public void setNombres(String nombres) {
this.nombres=new SimpleStringProperty (nombres);
}
public String getApellidos() {
return apellidos.get();
}
public void setApellidos(String apellidos) {
this.apellidos=new SimpleStringProperty ( apellidos);
}
public Integer getId_cliente() {
return id_cliente.get();
}
public void setid_cliente(Integer id_cliente) {
this.id_cliente=new SimpleIntegerProperty (id_cliente);
}
}
id have been reading, and i found that can't truncate or pass the data beetween Localdate and Date, so any help could be truly helpful. regards.
all the errors here:
javafx.fxml.LoadException:
/C:/Users/ROA%20PC/eclipse-workspace/Conexion/bin/application/Vista.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at application.Main.start(Main.java:23)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsupportedOperationException
at java.sql.Date.toInstant(Unknown Source)
at application.ConexionController.seleccionaregistros(ConexionController.java:190)
at application.ConexionController.initialize(ConexionController.java:92)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 17 more
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
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$155(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Root cannot be null
at javafx.scene.Scene.<init>(Scene.java:336)
at javafx.scene.Scene.<init>(Scene.java:235)
at application.Main.start(Main.java:27)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
... 1 more
Exception running application application.Main
The java.sql.Date is a java.util.Date subclass that holds no time information, so you can’t convert it to an Instant class.
Fortunately, there is a toLocalDate method that does just that, convert it directly to LocalDate.
It should be like this:
rs.getDate(4).toLocalDate();
For further reference take a look at the JavaDoc https://docs.oracle.com/javase/8/docs/api/java/sql/Date.html#toInstant--
I'm facing some problems while executing my main function using javafx .It appears to be a problem in loading the fxml file if I'm not mistaken but I can't seem to find how to fix it .
Exception message:
Exception in Application start method java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)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$154(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
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 Gestion.view.MainClass.initialisationContenu(MainClass.java:57)
at Gestion.view.MainClass.start(MainClass.java:28)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(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$147(WinApplication.java:177)
... 1 more
Exception running application Gestion.view.MainClass
Main function:
package Gestion.view;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class MainClass extends Application {
private Stage stagePrincipal;
private BorderPane conteneurPrincipal;
#Override
public void start(Stage primaryStage) {
stagePrincipal = primaryStage;
stagePrincipal.setTitle("Application de gestion du centre socio-médical OCP");
initialisationConteneurPrincipal();
initialisationContenu();
}
private void initialisationConteneurPrincipal() {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainClass.class.getResource("Welcome.fxml"));
try {
conteneurPrincipal = (BorderPane) loader.load();
Scene scene = new Scene(conteneurPrincipal);
stagePrincipal.setScene(scene);
stagePrincipal.show();
} catch (IOException e) {
e.printStackTrace();
}
}
private void initialisationContenu() {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass()
.getClassLoader()
.getResource("Acceuil1.fxml")
);
try {
AnchorPane conteneurPersonne = (AnchorPane) loader.load();
conteneurPrincipal.setCenter(conteneurPersonne);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
public Stage getStage() {
return null;
}
}
I've already searched in other similar questions , but the answers given did not work for me.
The problem is that FXMLLoader can't load an object hierarchy from FXML documents.
Fix it by updating the URLs:
loader.setLocation(MainClass.class.getResource("/fxml/Welcome.fxml"));
.getResource("/fxml/Acceuil1.fxml")
and moving Welcome.fxml and Acceuil1.fxml to src/main/resources/fxml directory.
I write program with java8, JAVAFX, spring, hibernate, jpa, mysql.
I've to problem with connecting server part of program with javafx.
When I click on class with main→run as java aplication, this problems occurs:
log4j:WARN No appenders could be found for logger (org.jboss.resteasy.plugins.providers.DocumentProvider).
log4j:WARN Please initialize the log4j system properly.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Sylwia/.m2/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Sylwia/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Sylwia/.m2/repository/org/slf4j/slf4j-simple/1.5.8/slf4j-simple-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$48/1732398722.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
/C:/Users/Sylwia/git/Praca%20inzynierska%203/Praca%20inzynierska%202/target/classes/fxml/productComponent.fxml
at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at pl.ftims.praca.restClientJavafx.RestClient.start(RestClient.java:17)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/1441419654.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/1051754451.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/742445343.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/1775282465.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
... 1 more
Caused by: java.lang.NullPointerException
at pl.ftims.praca.restClientJavafx.FXMLController.initialize(FXMLController.java:140)
... 23 more
Exception running application pl.ftims.praca.restClientJavafx.RestClient
//////////////////////////////////////////////////////////////////////
Should I first focus on problem:
at pl.ftims.praca.restClientJavafx.RestClient.start(RestClient.java:17)
or:
Caused by: java.lang.NullPointerException
at pl.ftims.praca.restClientJavafx.FXMLController.initialize(FXMLController.java:140)
... 23 more
my RestClient class:
package pl.ftims.praca.restClientJavafx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class RestClient extends Application {
#Override
public void start(Stage stage) throws Exception {
//When using the Class.getResource method,
//you must provide a local path from the location of the class on which is called the method.
//Parent root = FXMLLoader.load(RestClient.class.getResource("/fxml/components.fxml"));
Parent root = FXMLLoader.load(RestClient.class.getResource("/fxml/productComponent.fxml"));
//I also had to use Parent root = FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml"));
/*FXMLLoader loader = new FXMLLoadergetClass().getResource("main.fxml");
loader.setController(new MainController(path));
Pane mainPane = loader.load();*/
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application.
* main() serves only as fallback in case the application can not be
* launched through deployment artifacts, e.g., in IDEs with limited FX
* support. NetBeans ignores main().
*
* #param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
FXMLController class
package pl.ftims.praca.restClientJavafx;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import pl.ftims.praca.model.ProductWrapper;
import pl.ftims.praca.model.Products;
public class FXMLController implements Initializable {
#FXML
private TableView productTable;
#FXML
private TableColumn idColumn;
#FXML
private TableColumn nameColumn;
#FXML
private TableColumn sellingPriceColumn;
#FXML
private TableColumn purchasePriceColumn;
#FXML
private TextField idField;//tego nie bylo chyba, bo nie mozna przeciez zmieniac id
#FXML
private TextField nameField;
#FXML
private TextField sellingPriceField;
#FXML
private TextField purchasePriceField;
/*private Long id;
private String name;
private Double sellingPrice;
private Double purchasePrice; //cena zakupu
#ManyToOne
private Storages storage; */
private List<Products> listOfProducts = null;
private List<Fxproduct> listOfFxProducts = null;
private ObservableList<Fxproduct> listOfObservableList = null;
private final static String REST_ROOT_URL = "http://localhost:8080/rest/";
private final Client client = ClientBuilder.newClient();
#FXML
private void remove(ActionEvent event) { //ok rozumiem
Fxproduct fxproduct = (Fxproduct) productTable.getSelectionModel().getSelectedItem();
listOfObservableList.remove(fxproduct);
Response response = client.target(REST_ROOT_URL).
// path("publisher").
path("products").
path("deleteProductWithId").
path(String.valueOf(fxproduct.getId())).
request().delete();
}
#FXML
private void save(ActionEvent event) {
Products product = new Products();
product.setName(nameField.getText());
product.setPurchasePrice(Double.parseDouble(purchasePriceField.getText()));
product.setSellingPrice(Double.parseDouble(sellingPriceField.getText()));
Entity<Products> kitapEntity = Entity.entity(product, MediaType.APPLICATION_XML);
Response response = client.target(REST_ROOT_URL).
path("product").
path("createProductWithData").
request().
post(kitapEntity);
list(null);
nameField.setText("");
purchasePriceField.setText("");
sellingPriceField.setText("");
}
#FXML
private void list(ActionEvent event) { //NIE WIEM JAK TO ZROBIC
Response response = client.target("http://localhost:8080/rest/").
path("products").
path("products").
request(MediaType.APPLICATION_XML).
get();
ProductWrapper productWrapper = response.readEntity(ProductWrapper.class); //nie mam tego
listOfProducts = (productWrapper.getProductList()==null)?new ArrayList<Products>(): productWrapper.getProductList();
// listOfFxProducts = new ArrayList<>();
// listOfFxProducts = new ArrayList<>(); //tak bylo, ale to jest java 1.7 i sie nie kompilowalo
for (Products k : listOfProducts) {
listOfFxProducts.add(new Fxproduct(k));
}
listOfObservableList = FXCollections.observableList(listOfFxProducts);
System.out.println(listOfObservableList);
productTable.setItems(listOfObservableList);
System.out.println(productTable);
}
public void kitapDuzenle(Products product) {
Entity<Products> kitapEntity = Entity.entity(product, MediaType.APPLICATION_XML);
Response response = client.target(REST_ROOT_URL).
path("product").
path("saveProduct2").
request().
put(kitapEntity);
}
// #SuppressWarnings("restriction")
#Override
public void initialize(URL url, ResourceBundle rb) {
productTable.setEditable(true); //tu jest blad, nullpointer
//NAME
nameColumn.setCellFactory(TextFieldTableCell.forTableColumn());
nameColumn.setOnEditCommit(
new EventHandler<TableColumn.CellEditEvent<Fxproduct, String>>() {
#Override
public void handle(TableColumn.CellEditEvent<Fxproduct, String> t) {
ObservableList<Fxproduct> kitapListesi = t.getTableView().getItems();
Fxproduct kitap = kitapListesi.get(t.getTablePosition().getRow());
kitap.setName(t.getNewValue());
kitapDuzenle(kitap.getproduct());
}
}
);
//SELLINGPRICE
sellingPriceColumn.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleToStringConverter()));//tu jest blad
sellingPriceColumn.setOnEditCommit(
new EventHandler<TableColumn.CellEditEvent<Fxproduct, Double>>() {
#Override
public void handle(TableColumn.CellEditEvent<Fxproduct, Double> t) {
ObservableList<Fxproduct> kitapListesi = t.getTableView().getItems();
Fxproduct kitap = kitapListesi.get(t.getTablePosition().getRow());
kitap.setSellingPrice(t.getNewValue()); //tu ejst problem z double i siple double
kitapDuzenle(kitap.getproduct());
}
}
);
//PURCHASEPRICE
purchasePriceColumn.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleToStringConverter()));
purchasePriceColumn.setOnEditCommit(
new EventHandler<TableColumn.CellEditEvent<Fxproduct, Double>>() {
#Override
public void handle(TableColumn.CellEditEvent<Fxproduct, Double> t) {
ObservableList<Fxproduct> kitapListesi = t.getTableView().getItems();
Fxproduct kitap = kitapListesi.get(t.getTablePosition().getRow());
kitap.setPurchasePrice(t.getNewValue());//tu ejst problem z double i siple double
kitapDuzenle(kitap.getproduct());
}
}
);
idColumn.setCellValueFactory(
new PropertyValueFactory<Fxproduct, Long>("id"));
nameColumn.setCellValueFactory(
new PropertyValueFactory<Fxproduct, String>("name"));
purchasePriceColumn.setCellValueFactory(
new PropertyValueFactory<Fxproduct, Double>("price"));
sellingPriceColumn.setCellValueFactory(
new PropertyValueFactory<Fxproduct, Double>("price"));
list(null);
}
}
I thought that the problems is the path:
Parent root = FXMLLoader.load(RestClient.class.getResource("/fxml/productComponent.fxml"));
but I read this:
How to reference javafx fxml files in resource folder?
JavaFX "Location is required." even though it is in the same package
Referencing class resource in FXML
Error loading fxml files from a folder other than the bin folder
JavaFX: load resource from other package - NetBeans
How to reference javafx fxml files in resource folder?
https://stackexchange.com/search?q=How+to+reference+javafx+fxml+files+in+resource+folder%3F
JavaFX - Exception in Application start method?
and I didnt find the answer.
/////////////////////////////EDIT///////////////////
line 17 in RestClient:
Parent root = FXMLLoader.load(RestClient.class.getResource("/fxml/productComponent.fxml"));
line 139, 140 in FXMLController:
public void initialize(URL url, ResourceBundle rb) { productTable.setEditable(true); // nullpointer
So, I'm doing a JavaFX multiview GUI application.
Below is the code so that you can refer to it, don't read through it to find an error yet, I'll explain the problem underneath first ;)
I have a main - which starts the application
public class MyFXMLMain extends Application {
#Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Wireframe.fxml"));
stage.setTitle("My Fitness App");
Scene mainScene = new Scene(root,805,809);
stage.setScene(mainScene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
ScreensController - that controls loading/setting screens.
public class ScreensController extends StackPane {
private HashMap<String, Node> screens = new HashMap<>();
public ScreensController() {
super();
}
public void addScreen(String name, Node screen) {
screens.put(name, screen);
}
public Node getScreen(String name) {
return screens.get(name);
}
public boolean loadScreen(String name, String resource) {
try {
FXMLLoader myLoader = new FXMLLoader(getClass().getResource(resource));
Parent loadScreen = (Parent) myLoader.load();
ControlledScreen myScreenController = ((ControlledScreen) myLoader.getController());
myScreenController.setScreenParent(this);
addScreen(name, loadScreen);
return true;
}catch(Exception e) {
System.out.println(e.getMessage());
return false;
}
}
public boolean setScreen(final String name) {
if (screens.get(name) != null) { //screen loaded
final DoubleProperty opacity = opacityProperty();
if (!getChildren().isEmpty()) { //if there is more than one screen
Timeline fade = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(opacity, 1.0)),
new KeyFrame(new Duration(1000), new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent t) {
getChildren().remove(0); //remove the displayed screen
getChildren().add(0, screens.get(name)); //add the screen
Timeline fadeIn = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(opacity, 0.0)),
new KeyFrame(new Duration(800), new KeyValue(opacity, 1.0)));
fadeIn.play();
}
}, new KeyValue(opacity, 0.0)));
fade.play();
} else {
setOpacity(0.0);
getChildren().add(screens.get(name)); //no one else been displayed, then just show
Timeline fadeIn = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(opacity, 0.0)),
new KeyFrame(new Duration(2500), new KeyValue(opacity, 1.0)));
fadeIn.play();
}
return true;
} else {
System.out.println("screen hasn't been loaded!!! \n");
return false;
}
}
public boolean unloadScreen(String name) {
if (screens.remove(name) == null) {
System.out.println("Screen didn't exist");
return false;
} else {
return true;
}
}
}
A screen framework - that links the screens to the FXML files.
public class ScreensFramework extends Application {
public static String MAIN_SCREEN = "MyFXMLController";
public static String MAIN_SCREEN_FXML = "Wireframe.fxml";
public static String calendarScreen = "CalendarscreenController";
public static String calendarScreenFXML = "Calendarscreen.fxml";
public static String guideScreen = "GuideScreenController";
public static String guideScreenFXML ="Guidescreen.fxml";
#Override
public void start(Stage primaryStage) {
ScreensController mainContainer = new ScreensController();
mainContainer.loadScreen(ScreensFramework.MAIN_SCREEN, ScreensFramework.MAIN_SCREEN_FXML);
mainContainer.loadScreen(ScreensFramework.calendarScreen,ScreensFramework.calendarScreenFXML);
mainContainer.loadScreen(ScreensFramework.guideScreen,ScreensFramework.guideScreenFXML);
mainContainer.setScreen(ScreensFramework.MAIN_SCREEN);
Group root = new Group();
root.getChildren().addAll(mainContainer);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}
An FXML controller - which links to the FXML files and tells FXML what to do when something is clicked.
public class MyFXMLController implements ControlledScreen{
#FXML private TextField givenName;
#FXML private Text targetText;
//#FXML private static TableView<Mass> theTable;
//#FXML private static TableColumn<Mass, String> dateCol;
//#FXML private static TableColumn<Mass, String> massCol;
#FXML private static LineChart<Number,Number> weightChart;
#FXML private static NumberAxis axisX;
#FXML private static NumberAxis axisY;
#FXML private static Label myLabel;
//private static User theUser = new User();
private static ScreensController myController;
#Override
public void setScreenParent(ScreensController screenPage) {
myController = screenPage;
}
#FXML protected void handlePressedCalendarButtonAction(ActionEvent event){
System.out.println("Hello");
}
#FXML protected void mouseclickedcal(MouseEvent mec){
myController.setScreen(ScreensFramework.calendarScreen);
}
}
A controlledscreen - that does this:
public interface ControlledScreen {
public void setScreenParent(ScreensController screenPage);
}
And a CalendarScreenController - that controls one of the multi screens
public class CalendarScreenController implements Initializable, ControlledScreen {
ScreensController myController;
#Override
public void initialize(URL url, ResourceBundle rb) {
}
public void setScreenParent(ScreensController screenParent){
myController = screenParent;
}
#FXML
private void goToMain(ActionEvent event){
myController.setScreen(ScreensFramework.MAIN_SCREEN);
}
}
PROBLEM BELOW
When I run my program it works fine, but then if I click on a button that activates the calendar onclick code here:
#FXML protected void mouseclickedcal(MouseEvent mec){
myController.setScreen(ScreensFramework.calendarScreen);
}
which should set the screen to CalendarScreen.fxml,one of my multi screens but instead, it causes an error below:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$ClickGenerator.postProcess(Unknown Source)
at javafx.scene.Scene$ClickGenerator.access$8600(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1900(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
at com.sun.glass.ui.win.WinApplication$3$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
... 31 more
Caused by: java.lang.NullPointerException
at myfxml.MyFXMLController.mouseclickedcal(MyFXMLController.java:125)
... 40 more
Line 125 is the code:
#FXML protected void mouseclickedcal(MouseEvent mec){
myController.setScreen(ScreensFramework.calendarScreen);
}
Thank you so much for having a look at this. I can't seem to find the error ;(
Turns out I had 2 mains and they were conflicting and also in my xml code I was calling something that didn't exist in its controller.