运行 javafx 应用程序的原生图像因 java.lang.ClassNotFoundException -> "Solid_TextureRGB_AlphaTest_Loader" 而失败
Running native image of javafx app fails cause of java.lang.ClassNotFoundException -> "Solid_TextureRGB_AlphaTest_Loader"
我在 windows 10 上尝试 运行 我的 javafx 应用程序的原生图像。
该应用程序启动时没有任何小部件。我只有以下日志:
[So. Jan. 31 17:10:52 MEZ 2021][INFO] ==================== RUN TASK ====================
[So. Jan. 31 17:10:52 MEZ 2021][FINE] PB Command for run until end: c:\Users\...\target\client\x86_64-windows\MyApp.exe
[So. Jan. 31 17:10:52 MEZ 2021][FINE] Start process run until end...
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] java.lang.ClassNotFoundException: com.sun.prism.shader.Solid_TextureRGB_AlphaTest_Loader
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:60)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.lang.Class.forName(DynamicHub.java:1247)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.d3d.D3DResourceFactory.createStockShader(D3DResourceFactory.java:411)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.ps.BaseShaderContext.getSpecialShader(BaseShaderContext.java:318)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.ps.BaseShaderContext.validateTextureOp(BaseShaderContext.java:579)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.ps.BaseShaderContext.validateTextureOp(BaseShaderContext.java:507)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.BaseGraphics.drawTexture(BaseGraphics.java:432)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.ps.BaseShaderGraphics.drawTexture(BaseShaderGraphics.java:139)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGRegion.paintTiles(NGRegion.java:2007)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGRegion.renderBackgroundRectangle(NGRegion.java:971)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGRegion.renderAsRectangle(NGRegion.java:754)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:575)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.lang.Thread.run(Thread.java:834)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
谁能告诉我该怎么做?
pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>15.0.1</javafx.version>
<attach.version>4.0.10</attach.version>
<client.plugin.version>0.1.36</client.plugin.version>
<javafx.plugin.version>0.0.5</javafx.plugin.version>
<mainClassName>MyApp</mainClassName>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq</groupId>
<artifactId>charm-glisten</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>display</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>lifecycle</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>statusbar</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>storage</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>util</artifactId>
<version>${attach.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Gluon</id>
<url>https://nexus.gluonhq.com/nexus/content/repositories/releases</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.plugin.version}</version>
<configuration>
<mainClass>${mainClassName}</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>client-maven-plugin</artifactId>
<version>${client.plugin.version}</version>
<configuration>
<target>${client.target}</target>
<enableSWRendering>true</enableSWRendering>
<attachList>
<list>display</list>
<list>lifecycle</list>
<list>statusbar</list>
<list>storage</list>
</attachList>
<resourcesList>
<list>.*\.txt</list>
</resourcesList>
<mainClass>${mainClassName}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>desktop</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<client.target>host</client.target>
</properties>
<dependencies>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>display</artifactId>
<version>${attach.version}</version>
<classifier>desktop</classifier>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>lifecycle</artifactId>
<version>${attach.version}</version>
<classifier>desktop</classifier>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>storage</artifactId>
<version>${attach.version}</version>
<classifier>desktop</classifier>
</dependency>
</dependencies>
</profile>
<profile>
<id>ios</id>
<properties>
<client.target>ios</client.target>
</properties>
</profile>
<profile>
<id>android</id>
<properties>
<client.target>android</client.target>
</properties>
</profile>
</profiles>
再次感谢何塞佩雷达。我在我的 pom.xml 中将 class com.sun.prism.shader.Solid_TextureRGB_AlphaTest_Loader
添加到 <reflectionList/>
并且有效。
我在 windows 10 上尝试 运行 我的 javafx 应用程序的原生图像。
该应用程序启动时没有任何小部件。我只有以下日志:
[So. Jan. 31 17:10:52 MEZ 2021][INFO] ==================== RUN TASK ====================
[So. Jan. 31 17:10:52 MEZ 2021][FINE] PB Command for run until end: c:\Users\...\target\client\x86_64-windows\MyApp.exe
[So. Jan. 31 17:10:52 MEZ 2021][FINE] Start process run until end...
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] java.lang.ClassNotFoundException: com.sun.prism.shader.Solid_TextureRGB_AlphaTest_Loader
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:60)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.lang.Class.forName(DynamicHub.java:1247)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.d3d.D3DResourceFactory.createStockShader(D3DResourceFactory.java:411)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.ps.BaseShaderContext.getSpecialShader(BaseShaderContext.java:318)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.ps.BaseShaderContext.validateTextureOp(BaseShaderContext.java:579)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.ps.BaseShaderContext.validateTextureOp(BaseShaderContext.java:507)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.BaseGraphics.drawTexture(BaseGraphics.java:432)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.prism.impl.ps.BaseShaderGraphics.drawTexture(BaseShaderGraphics.java:139)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGRegion.paintTiles(NGRegion.java:2007)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGRegion.renderBackgroundRectangle(NGRegion.java:971)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGRegion.renderAsRectangle(NGRegion.java:754)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:575)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at java.lang.Thread.run(Thread.java:834)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
[So. Jan. 31 17:10:53 MEZ 2021][INFO] [SUB] at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
谁能告诉我该怎么做?
pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>15.0.1</javafx.version>
<attach.version>4.0.10</attach.version>
<client.plugin.version>0.1.36</client.plugin.version>
<javafx.plugin.version>0.0.5</javafx.plugin.version>
<mainClassName>MyApp</mainClassName>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq</groupId>
<artifactId>charm-glisten</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>display</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>lifecycle</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>statusbar</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>storage</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>util</artifactId>
<version>${attach.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Gluon</id>
<url>https://nexus.gluonhq.com/nexus/content/repositories/releases</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.plugin.version}</version>
<configuration>
<mainClass>${mainClassName}</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>client-maven-plugin</artifactId>
<version>${client.plugin.version}</version>
<configuration>
<target>${client.target}</target>
<enableSWRendering>true</enableSWRendering>
<attachList>
<list>display</list>
<list>lifecycle</list>
<list>statusbar</list>
<list>storage</list>
</attachList>
<resourcesList>
<list>.*\.txt</list>
</resourcesList>
<mainClass>${mainClassName}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>desktop</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<client.target>host</client.target>
</properties>
<dependencies>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>display</artifactId>
<version>${attach.version}</version>
<classifier>desktop</classifier>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>lifecycle</artifactId>
<version>${attach.version}</version>
<classifier>desktop</classifier>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>storage</artifactId>
<version>${attach.version}</version>
<classifier>desktop</classifier>
</dependency>
</dependencies>
</profile>
<profile>
<id>ios</id>
<properties>
<client.target>ios</client.target>
</properties>
</profile>
<profile>
<id>android</id>
<properties>
<client.target>android</client.target>
</properties>
</profile>
</profiles>
再次感谢何塞佩雷达。我在我的 pom.xml 中将 class com.sun.prism.shader.Solid_TextureRGB_AlphaTest_Loader
添加到 <reflectionList/>
并且有效。