0

I have a legacy Google Cloud appengine using Java 8 which I need to migrate to Java 11. As per this guide I plan to "Migrate to Java 11/17 with bundled services", so I have not migrated my appengine-web.xml to app.yaml. Instead I have simply done the following:

  1. Downloaded Java 11 and updated the JAVA_HOME path
  2. Updated the appengine-web.xml to <runtime>java11</runtime>
  3. Updated the pom.xml for maven-complier-plugin: <source>11</source> <target>11</target>

I haven't tried to deploy yet using mvn appengin:deploy , but I get the following error when trying to run the local server: mvn appengine:run

Localhost:8080 then obviously fails with a 503 Service Unavailable.

Any idea why this is failing to start the dev server in Java 11.

I have added the suggested dependencies to my POM files, but this then give further Java errors:

[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)

and then:

 [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)

Thanks! Tim

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>
Tim Cobra
  • 111
  • 13
  • Likely a duplicate: https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception and https://stackoverflow.com/questions/52502189/java-11-package-javax-xml-bind-does-not-exist?noredirect=1&lq=1 – Codo May 01 '23 at 11:55
  • Thanks! I have added those dependencies and still no joy. I've updated the main post to show the updated POM and the new errors – Tim Cobra May 01 '23 at 14:24
  • 2
    You have fundamentally changed the question. Initially, it was about missing JAXB classes. All traces of that have been removed. It's a new error message now. This is not how StackOverflow works. Go to a forum / discussion / chat room if you want to work that way. BTW: The solution for the current error message can easily be found with Google search. – Codo May 01 '23 at 15:19
  • The question still remains the same "migrating Google appengine from Java 8 to 11" and trying to get the local server to work using mvn appengine:run – Tim Cobra May 01 '23 at 16:11
  • @TimCobra you should consider spending some time learning how to use stack overflow properly. You get better help far way. – Thorbjørn Ravn Andersen May 02 '23 at 15:05

1 Answers1

2

The version of objectweb Glassfish uses to manipulate class files is too old to parse the classfiles of the version of Java you want to use.

In other words, your current version of your platform does not support Java 11.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347