Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View cannot be loaded if the name is only 'View' #48

Open
deen13 opened this issue Jan 11, 2018 · 1 comment
Open

View cannot be loaded if the name is only 'View' #48

deen13 opened this issue Jan 11, 2018 · 1 comment

Comments

@deen13
Copy link

deen13 commented Jan 11, 2018

While writing a One Page JavaFX application, I noticed that a View named 'View' can not be loaded. The application then crashes with a IllegalStateException.

Stacktrace:

java.lang.IllegalStateException: Cannot load 
	at de.felixroske.jfxsupport.AbstractFxmlView.loadSynchronously(AbstractFxmlView.java:161) ~[springboot-javafx-support-1.4.0.jar:na]
	at de.felixroske.jfxsupport.AbstractFxmlView.ensureFxmlLoaderInitialized(AbstractFxmlView.java:176) ~[springboot-javafx-support-1.4.0.jar:na]
	at de.felixroske.jfxsupport.AbstractFxmlView.getView(AbstractFxmlView.java:188) ~[springboot-javafx-support-1.4.0.jar:na]
	at de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport.showView(AbstractJavaFxApplicationSupport.java:202) [springboot-javafx-support-1.4.0.jar:na]
	at de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport.showInitialView(AbstractJavaFxApplicationSupport.java:177) [springboot-javafx-support-1.4.0.jar:na]
	at de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport.lambda$start$4(AbstractJavaFxApplicationSupport.java:144) [springboot-javafx-support-1.4.0.jar:na]
	at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) ~[jfxrt.jar:na]
	at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_131]
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) ~[jfxrt.jar:na]
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) ~[jfxrt.jar:na]
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) ~[jfxrt.jar:na]
	at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) ~[jfxrt.jar:na]
	at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_131]
Caused by: java.lang.IllegalStateException: Location is not set.
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434) ~[jfxrt.jar:na]
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409) ~[jfxrt.jar:na]
	at de.felixroske.jfxsupport.AbstractFxmlView.loadSynchronously(AbstractFxmlView.java:159) ~[springboot-javafx-support-1.4.0.jar:na]
	... 12 common frames omitted

Cause:
The AbstractFxmlView tries to resolve the fxml path by itself if its not set by the annotation and thereby cuts 'View' out of the path. The path of a view called 'View' then will point to the parent directory.

private static String stripEnding(final String clazz) {

	if (!clazz.endsWith("view")) {
		return clazz;
	}

	return clazz.substring(0, clazz.lastIndexOf("view"));
}
@roskenet
Copy link
Owner

This is true.
Will add a check, that the resulting substring should never be stripped down until it's empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants