可以从Payara-Micro-Maven-Plugin启动Pareara Micro,获得“无支持的JDK”

发布于 2025-01-27 22:49:07 字数 5901 浏览 2 评论 0原文

我整理了一个示例项目,以演示我遇到的问题。

https://github.com/johnmanko/johnmanko/payara-payara-micro-plugin-plugin-glugin-group

基本上,我正在尝试在开发过程中通过Payara Micro的Maven插件启动我的应用程序。这是pom.xml config:

<plugin>
                <groupId>fish.payara.maven.plugins</groupId>
                <artifactId>payara-micro-maven-plugin</artifactId>
                <version>1.4.0</version>
                <configuration>
                    <useUberJar>false</useUberJar>
                    <contextRoot>/myapp</contextRoot>
                    <payaraVersion>${version.payara}</payaraVersion>
                    <deployWar>false</deployWar>
                    <artifactItem>
                        <groupId>fish.payara.extras</groupId>
                        <artifactId>payara-micro</artifactId>
                        <version>${version.payara.micro}</version>
                    </artifactItem>
                    <javaCommandLineOptions>
                        <option>
                            <value>-Xdebug</value>
                        </option>
                    </javaCommandLineOptions>
                    <commandLineOptions>
                        <option>
                            <key>--autoBindHttp</key>
                        </option>
                        <option>
                            <key>--nocluster</key>
                        </option>
                        <option>
                            <key>--port</key>
                            <value>8095</value>
                        </option>
                        <option>
                            <key>--prebootcommandfile</key>
                            <value>${project.basedir}/src/main/resources/pre-boot-commands.txt</value>
                        </option>
                        <option>
                            <key>--postbootcommandfile</key>
                            <value>${project.basedir}/src/main/resources/post-boot-commands.txt</value>
                        </option>
                        <option>
                            <key>--deploy</key>
                            <value>${project.build.directory}/${project.build.finalName}</value>
                        </option>
                    </commandLineOptions>
                </configuration>
            </plugin>

结果:结果是:

