google app engine Could not find or load main class after upgrade to java 11 - google-app-engine

Hi I have project that develop with java 8 and manage in google app engine and everything work fine.
my project used appengine-web.xml and not app.ymal file to config the app engine
i decided to upgrade to java 11 so now i need to use app.ymal file to config app engine.
this is my config file
runtime: java11
env: standard
entrypoint: 'java -cp "*" mypackageName.ServerMain myprojectName-1.0.war'
after upgrate to java 11 in my local host the project work fine but when i deploy the project to app engine i get error
(from app engine logs)
2022-09-22 11:01:43.876 IDT
Error: Could not find or load main class mypackageName.ServerMain
2022-09-22 11:01:43.876 IDT
Caused by: java.lang.ClassNotFoundException: mypackageName.ServerMain
to upgrade my project to java 11 i use this guide
https://happycoding.io/tutorials/google-cloud/migrating-to-java-11
config pom file
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0</version>
<groupId>mypackageName</groupId>
<artifactId>myprojectName</artifactId>
when i look on app engine console i saw war file correct and app.yaml file
so what is problem
thank you

Related

How to deploy a Helidon application to Google Cloud App Engine?

I am trying to deploy an Helidon MP project to Google Cloud App Engine using java11 runtime but having trouble to define the app.yaml properly.
Tried to deploy the jar file directly using the below app.yaml using the command $ gcloud app deploy cord.jar. The app gets deployed but empty page on view.
runtime: java11
entrypoint: 'java -jar cord.jar'
Tried to modify the codewbase adding appengine\app.yaml to <project>\src\main\appengine\app.yaml and with contents as below and using command $ gcloud app deploy pom.xml:
runtime: java11
instance_class: F1
In all cases, the app got deployed but page loads empty.
They have examples on github but unfortunately not yet with Helidon.
I've put together an example for Helidon.
A couple things to note:
Make sure your application obeys the PORT environment variable, and configures its server to use that port.
Make sure your app.yaml is in the same directory as your jar and defines a custom entry point. For example:
runtime: java11
entrypoint: java -Xmx64m -jar helidon-quickstart-se.jar
Helidon uses "thin" jars and App Engine seems to handle this AOK as mentioned here: https://cloud.google.com/appengine/docs/standard/java11/runtime#application_startup
As an answer to my question.. issue for the page not loading was because of port 9090 that we were using (defined in src/main/resources/META-INF/microprofile-config.properties file). After i changed it to default 8080, my app worked.
microprofile-config.properties:
# Application properties. This is the default greeting
app.greeting=Hello
# Microprofile server properties
server.port=8080
server.host=0.0.0.0
References:
Helidon MP example for Google App Engine
There is a github thread regarding this and so far the current workaround is to add an app.yaml file similar to the one for the frameworks like Spring Boot or Vert.x
I have followed the tutorial where the github sample of the other responses is and it worked for me.
First I have cloned the repository and I used the quickstart mp:
git clone https://github.com/barchetta/helidon-google-app-engine-example/
cd helidon-google-app-engine-example/helidon-quickstart-mp
Then I have built and run the application and check if the port responds.
mvn package
export PORT=8888
java -jar target/helidon-quickstart-mp.jar
After all these previous steps I was able to see in localhost the result of the application.
For deploying I created the app.yaml file named "helidon-mp-app.yaml" and wrote this configuration inside:
runtime: java11
entrypoint: java -Xmx64m -jar helidon-quickstart-mp.jar
And copied it to the target/ directory:
cp helidon-mp-app.yaml target/
As the last configuration file, the file ".gcloudingonre" which also needs to be moved to target/
# Exclude everything. Then include just the app jar and runtime
# dependencies in libs/
*
*/
*/**
!helidon-quickstart-mp.jar
!libs/
!libs/**
Then as all the configuration files are ready, I executed
gcloud app deploy target/helidon-mp-app.yaml
gcloud app browse
And appending "/greet" in the URL we can see the result:
{"message":"Hello World!"}

Deploy ASP.NET Core 2.1 app to Google Cloud App Engine error: bad character range

When I try to publish an ASP.NET Core 2.1 Web Application to Google Cloud Platform App Engine I get the error gcloud crashed (error): bad character range.
I publish with the GCP Visual Studio 2017 extension and I get the above error.
I publish from the cmd with an app.yaml in my project and I get the above error.
In order to deploy the ASP.NET Core 2.1 web application to Google Cloud App Engine I added an app.yaml file with the following contents:
runtime: aspnetcore
env: flex
I did the following:
Added app.yaml with
runtime: aspnetcore
env: flex
Added it to csproj
<ItemGroup>
<None Include="app.yaml" CopyToOutputDirectory="Always" />
</ItemGroup>
And executed the command
gcloud beta app deploy ./bin/release/netcoreapp2.1/publish/app.yaml
However I got the error: gcloud crashed (error): bad character range
Anyone know what I am doing wrong?
I follow the following guide and still get the same error when I try method 1, 2 and 3: https://cloudplatform.googleblog.com/2017/10/4-ways-you-can-deploy-an-ASP.NET-Core-app-to-GCP.html
This issue is being investigated at the moment and a fix should be released soon. As a workaround, please downgrade your Cloud SDK version to 212.0.0 by running the following command:
gcloud components update --version 212.0.0
Downgrading the version of your Cloud SDK to 212.0.0 or lower works because it seems in version 213.0.0 some changes were implemented that caused an issue with the yaml parser used by gcloud.
In addition, please follow this Issue Tracker thread to get updates regarding the status of this issue.
You should navigate to the publish directory first and deploy from there. Make sure the app.yaml file is present in the publish directory.
dotnet publish -c Release
cd ./bin/Release/netcoreapp2.1/publish
gcloud app deploy

Does my PHP project need appengine-web.xml

Setting up IntelliJ IDEA to run my PHP Wordpress (for App Engine) projects. Google Cloud Tools installed.
Have imported existing project files and then went to Tools > Google Cloud Tools > Run on a local App Engine Standard dev server.
An error is returned:
Project does not contain App Engine Standard modules: To use the App Engine Standard local development server, the project must contain at least one App Engine Standard module with an appengine-web.xml configuration file.
I read up on appengine-web.xml and apparently its used for Java projects. I'm trying to run PHP at the moment.
I haven't dealt with this file type before, is it similar to app.yaml?
Do I need this fie to set up my local server for PHP?
Actually the file appengine-web.xml corresponds to the App Engine Java runtime, you don't need to use it in your PHP project. It is similar to the app.yaml in the sense that it is where you define your default service.
In order to define the default service in your PHP app, you need the app.yaml. There are also optional configuration files, such as:
dispatch.yaml, queue.yaml, index.yaml, cron.yaml, dos.yaml
On a side note, maybe PHP Storm or Eclipse with the PHP Development tools are more suitable for your use case.

Google AppEngine gives Jersey ServletContainer ClassNotFoundException

I am using Eclipse Indigo with Google AppEngine SDK (and no GWT)
Project setup starting with a clean default project:
Java in use is the Oracle JDK 7 but changed project settings to generate 1.6 code and source code compatibility also set to 1.6
Added 2 external jars to BuildPath from Glassfish Java EE 6 + JDK 7 installation
jersey-core.jar
jersey-gf-server.jar
jersey-gf-server.jar contains com.sun.jersey.spi.container.servlet.ServletContainer
Fixed Eclipse markers complaining that the jar files would not be found in the deployed app -- accepted suggested fix for each to copy them to war/WEB-INF/lib folder
Deployed successfully
Upon accessing the regular non-Jersey hello-world servlet, I get the error in AppEngine logs: java.lang.ClassNotFoundException: com.sun.jersey.spi.provider.container.servlet.ServletContainer
the class ServletContainer is in the jersey-bundle.jar
You should add jersey-servlet.jar as well. At some point this class was migrated there.

Deploy GWT Application to Google App Engine using NetBeans

I try to deploy a GWT application, to Google App Engine using NetBeans.
I had successful run GWT sample http://code.google.com/webtoolkit/doc/latest/tutorial/create.html using Personal GlassFish v3 Prelude Domain, by
1) Copy generated source code from StockWatcher to C:\Projects\StockWatcherNetbeans\src\java\com\google\
2) Modify C:\Projects\StockWatcherNetbeans\nbproject\gwt.properties
gwt.module=com.google.gwt.stockwatcher.StockWatcher
3) Select Personal GlassFish v3 Prelude Domain, and run.
All works fine!
Now, I try to select Google App Engine server, and run. However, I get the error
"There is no appengine web project
opened!"
I check... There is file called
C:\Projects\StockWatcherNetbeans\war\WEB-INF\appengine-web.xml
with content
<?xml version="1.0" encoding="UTF-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://kenai.com/projects/nbappengine/downloads/download/schema/appengine-web.xsd appengine-web.xsd'>
<application>StockWatcherNetbeans</application>
<version>1</version>
</appengine-web-app>
I am using
NetBeans 6.7.1
GWT4NB (GWT Plugin for NetBeans) 2.6.12
Google App Engine plugin for NetBeans from http://kenai.com/downloads/nbappengine/1.0_NetBeans671/updates.xml
Anything I had missed out?
Even when I right click to the project, the Deploy to Google App Engine options is disabled.
And yes, please do not ask me why not use Eclipse.
Starting with GWT 1.6, static files
have been moved to /war.
Instead of using war folder, I rename it to web folder. The Google App Engine plug-in comes with NetBeans needs the files to be placed in web folder.

Resources