将appengine从Java 8迁移到11时出现问题

vlf7wbxs  于 2023-05-05  发布在  Java
关注(0)|答案(1)|浏览(175)

我有一个使用Java 8的遗留Google Cloud应用引擎,我需要将其迁移到Java 11。根据this guide,我计划“迁移到带有捆绑服务的Java 11/17”,所以我没有将我的appengine-web.xml迁移到app. yaml。相反,我只是简单地做了以下事情:
1.下载Java 11并更新JAVA_HOME路径
1.将appengine-web.xml更新为<runtime>java11</runtime>
1.更新了maven-compiler-plugin的pom.xml:<source>11</source> <target>11</target>
我还没有尝试使用mvn appengin:deploy进行部署,但在尝试运行本地服务器时出现以下错误:mvn appengine:run
Localhost:8080出现503 Service Unavailable。
你知道为什么在Java 11中无法启动dev服务器吗?
我已经将建议的依赖项添加到我的POM文件中,但这会给予进一步的Java错误:

[exec] [INFO] GCLOUD: SEVERE: javax.servlet.ServletContext log: unavailable
     [exec] [INFO] GCLOUD: java.lang.IllegalArgumentException
     [exec] [INFO] GCLOUD: at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
     [exec] [INFO] GCLOUD: at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
     [exec] [INFO] GCLOUD: at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
     [exec] [INFO] GCLOUD: at org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener.process(AnnotationAcceptingListener.java:170)

然后:

[exec] [INFO] GCLOUD: 2023-05-01 15:09:16.040:WARN:oejw.WebAppContext:main: Failed startup of context c.g.a.t.d.j.DevAppEngineWebAppContext@108531c2{/,file:///C:/Users/revda/OneDrive/Documents/Timtest/CardServer/server/target/cardgamesserver-1.0/,UNAVAILABLE}{C:\Users\revda\OneDrive\Documents\Timtest\CardServer\server\target\cardgamesserver-1.0}
 [exec] [INFO] GCLOUD: javax.servlet.ServletException: Card Game Server==org.glassfish.jersey.servlet.ServletContainer@f3e13e41{jsp=null,order=1,inst=true,async=false,src=DESCRIPTOR:file:///C:/Users/revda/OneDrive/Documents/Timtest/CardServer/server/target/cardgamesserver-1.0/WEB-INF/web.xml,STARTED}
 [exec] [INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:650)
 [exec] [INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:415)
 [exec] [INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:731)
 [exec] [INFO] GCLOUD: at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)

谢谢!蒂姆
pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <packaging>war</packaging>
    <version>1.0</version>

    <groupId>com.myhouse.cards</groupId>
    <artifactId>cardserver</artifactId>

    <properties>
        <appengine.app.version>1</appengine.app.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <prerequisites>
        <maven>3.6.1</maven>
    </prerequisites>

    <dependencies>
       <!-- API, java.xml.bind module -->
      <dependency>
          <groupId>jakarta.xml.bind</groupId>
          <artifactId>jakarta.xml.bind-api</artifactId>
          <version>2.3.2</version>
      </dependency>
      <!-- Runtime, com.sun.xml.bind module -->
      <dependency>
          <groupId>org.glassfish.jaxb</groupId>
          <artifactId>jaxb-runtime</artifactId>
          <version>2.3.2</version>
      </dependency>
        <!-- Compile/runtime dependencies -->
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>1.9.90</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>2.17</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
            <version>2.17</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.objectify</groupId>
            <artifactId>objectify</artifactId>
            <version>5.1.5</version>
        </dependency>   
    </dependencies>

    <build>
        <!-- for hot reload of the web application-->
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>display-dependency-updates</goal>
                            <goal>display-plugin-updates</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.2</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>2.0.0</version>
                <configuration>
                    <projectId>cardserver</projectId>
                    <version>1</version>
                    <cloudSdkVersion>350.0.0</cloudSdkVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
w41d8nur

w41d8nur1#

Glassfish用于操作类文件的objectweb版本太旧,无法解析您要使用的Java版本的类文件。
换句话说,您当前的平台版本不支持Java 11。

相关问题