[2022-05-11T09:54:58.362-0400] [] [SEVERE] [] [org.eclipse.persistence.session./file:/path/to/payara-micro-plugin-group/payara-micro-plugin-example/target/payara-micro-plugin-example-1.0.0-SNAPSHOT/WEB-INF/classes/_MyAppPU.metadata] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1652277298362] [levelValue: 1000] [[
  The java.lang.Object class was compiled with an unsupported JDK. Report this error to the EclipseLink open source project.
java.lang.ArrayIndexOutOfBoundsException: Index 8 out of bounds for length 0
    at org.eclipse.persistence.internal.libraries.asm.ClassReader.readUnsignedShort(ClassReader.java:3573)


[2022-05-11T09:54:58.364-0400] [] [WARNING] [] [org.eclipse.persistence.session./file:/path/to/payara-micro-plugin-group/payara-micro-plugin-example/target/payara-micro-plugin-example-1.0.0-SNAPSHOT/WEB-INF/classes/_MyAppPU.metadata] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1652277298364] [levelValue: 900] [[
  The java.lang.String class was compiled with an unsupported JDK. Report this error to the EclipseLink open source project.
java.lang.IllegalArgumentException: Unsupported class file major version 62
    at org.eclipse.persistence.internal.libraries.asm.ClassReader.<init>(ClassReader.java:196)


[2022-05-11T09:54:58.372-0400] [] [WARNING] [] [org.eclipse.persistence.session./file:/path/to/payara-micro-plugin-group/payara-micro-plugin-example/target/payara-micro-plugin-example-1.0.0-SNAPSHOT/WEB-INF/classes/_MyAppPU.metadata] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1652277298372] [levelValue: 900] [[
  The java.lang.Long class was compiled with an unsupported JDK. Report this error to the EclipseLink open source project.
java.lang.IllegalArgumentException: Unsupported class file major version 62
    at org.eclipse.persistence.internal.libraries.asm.ClassReader.<init>(ClassReader.java:196)


[2022-05-11T09:54:58.379-0400] [] [WARNING] [] [org.eclipse.persistence.session./file:/path/to/payara-micro-plugin-group/payara-micro-plugin-example/target/payara-micro-plugin-example-1.0.0-SNAPSHOT/WEB-INF/classes/_MyAppPU.metadata] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1652277298379] [levelValue: 900] [[
  The java.lang.Number class was compiled with an unsupported JDK. Report this error to the EclipseLink open source project.
java.lang.IllegalArgumentException: Unsupported class file major version 62
    at org.eclipse.persistence.internal.libraries.asm.ClassReader.<init>(ClassReader.java:196)

该项目是用JDK 1.8构建的,MAVEN的开始是将JAVA_HOME设置为JDK 1.8:

DATABASE_USER=user \
DATABASE_PASS=password \
DATABASE_NAME=MY_DB_NAME \
DATABASE_SERVER=localhost \
DATABASE_SERVER_PORT=1234 \
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \
M2_HOME=/usr/share/maven \
/usr/share/maven/bin/mvn payara-micro:start

系统默认值为Java 18,但我DON t看看这甚至可以发挥作用。所有包含的应用程序依赖项均使用JDK 1.8或更早(我检查了每个)。

为什么要拿起主要版本62?

I put together a sample project to demonstrate the issue I'm having.

https://github.com/johnmanko/payara-micro-plugin-group

Basically, I'm trying to launch my app via payara micro's maven plugin during development. Here is the pom.xml config:

<plugin>
                <groupId>fish.payara.maven.plugins</groupId>
                <artifactId>payara-micro-maven-plugin</artifactId>
                <version>1.4.0</version>
                <configuration>
                    <useUberJar>false</useUberJar>
                    <contextRoot>/myapp</contextRoot>
                    <payaraVersion>${version.payara}</payaraVersion>
                    <deployWar>false</deployWar>
                    <artifactItem>
                        <groupId>fish.payara.extras</groupId>
                        <artifactId>payara-micro</artifactId>
                        <version>${version.payara.micro}</version>
                    </artifactItem>
                    <javaCommandLineOptions>
                        <option>
                            <value>-Xdebug</value>
                        </option>
                    </javaCommandLineOptions>
                    <commandLineOptions>
                        <option>
                            <key>--autoBindHttp</key>
                        </option>
                        <option>
                            <key>--nocluster</key>
                        </option>
                        <option>
                            <key>--port</key>
                            <value>8095</value>
                        </option>
                        <option>
                            <key>--prebootcommandfile</key>
                            <value>${project.basedir}/src/main/resources/pre-boot-commands.txt</value>
                        </option>
                        <option>
                            <key>--postbootcommandfile</key>
                            <value>${project.basedir}/src/main/resources/post-boot-commands.txt</value>
                        </option>
                        <option>
                            <key>--deploy</key>
                            <value>${project.build.directory}/${project.build.finalName}</value>
                        </option>
                    </commandLineOptions>
                </configuration>
            </plugin>

The result is the following:

[2022-05-11T09:54:58.362-0400] [] [SEVERE] [] [org.eclipse.persistence.session./file:/path/to/payara-micro-plugin-group/payara-micro-plugin-example/target/payara-micro-plugin-example-1.0.0-SNAPSHOT/WEB-INF/classes/_MyAppPU.metadata] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1652277298362] [levelValue: 1000] [[
  The java.lang.Object class was compiled with an unsupported JDK. Report this error to the EclipseLink open source project.
java.lang.ArrayIndexOutOfBoundsException: Index 8 out of bounds for length 0
    at org.eclipse.persistence.internal.libraries.asm.ClassReader.readUnsignedShort(ClassReader.java:3573)


[2022-05-11T09:54:58.364-0400] [] [WARNING] [] [org.eclipse.persistence.session./file:/path/to/payara-micro-plugin-group/payara-micro-plugin-example/target/payara-micro-plugin-example-1.0.0-SNAPSHOT/WEB-INF/classes/_MyAppPU.metadata] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1652277298364] [levelValue: 900] [[
  The java.lang.String class was compiled with an unsupported JDK. Report this error to the EclipseLink open source project.
java.lang.IllegalArgumentException: Unsupported class file major version 62
    at org.eclipse.persistence.internal.libraries.asm.ClassReader.<init>(ClassReader.java:196)


[2022-05-11T09:54:58.372-0400] [] [WARNING] [] [org.eclipse.persistence.session./file:/path/to/payara-micro-plugin-group/payara-micro-plugin-example/target/payara-micro-plugin-example-1.0.0-SNAPSHOT/WEB-INF/classes/_MyAppPU.metadata] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1652277298372] [levelValue: 900] [[
  The java.lang.Long class was compiled with an unsupported JDK. Report this error to the EclipseLink open source project.
java.lang.IllegalArgumentException: Unsupported class file major version 62
    at org.eclipse.persistence.internal.libraries.asm.ClassReader.<init>(ClassReader.java:196)


[2022-05-11T09:54:58.379-0400] [] [WARNING] [] [org.eclipse.persistence.session./file:/path/to/payara-micro-plugin-group/payara-micro-plugin-example/target/payara-micro-plugin-example-1.0.0-SNAPSHOT/WEB-INF/classes/_MyAppPU.metadata] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1652277298379] [levelValue: 900] [[
  The java.lang.Number class was compiled with an unsupported JDK. Report this error to the EclipseLink open source project.
java.lang.IllegalArgumentException: Unsupported class file major version 62
    at org.eclipse.persistence.internal.libraries.asm.ClassReader.<init>(ClassReader.java:196)

The project is built with JDK 1.8, and maven is started with setting JAVA_HOME to JDK 1.8:

DATABASE_USER=user \
DATABASE_PASS=password \
DATABASE_NAME=MY_DB_NAME \
DATABASE_SERVER=localhost \
DATABASE_SERVER_PORT=1234 \
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \
M2_HOME=/usr/share/maven \
/usr/share/maven/bin/mvn payara-micro:start

The system default is Java 18, but I don't see how that can even come into play. All included application dependencies were compiled with JDK 1.8 or earlier (I checked each one).

Why would it be picking up major version 62?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南城旧梦 2025-02-03 22:49:07

我找到了原因。该插件使用 apache工具链/code>,它发现错误的一个(即系统一个)。

一种解决方案是添加插件&lt; javapath&gt;选项:

                <configuration>
                    <useUberJar>false</useUberJar>
                    <contextRoot>/myapp</contextRoot>
                    <payaraVersion>${version.payara}</payaraVersion>
                    <deployWar>false</deployWar>                    
                    <javaPath>/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java</javaPath>

当然,这对Mac Windows等其他系统上的开发人员不起作用。

适当的方法是配置〜/.m2/toolchains.xml文件并设置工具链在POM中使用它。

〜/.m2/toolchains.xml

<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
    <!-- JDK toolchains -->
    <toolchain>
        <type>jdk</type>
        <provides>
            <version>1.8</version>
            <vendor>openjdk</vendor>
        </provides>
        <configuration>
            <jdkHome>/usr/lib/jvm/java-1.8.0-openjdk-amd64</jdkHome>
        </configuration>
    </toolchain>
    <toolchain>
        <type>jdk</type>
        <provides>
            <version>11</version>
            <vendor>openjdk</vendor>
        </provides>
        <configuration>
            <jdkHome>/usr/lib/jvm/java-11-openjdk-amd64</jdkHome>
        </configuration>
    </toolchain>
    <toolchain>
        <type>jdk</type>
        <provides>
            <version>18</version>
            <vendor>openjdk</vendor>
        </provides>
        <configuration>
            <jdkHome>/usr/lib/jvm/java-18-openjdk-amd64</jdkHome>
        </configuration>
    </toolchain>
</toolchains>

pom.xml


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolchains>
                        <jdk>
                            <version>1.8</version>
                            <vendor>openjdk</vendor>
                        </jdk>
                    </toolchains>
                </configuration>
            </plugin>
            <plugin>
                <groupId>fish.payara.maven.plugins</groupId>
                <artifactId>payara-micro-maven-plugin</artifactId>
                <version>1.4.0</version>
                <configuration>
                    <useUberJar>false</useUberJar>
                    <contextRoot>/myapp</contextRoot>
                    <payaraVersion>${version.payara}</payaraVersion>
                    <deployWar>false</deployWar>                    
                    <artifactItem>
                        <groupId>fish.payara.extras</groupId>
                        <artifactId>payara-micro</artifactId>
                        <version>${version.payara.micro}</version>
                    </artifactItem>
                    <javaCommandLineOptions>
                        <option>
                            <value>-Xdebug</value>
                        </option>
                    </javaCommandLineOptions>
                    <commandLineOptions>
                        <option>
                            <key>--nocluster</key>
                        </option>
                        <option>
                            <key>--port</key>
                            <value>8095</value>
                        </option>
                        <option>
                            <key>--postbootcommandfile</key>
                            <value>${project.basedir}/src/main/resources/post-boot-commands.txt</value>
                        </option>
                        <option>
                            <key>--deploy</key>
                            <value>${project.build.directory}/${project.build.finalName}</value>
                        </option>
                    </commandLineOptions>
                </configuration>
            </plugin>

使用nbactions.xml

<?xml version="1.0" encoding="UTF-8"?>
<actions>
    <action>
        <actionName>CUSTOM-toolchains:toolchain payara-micro:start (with DB)</actionName>
        <displayName>toolchains:toolchain payara-micro:start (with DB)</displayName>
        <goals>
            <goal>toolchains:toolchain</goal>
            <goal>payara-micro:start</goal>
        </goals>
        <properties>
            <Env.DATABASE_USER>user</Env.DATABASE_USER>
            <Env.DATABASE_PASS>password</Env.DATABASE_PASS>
            <Env.DATABASE_NAME>DATABASE</Env.DATABASE_NAME>
            <Env.DATABASE_SERVER>localhost</Env.DATABASE_SERVER>
            <Env.DATABASE_SERVER_PORT>1234</Env.DATABASE_SERVER_PORT>
        </properties>
    </action>
</actions>

使用commandline启动:

DATABASE_USER=user \
DATABASE_PASS=password \
DATABASE_NAME=MY_DB_NAME \
DATABASE_SERVER=localhost \
DATABASE_SERVER_PORT=1234 \
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \
M2_HOME=/usr/share/maven \
/usr/share/maven/bin/mvn toolchains:toolchain payara-micro:start

I found the cause. The plugin uses Apache Toolchain to locate java, and it's finding the wrong one (ie, the system one).

One solution is to add the plugin <javaPath> option:

                <configuration>
                    <useUberJar>false</useUberJar>
                    <contextRoot>/myapp</contextRoot>
                    <payaraVersion>${version.payara}</payaraVersion>
                    <deployWar>false</deployWar>                    
                    <javaPath>/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java</javaPath>

Of course, that won't work for devs on other systems like Windows of Mac.

The proper way is configure a ~/.m2/toolchains.xml file and set up Toolchain in the pom to use that.

~/.m2/toolchains.xml:

<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
    <!-- JDK toolchains -->
    <toolchain>
        <type>jdk</type>
        <provides>
            <version>1.8</version>
            <vendor>openjdk</vendor>
        </provides>
        <configuration>
            <jdkHome>/usr/lib/jvm/java-1.8.0-openjdk-amd64</jdkHome>
        </configuration>
    </toolchain>
    <toolchain>
        <type>jdk</type>
        <provides>
            <version>11</version>
            <vendor>openjdk</vendor>
        </provides>
        <configuration>
            <jdkHome>/usr/lib/jvm/java-11-openjdk-amd64</jdkHome>
        </configuration>
    </toolchain>
    <toolchain>
        <type>jdk</type>
        <provides>
            <version>18</version>
            <vendor>openjdk</vendor>
        </provides>
        <configuration>
            <jdkHome>/usr/lib/jvm/java-18-openjdk-amd64</jdkHome>
        </configuration>
    </toolchain>
</toolchains>

pom.xml


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolchains>
                        <jdk>
                            <version>1.8</version>
                            <vendor>openjdk</vendor>
                        </jdk>
                    </toolchains>
                </configuration>
            </plugin>
            <plugin>
                <groupId>fish.payara.maven.plugins</groupId>
                <artifactId>payara-micro-maven-plugin</artifactId>
                <version>1.4.0</version>
                <configuration>
                    <useUberJar>false</useUberJar>
                    <contextRoot>/myapp</contextRoot>
                    <payaraVersion>${version.payara}</payaraVersion>
                    <deployWar>false</deployWar>                    
                    <artifactItem>
                        <groupId>fish.payara.extras</groupId>
                        <artifactId>payara-micro</artifactId>
                        <version>${version.payara.micro}</version>
                    </artifactItem>
                    <javaCommandLineOptions>
                        <option>
                            <value>-Xdebug</value>
                        </option>
                    </javaCommandLineOptions>
                    <commandLineOptions>
                        <option>
                            <key>--nocluster</key>
                        </option>
                        <option>
                            <key>--port</key>
                            <value>8095</value>
                        </option>
                        <option>
                            <key>--postbootcommandfile</key>
                            <value>${project.basedir}/src/main/resources/post-boot-commands.txt</value>
                        </option>
                        <option>
                            <key>--deploy</key>
                            <value>${project.build.directory}/${project.build.finalName}</value>
                        </option>
                    </commandLineOptions>
                </configuration>
            </plugin>

Launch using nbactions.xml:

<?xml version="1.0" encoding="UTF-8"?>
<actions>
    <action>
        <actionName>CUSTOM-toolchains:toolchain payara-micro:start (with DB)</actionName>
        <displayName>toolchains:toolchain payara-micro:start (with DB)</displayName>
        <goals>
            <goal>toolchains:toolchain</goal>
            <goal>payara-micro:start</goal>
        </goals>
        <properties>
            <Env.DATABASE_USER>user</Env.DATABASE_USER>
            <Env.DATABASE_PASS>password</Env.DATABASE_PASS>
            <Env.DATABASE_NAME>DATABASE</Env.DATABASE_NAME>
            <Env.DATABASE_SERVER>localhost</Env.DATABASE_SERVER>
            <Env.DATABASE_SERVER_PORT>1234</Env.DATABASE_SERVER_PORT>
        </properties>
    </action>
</actions>

Launch using commandline:

DATABASE_USER=user \
DATABASE_PASS=password \
DATABASE_NAME=MY_DB_NAME \
DATABASE_SERVER=localhost \
DATABASE_SERVER_PORT=1234 \
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \
M2_HOME=/usr/share/maven \
/usr/share/maven/bin/mvn toolchains:toolchain payara-micro:start
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文