I had a Java 8 app on GAE standard runtime that was working fine. Apparently, Java 8 deployments are no longer supported after Jan 31 2024. I am trying to migrate to Java 11 and deploy. I was using Eclipse with Google Plugin earlier to run locally and right click and Deploy to App Engine standard and it was seamless.
This is what I did so far
- 1.Downloaded Gcloud CLI tools and installed app-engine-java on it. 2. Did a right click on the project in Eclipse (2023-12 / 4.30 version) and did Configure > Convert to Maven project 3. Removed threadsafe in appengine-web.xml and added runtime as java11 and app-engine-apis property is set to true 4. Updated the POM file to add the Google tools. Full POM is as below
.
<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>
<groupId>SAAS_BWCS_GAE_J8</groupId>
<artifactId>SAAS_BWCS_GAE_J8</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>2.0.4</version> <!-- or later-->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<!--
https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
<!--
https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.2</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>true</failOnMissingWebXml>
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF/lib</directory>
<targetPath>WEB-INF/lib</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.7.0</version>
</plugin>
</plugins>
</build>
After this, I did Maven / Update Project and ran the goals in Eclipse as Maven clean package. The package WAR file is built fine. However when I run it on local development server I get the following error
024-02-23 23:46:29.758:WARN:oejw.WebAppContext:main: Failed startup of context c.g.a.t.d.j.DevAppEngineWebAppContext@7e1a1da6{/,file:///C:/data/MY_APP/src/main/webapp/,UNAVAILABLE}{C:\data\MY_APP\src\main\webapp}
MultiException[javax.servlet.UnavailableException: Servlet class com.myapp.MyServlet is not a javax.servlet.Servlet, javax.servlet.UnavailableException: Servlet class com.myapp.EmailServlet is not a javax.servlet.Servlet]
I thought it might be a local development server issue and deployed to cloud using
appengine:deploy -Dapp.deploy.projectId=my_app_id -Dapp.deploy.version=newj11 -Dapp.deploy.promote=True
However, on the live version on the google cloud, I get the same error too and the server won't start.
Failed startup of context c.g.a.r.j.AppEngineWebAppContext@6d2c0e53{/,file:///workspace/,UNAVAILABLE}{/workspace} MultiException[javax.servlet.UnavailableException: Servlet class com.myapp.MyServlet is not a javax.servlet.Servlet
I thought it is because I included javax.servlet in dependency and removed it. If I remove it, the code does not compile in maven compile. I have been at this for more than 7 hours now and I am lost. Can anyone help on how to fix this and get this deployed. The change itself is very small one line change but Google is making it so difficult to migrate / deploy
As mentioned in this document Cloud Tools for Eclipse release notes
As per this Github Link, at the moment Java 11/17 support for the App Engine standard on Cloud Tools for Eclipse is not available.
There is an open github thread here, you can add your concern to the same issue.Also feel free to raise a Public issue tracker or Feature request describing your concern. You can use this page for reference when creating an issue.