简体   繁体   English

运行应用程序时出现 JavaFX IllegalAccessError

[英]JavaFX IllegalAccessError on running application

I have a JavaFx 14 application running on JDK 14. I created a jlink runtime version that has the only the required modules I need to run the application on both Mac and Wins 10.我有一个在 JDK 14 上运行的 JavaFx 14 应用程序。我创建了一个 jlink 运行时版本,该版本只有在 Mac 和 Wins 10 上运行该应用程序所需的模块。

I wanted to add a PreLoader to show users while the background processes finish.我想添加一个 PreLoader 在后台进程完成时向用户显示。

I test primarily on Mac OS and then try it on Windows to verify that it still works.我主要在 Mac OS 上进行测试,然后在 Windows 上尝试以验证它是否仍然有效。

After changing the start from Application.launch(TripsFxApplication.class, args) to LauncherImpl.launchApplication(TripsFxApplication.class, TripsPreloader.class, args) , I started seeing this exception trace (scan down).将开始从Application.launch(TripsFxApplication.class, args)更改为LauncherImpl.launchApplication(TripsFxApplication.class, TripsPreloader.class, args) ,我开始看到此异常跟踪(向下扫描)。

This is my bat file to run it:这是我运行它的 bat 文件:

jre\bin\java -p javafx-sdk-14.0.2.1\lib --add-modules javafx.controls,javafx.base,javafx.fxml,javafx.graphics,javafx.media,javafx.web --add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED --add-exports javafx.base/com.sun.javafx.event=ALL-UNNAMED -jar trips.jar

Now the same application works fine on Mac OSX and I see my preloader there, but on Windows 10, I get this error.现在相同的应用程序在 Mac OSX 上运行良好,我在那里看到我的预加载器,但在 Windows 10 上,我收到此错误。 Is there some extra module that I am missing to add in the bat file above?上面的 bat 文件中是否有一些我缺少添加的额外模块?

Exception trace异常跟踪

jre\bin\java -p javafx-sdk-14.0.2.1\lib --add-modules javafx.controls,javafx.base,javafx.fxml,javafx.graphics,javafx.media,javafx.web --add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-exports javafx.base/com.sun.javafx.event=ALL-UNNAMED -jar trips.jar
09:49:17,597 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:49:17,597 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:49:17,598 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/Z:/larrymitchell%20On%20My%20Mac/tripsnew/wintripsruntime/trips.jar!/BOOT-INF/classes!/logback.xml]
09:49:17,908 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@73a1e9a9 - URL [jar:file:/Z:/larrymitchell%20On%20My%20Mac/tripsnew/wintripsruntime/trips.jar!/BOOT-INF/classes!/logback.xml] is not of type file
09:49:18,544 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
09:49:18,662 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework] to INFO
09:49:18,662 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.security.oauth2] to INFO
09:49:18,662 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.integration] to OFF
09:49:18,663 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.oxm] to OFF
09:49:18,663 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.http] to ERROR
09:49:18,663 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.elasticsearch.bootstrap] to ERROR
09:49:18,664 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@71d44a3 - Adding [jar:file:/Z:/larrymitchell%20On%20My%20Mac/tripsnew/wintripsruntime/trips.jar!/BOOT-INF/classes!/logbackbase.xml] to configuration watch list.
09:49:18,664 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@73a1e9a9 - URL [jar:file:/Z:/larrymitchell%20On%20My%20Mac/tripsnew/wintripsruntime/trips.jar!/BOOT-INF/classes!/logbackbase.xml] is not of type file
09:49:18,667 |-INFO in ch.qos.logback.classic.joran.action.JMXConfiguratorAction - begin
09:49:18,832 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word clr with class [org.springframework.boot.logging.logback.ColorConverter]
09:49:18,835 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.startup.DigesterFactory] to ERROR
09:49:18,835 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.util.LifecycleBase] to ERROR
09:49:18,835 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.coyote.http11.Http11NioProtocol] to WARN
09:49:18,835 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.sshd.common.util.SecurityUtils] to WARN
09:49:18,835 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.tomcat.util.net.NioSelectorPool] to WARN
09:49:18,835 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.validator.internal.util.Version] to WARN
09:49:18,835 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
09:49:18,845 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]
09:49:18,858 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:49:19,178 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
09:49:19,246 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
09:49:19,249 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:49:19,300 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@2073621255 - Will use gz compression
09:49:19,303 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@2073621255 - Will use the pattern logs/terranrepublicviewer.log.%d{yyyy-MM-dd}.log for the active file
09:49:19,311 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern 'logs/terranrepublicviewer.log.%d{yyyy-MM-dd}.log.gz'.
09:49:19,311 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
09:49:19,317 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Mon Oct 05 09:33:15 EDT 2020
09:49:19,325 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1208121709 - Will use gz compression
09:49:19,325 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1208121709 - Will use the pattern logs/terranrepublicviewer.log.%d{yyyy-MM-dd}.%i.log for the active file
09:49:19,326 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@34123d65 - The date pattern is 'yyyy-MM-dd' from file name pattern 'logs/terranrepublicviewer.log.%d{yyyy-MM-dd}.%i.log.gz'.
09:49:19,326 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@34123d65 - Roll-over at midnight.
09:49:19,327 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@34123d65 - Setting initial period to Mon Oct 05 09:33:15 EDT 2020
09:49:19,328 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@34123d65 - SizeAndTimeBasedFNATP is deprecated. Use SizeAndTimeBasedRollingPolicy instead
09:49:19,328 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@34123d65 - For more information see http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy
09:49:19,336 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: logs/terranrepublicviewer.log
09:49:19,336 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [logs/terranrepublicviewer.log]
09:49:19,339 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - ROOT level set to INFO
09:49:19,340 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
09:49:19,341 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]
09:49:19,341 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
09:49:19,341 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@59474f18 - Registering current configuration as safe fallback point

Exception in thread "main" 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:564)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:109)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.lang.IllegalAccessError: class com.teamgannon.trips.TripsSpringBootApplication (in unnamed module @0x639c2c1d) cannot access class com.sun.javafx.application.LauncherImpl (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.application to unnamed module @0x639c2c1d
        at com.teamgannon.trips.TripsSpringBootApplication.main(TripsSpringBootApplication.java:32)
        ... 8 more
Z:\larrymitchell On My Mac\tripsnew\wintripsruntime>

ok, I searched around and if you want to use a PreLoader in a JDK 9+ modular environment, then you have to do it this way好的,我搜索了一下,如果你想在 JDK 9+ 模块化环境中使用 PreLoader,那么你必须这样做

 System.setProperty("javafx.preloader", "com.teamgannon.trips.javafxsupport.TripsPreloader"); Application.launch(TripsFxApplication.class, args);
Application will look for the property holding the preloader and insert it correctly. 应用程序将查找持有预加载器的属性并正确插入它。 This should be documented better but there you go. 这应该更好地记录在案,但你去了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM