Hey Leute,
also bei mir ist gerade der Wurm drin, oder ich bin blind.
Bitte um Hilfe bei folgender Exception:
Caused by: javafx.fxml.LoadException:
$path/resources/main/fxml/user-box.fxml
$path/resources/main/fxml/detail-box.fxml:17
$path/resources/main/fxml/main-window.fxml:9
usw. usf.
Caused by: java.lang.IllegalArgumentException: Can not set javafx.scene.control.Label field $package.controller.UserBoxController.location to java.net.URL
Meldung ist mir an sich klar, im UserBoxController ist ein Feld “location” als Label deklariert. Allerdings scheint er in der FXML eine URL vorzufinden und das Injecten schlägt fehl?
Hier noch einmal die komplette Exception. Vorweg ich hab den kompletten Package-Pfad abgekürzt ($package), bzw. Datei-Pfade mit $path und MyApplication ist halt der Entry Point
der JavaFX Anwendung.
[spoiler]
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:497)
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:497)
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$152(LauncherImpl.java:182)
at com.sun.javafx.application.LauncherImpl$$Lambda$50/1323468230.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
$path/resources/main/fxml/user-box.fxml
$path/resources/main/fxml/detail-box.fxml:17
$path/resources/main/fxml/main-window.fxml:9
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2583)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.access$2700(FXMLLoader.java:104)
at javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:1139)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:742)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.access$2700(FXMLLoader.java:104)
at javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:1139)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:742)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2711)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2531)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2413)
at MyApplication.start(MyApplication.java:58)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$53/703873231.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/186276003.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1660695354.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/237061348.run(Unknown Source)
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$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/2117255219.run(Unknown Source)
... 1 more
Caused by: java.lang.IllegalArgumentException: Can not set javafx.scene.control.Label field $package.controller.UserBoxController.location to java.net.URL
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:764)
at javafx.fxml.FXMLLoader.injectFields(FXMLLoader.java:1159)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2558)
... 29 more
Exception running application MyApplication
[/spoiler]
Hier der UserBoxController
[spoiler]
package $package.controller;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.text.Text;
import $package.model.User;
public class UserBoxController {
private static final int AVATAR_SIZE = 250;
@FXML private Label username;
@FXML private Label index;
@FXML private Label infection;
@FXML private ImageView avatar;
@FXML private Label location;
@FXML private Text bio;
public final void updateUser(final User user) {
username.setText(user.getName());
index.setText(String.valueOf(user.getKarma()));
infection.setText("You can infect " + user.getCanInfect() + " people.");
if (user.getAvatar() != null && !user.getAvatar().isEmpty()) {
avatar.setImage(new Image(user.getAvatar(),
AVATAR_SIZE, AVATAR_SIZE, true, true, true));
}
location.setText(user.getCity() + ", " + user.getCountry());
bio.setText(user.getBio());
}
}
[/spoiler]
Und hier die zugehörige FXML:
[spoiler]
[xml]
<ScrollPane styleClass="scrollpane-custom">
<VBox spacing="20">
<padding>
<Insets left="10" right="10" bottom="10" top="10"/>
</padding>
<VBox spacing="10" styleClass="block">
<Label fx:id="username" styleClass="big-centered-label, blue-label" text="Name of the User"/>
<Label fx:id="index" styleClass="big-centered-label" text="10 000"/>
<Label fx:id="infection" styleClass="centered-label" text="Their/You can infext X people."/>
</VBox>
<VBox alignment="CENTER" spacing="10" styleClass="block">
<padding>
<Insets bottom="10" left="10" right="10" top="10"/>
</padding>
<Separator prefHeight="1"/>
<ImageView fx:id="avatar" fitHeight="250" fitWidth="250" preserveRatio="true">
<Image url="@../images/user-default.png" />
</ImageView>
<Label fx:id="location" styleClass="right-align-label, blue-label" text="City, Country" />
<Separator prefHeight="1"/>
</VBox>
<VBox spacing="10" styleClass="block">
<padding>
<Insets bottom="10" left="10" right="10" top="10"/>
</padding>
<Label styleClass="big-left-label, blue-label" text="Bio:"/>
<Text fx:id="bio" fill="#9B9B93" fontSmoothingType="lcd"
text="Lorem ipsum dolor sit amet."
wrappingWidth="250">
</Text>
</VBox>
</VBox>
</ScrollPane>
[/xml]
[/spoiler]
Wäre super, wenn da mal jemand rübergucken kann. Irgendwas entgeht mir wohl oder ich schaue an der falschen Stelle.