在Heroku上部署JavaFX应用程序时无法打开DISPLAY错误

时间:2020-06-24 10:27:09

标签: heroku javafx

我正在尝试在heroku上部署JavaFX应用并收到此错误:

 2020-06-24T10:02:29.653205+00:00 app[web.1]: Exception in thread "main"  
        java.lang.UnsupportedOperationException: Unable to open DISPLAY
        2020-06-24T10:02:29.653920+00:00 app[web.1]: at com.sun.glass.ui.gtk.GtkApplication.lambda$new$6(GtkApplication.java:173)
        2020-06-24T10:02:29.654063+00:00 app[web.1]: at java.base/java.security.AccessController.doPrivileged(Native Method)
        2020-06-24T10:02:29.654153+00:00 app[web.1]: at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:171)
        2020-06-24T10:02:29.654239+00:00 app[web.1]: at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
        2020-06-24T10:02:29.654329+00:00 app[web.1]: at com.sun.glass.ui.Application.run(Application.java:144)
        2020-06-24T10:02:29.654429+00:00 app[web.1]: at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:258)
        2020-06-24T10:02:29.654522+00:00 app[web.1]: at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:269)
        2020-06-24T10:02:29.654606+00:00 app[web.1]: at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
        2020-06-24T10:02:29.654690+00:00 app[web.1]: at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
        2020-06-24T10:02:29.654783+00:00 app[web.1]: at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
        2020-06-24T10:02:29.654892+00:00 app[web.1]: at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        2020-06-24T10:02:29.655007+00:00 app[web.1]: at java.base/java.lang.Thread.run(Thread.java:834)

我尝试使用heroku apt buildpack安装libglu1-mesa和libgtk-3-0,并且我也尝试使用heroku-buildpack-javafx。通过安装libglu1-mesa,我克服了有关opengl的错误,但仍然出现“无法打开显示”错误。

我的pom.xml看起来像这样:

 <dependencies>

            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-graphics</artifactId>
                <version>11</version>
            </dependency>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-base</artifactId>
                <version>11</version>
            </dependency>
    
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-controls</artifactId>
                <version>11</version>
            </dependency>
    
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-fxml</artifactId>
                <version>11</version>
            </dependency>
    
    
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-swing</artifactId>
                <version>11</version>
            </dependency>
    
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.6</version>
            </dependency>
    
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>1.3.173</version>
                <scope>runtime</scope>
            </dependency>
    
    
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <scope>runtime</scope>
            </dependency>
    
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>RELEASE</version>
                <scope>runtime</scope>
            </dependency>
            
    
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.openjfx</groupId>
                    <artifactId>javafx-maven-plugin</artifactId>
                    <version>0.0.4</version>
                    <configuration>
                        <mainClass>streaming.Main</mainClass>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.2</version>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>package</phase>
                            <goals><goal>copy-dependencies</goal></goals>
                        </execution>
                    </executions>
                </plugin>
    
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>11</source>
                        <target>11</target>
                    </configuration>
                </plugin>
    
            </plugins>
    </build>

使用“ heroku本地网络”时效果很好。

有什么想法吗?

0 个答案:

没有答案