我正在 Windows 上的 InteliJ 中使用 Gluon-mobile 构建应用程序,但在通过 Maven 添加其他依赖项时遇到问题。在 Windows 上,当我向 pom 文件添加新的依赖项并尝试从命令行运行 client:build 时,我开始收到 java.lang.NoClassDefFoundError 错误。
在这种情况下,我尝试使用 obs-websocket-java 模块并在我的 pom 文件中添加了依赖项。我也试过其他的,发现也有同样的问题。
错误示例
[Tue Mar 09 16:39:58 GMT-08:00 2021][INFO] We will now compile your code for x86_64-microsoft-windows. This may take some time.
[Tue Mar 09 16:39:58 GMT-08:00 2021][INFO] [SUB] Warning: Ignoring server-mode native-image argument --no-server.
[Tue Mar 09 16:40:00 GMT-08:00 2021][INFO] [SUB] [org.jdf.teamdatacollect:20756] classlist: 1,404.15 ms, 0.96 GB
[Tue Mar 09 16:40:06 GMT-08:00 2021][INFO] [SUB] [org.jdf.teamdatacollect:20756] (cap): 4,533.88 ms, 0.95 GB
[Tue Mar 09 16:40:06 GMT-08:00 2021][INFO] [SUB] [org.jdf.teamdatacollect:20756] setup: 5,221.72 ms, 0.95 GB
[Tue Mar 09 16:40:06 GMT-08:00 2021][INFO] [SUB] Error: Error parsing reflection configuration in file:/C:/Users/joshu/IdeaProjects/TeamDataCollect/target/classes/META-INF%5cnative-image%5creflect-config.json:
[Tue Mar 09 16:40:06 GMT-08:00 2021][INFO] [SUB] Could not register net.twasi.obsremotejava.OBSCommunicator: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/api/Session. To allow unresolvable reflection configuration, use option -H:+AllowIncompleteClasspath
[Tue Mar 09 16:40:06 GMT-08:00 2021][INFO] [SUB] Verify that the configuration matches the schema described in the -H:PrintFlags=+ output for option ReflectionConfigurationResources.
[Tue Mar 09 16:40:06 GMT-08:00 2021][INFO] [SUB] com.oracle.svm.core.util.UserError$UserException: Error parsing reflection configuration in file:/C:/Users/joshu/IdeaProjects/TeamDataCollect/target/classes/META-INF%5cnative-image%5creflect-config.json:
[Tue Mar 09 16:40:06 GMT-08:00 2021][INFO] [SUB] Could not register net.twasi.obsremotejava.OBSCommunicator: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/api/Session. To allow unresolvable reflection configuration, use option -H:+AllowIncompleteClasspath
[Tue Mar 09 16:40:06 GMT-08:00 2021][INFO] [SUB] Verify that the configuration matches the schema described in the -H:PrintFlags=+ output for option ReflectionConfigurationResources.
[
pom 文件
<modelVersion>4.0.0</modelVersion>
<groupId>org.jdf</groupId>
<artifactId>teamdatacollect</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TeamDataCollect</name>
<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.38</client.plugin.version>
<javafx.plugin.version>0.0.5</javafx.plugin.version>
<mainClassName>org.jdf.TeamDataCollect</mainClassName>
</properties>
<dependencies>
<dependency>
<groupId>com.hierynomus</groupId>
<artifactId>sshj</artifactId>
<version>0.31.0</version>
</dependency>
<dependency>
<groupId>net.twasi</groupId>
<artifactId>obs-websocket-java</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</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>
<attachList>
<list>display</list>
<list>lifecycle</list>
<list>statusbar</list>
<list>storage</list>
</attachList>
<reflectionList>
<list>org.jdf.views.CollectDataPresenter</list>
<list>org.jdf.views.SetupPresenter</list>
<list>org.jdf.views.StreamingPresenter</list>
</reflectionList>
<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>
</project>
我试过运行 client:runagent 但这似乎没有帮助。我在查看错误日志时发现,target\client\x86_64-windows\gvm\tmp
中的 classpathJar.jar 清单文件中的类路径不包含 obs-websocket-java 模块所依赖的所有 jar。如果我手动运行 native-image 命令替换自定义 classpathJar.jar 我能够取得进一步的进展,但仍然没有找到一个神奇的配方来构建它
我还发现 client:runagent 生成的 jni-config.json 和 reflect-config.json 似乎缺少我运行 Graalvm 代理手动生成这些时获得的许多条目.不知道有没有关系。
是否有我遗漏的步骤?任何和所有帮助表示赞赏。
约书亚