Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaFX应用程序线程-使用Glion Ignite依赖项注入时_Java_Javafx_Dependency Injection_Gluon Mobile_Javafxports - Fatal编程技术网

JavaFX应用程序线程-使用Glion Ignite依赖项注入时

JavaFX应用程序线程-使用Glion Ignite依赖项注入时,java,javafx,dependency-injection,gluon-mobile,javafxports,Java,Javafx,Dependency Injection,Gluon Mobile,Javafxports,我正在使用Gluon的Ignite依赖项注入库,当我运行这段代码时,我得到以下错误 public void initialize() { Platform.runLater(() -> { ApplicationContext context = new ClassPathXmlApplicationContext(this.getClass().getResource("DL4JBeans.xml").getPath());

我正在使用Gluon的Ignite依赖项注入库,当我运行这段代码时,我得到以下错误

public void initialize() {
    Platform.runLater(() -> {
                ApplicationContext context = new ClassPathXmlApplicationContext(this.getClass().getResource("DL4JBeans.xml").getPath());
                dL4JData = context.getBean("dL4JData", DL4JData.class);
                dL4JGlobalConfig = context.getBean("dL4JGlobalConfig", DL4JGlobalConfig.class);
                dL4JLayers = context.getBean("dL4JDataLayers", DL4JLayers.class);
                dL4JModel = context.getBean("dL4JModel", DL4JModel.class);
                ((ClassPathXmlApplicationContext) context).close();
            });
}
错误日志:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
    at se.danielmartensson.views.NeuralNetworksPresenter.lambda$initialize$6(NeuralNetworksPresenter.java:140)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication.enterNestedEventLoopImpl(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication._enterNestedEventLoop(GtkApplication.java:211)
    at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:511)
    at com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
    at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:590)
    at com.gluonhq.charm.glisten.control.Dialog.a(SourceFile:608)
    at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:182)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
    at javafx.beans.property.BooleanPropertyBase.fireValueChangedEvent(BooleanPropertyBase.java:103)
    at javafx.beans.property.ReadOnlyBooleanWrapper.fireValueChangedEvent(ReadOnlyBooleanWrapper.java:101)
    at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
    at javafx.beans.property.BooleanPropertyBase.access$000(BooleanPropertyBase.java:49)
    at javafx.beans.property.BooleanPropertyBase$Listener.invalidated(BooleanPropertyBase.java:245)
    at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:349)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
    at javafx.beans.property.BooleanPropertyBase.fireValueChangedEvent(BooleanPropertyBase.java:103)
    at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
    at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144)
    at javafx.beans.property.BooleanProperty.setValue(BooleanProperty.java:81)
    at com.gluonhq.charm.glisten.layout.Layer.show(SourceFile:285)
    at com.gluonhq.charm.glisten.control.Dialog.showAndWait(SourceFile:559)
    at com.gluonhq.impl.charm.a.e.c.b(SourceFile:77)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$5(GtkApplication.java:139)
    at java.lang.Thread.run(Thread.java:748)
这是140线

ApplicationContext context = new ClassPathXmlApplicationContext(this.getClass().getResource("DL4JBeans.xml").getPath());
它没有给出文件未找到异常,只有线程应用程序错误。 这是我的毕业档案

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.17'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'se.danielmartensson.Main'

dependencies {
    compile 'com.gluonhq:charm:5.0.2'
    compile group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '1.0.0-beta4'
    compile group: 'org.nd4j', name: 'nd4j-native-platform', version: '1.0.0-beta4'
    compile group: 'org.datavec', name: 'datavec-api', version: '1.0.0-beta4'
    compile 'com.gluonhq:ignite-spring:1.0.2'
    compile group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
}

jfxmobile {
    downConfig {
        version = '3.8.6'
        // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'se.danielmartensson.**.*',
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}
一件奇怪的事情是,即使我犯了这些错误,我仍然可以使用我刚刚注入的依赖项中的方法

以下是我的文件夹结构的图像:

更新:

getResource()
如果找不到资源,则返回
null
。 我打赌它找不到DL4JBeans.xml

DL4JBeans.xml应该是

  • 与NeuralNetworksPresenter.java位于同一文件夹中
  • 在类路径中的资源文件夹中,与NeuralNetworksPresenter位于同一个包中(即相同的文件夹结构)
getResource()
如果未找到资源,则返回
null
。 我打赌它找不到DL4JBeans.xml

DL4JBeans.xml应该是

  • 与NeuralNetworksPresenter.java位于同一文件夹中
  • 在类路径中的资源文件夹中,与NeuralNetworksPresenter位于同一个包中(即相同的文件夹结构)

嗨!JavaFX可以找到DL4JBeans.xml。它不会给出“IOException File not found”异常。getResource()不会抛出IOException,因为我从文档中可以看出,我的DL4JBean.xml位于包“”/se/danielmartensson/beans/DL4JBeans.xml中的资源文件夹中“NeuralNetworksPresenter是否在se.danielmartensson.beans包中?不。在se.danielmartensson.viewsHi!JavaFX可以找到DL4JBeans.xml。它不会给出“IOException File not found”异常。getResource()不会抛出IOException,因为我从文档中可以看出,我的DL4JBean.xml位于包“”中的资源文件夹中“/se/danielmartensson/beans/DL4JBeans.xml”是包se.danielmartensson.beans中的NeuralNetworksPresenter吗?不在se.danielmartensson.views中