Can't Deploy Java Application to App Engine Standard - java

I have a Google Cloud Endpoints Java application that I am developing for App Engine Standard. I am unable to deploy it locally from Eclipse but I can deploy and run it locally like this:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
mvn clean package endpoints-framework:openApiDocs -DskipTests \
&& gcloud endpoints services deploy target/openapi-docs/openapi.json \
&& clear \
&& mvn appengine:run -Dapp.devserver.host=0.0.0.0 | tee appengine.out
Now I want to deploy it to App Engine Standard. If I try to deploy it using the Eclipse plugin I get:
Reading application configuration data...
2021-01-16 11:56:14.946:INFO::main: Logging initialized #370ms to org.eclipse.jetty.util.log.StdErrLog
Bad configuration: Missing required element 'application'.
Please see the logs [/tmp/appcfg1077472932380362760.log] for further information.
The log file says:
com.google.apphosting.utils.config.AppEngineConfigException: Missing required element 'application'.
at com.google.apphosting.utils.config.AppYaml.getApplication(AppYaml.java:804)
at com.google.apphosting.utils.config.AppYaml.generateAppEngineWebXml(AppYaml.java:1296)
at com.google.apphosting.utils.config.AppYamlProcessor.convert(AppYamlProcessor.java:50)
at com.google.appengine.tools.admin.Application.<init>(Application.java:250)
at com.google.appengine.tools.admin.Application.readApplication(Application.java:536)
at com.google.appengine.tools.admin.AppCfg.readWar(AppCfg.java:303)
at com.google.appengine.tools.admin.AppCfg.readApplication(AppCfg.java:281)
at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:209)
at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:118)
at com.google.appengine.tools.admin.AppCfg.main(AppCfg.java:114)
If I try to deploy it from the command line I get:
$ gcloud app deploy
ERROR: (gcloud.app.deploy) Maven source deployment is not supported for Java8 GAE project.
When I run:
gcloud config list
I get what looks like the correct value for "project".
Is there a way to deploy this application to App Engine Standard?
Thanks for your help.
-Dan

Related

Application error and logs not loading, what steps to take?

I've been getting the following error page, when visiting my app:
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
However, heroku logs --tail does not return anything. If I go to the dashboard through web (https://dashboard.heroku.com/apps/app-name/logs), the logs window keeps loading but nothing is shown.
I have nothing to go on, and Heroku won't accept a ticket of a free app. Does anyone know any more steps I can take to trace the error?
Additional info:
The build logs all look fine:
BUILD SUCCESSFUL in 49s
5 actionable tasks: 5 executed
Discovering process types
Procfile declares types -> (none)
Default types for buildpack -> web
Compressing...
Done: 85.2M
Launching...
Released v3
https://app-name.herokuapp.com/ deployed to Heroku
I am creating a spring Java API, it works fine when I try to run it locally. If I try to run it through $heroku local I do get an error:
[FAIL] No Procfile and no package.json file found in Current Directory - See run --help
I had same issue. I just added system.properties to root folder of spring app and this file contained 1 line:
java.runtime.version=11
Heroku procfile documentation.
Spring documentation for Heroku deployment

Unable to deploy my code to google cloud app engine via gitlab

I am trying to create a gitlab pipeline for deploying my spring boot app to google app engine and i am able to authenticate app engine to gitlab but at deployment step of ci file i am getting Java 7+ JRE must be installed and on your system PATH though i have installed it with gcloud install components app-engine-java command in gitlab ci file. Please suggest what needs to be done to resolve this error.
.gitlab-ci.yml file:
image: google/cloud-sdk:alpine
deploy_production:
stage: deploy
environment: Production
only:
- master
script:
- echo $DEPLOY_KEY_FILE_PRODUCTION > /tmp/$CI_PIPELINE_ID.json
- gcloud -q components install app-engine-java
- gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
- gcloud --quiet --project $PROJECT_ID_PRODUCTION --verbosity debug app deploy src/main/webapp/WEB-INF/appengine-web.xml
Below are the debug details which mentions that to use the local staging for java, java JRE must be installed though i have installed it using gcloud install components google-app-engine cmd:
$ gcloud --quiet --project $PROJECT_ID_PRODUCTION --verbosity debug app deploy src/main/webapp/WEB-INF/appengine-web.xml
DEBUG: Running [gcloud.app.deploy] with arguments: [--project: "playground-kg", --quiet: "True", --verbosity: "debug", DEPLOYABLES:1: "[u'src/main/webapp/WEB-INF/appengine-web.xml']"]
**DEBUG: (gcloud.app.deploy) To use the local staging for java, a Java 7+ JRE must be installed and on your system PATH**
Traceback (most recent call last):
File "/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 983, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 784, in Run
resources = command_instance.Run(args)
File "/google-cloud-sdk/lib/surface/app/deploy.py", line 90, in Run
parallel_build=False)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 573, in RunDeploy
args.deployables, stager, deployables.GetPathMatchers())
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deployables.py", line 334, in GetDeployables
service = Service.FromPath(path, stager, path_matchers)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deployables.py", line 102, in FromPath
service = matcher(path, stager)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deployables.py", line 175, in AppengineWebMatcher
staging_dir = stager.Stage(descriptor, app_dir, 'java-xml', env.STANDARD)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/staging.py", line 387, in Stage
return command.Run(self.staging_area, descriptor, app_dir)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/staging.py", line 171, in Run
args = self.GetArgs(descriptor, app_dir, staging_dir)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/staging.py", line 251, in GetArgs
return self._mapper(self.GetPath(), descriptor, app_dir, staging_dir)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/staging.py", line 107, in _JavaStagingMapper
java_bin = java.RequireJavaInstalled('local staging for java')
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/util/java.py", line 54, in RequireJavaInstalled
v=min_version))
JavaError: To use the local staging for java, a Java 7+ JRE must be installed and on your system PATH
ERROR: (gcloud.app.deploy) To use the local staging for java, a Java 7+ JRE must be installed and on your system PATH
Some people got the same issue trying to create the same workflow, but with github. The same issue can be viewed here. This guy solved this by adding openjdk-8 to Docker.
You can see here how to add openjdk-8 to Docker.
If this did not work for you, please let me know and I will try to edit my answer.
You may also want to check Jenkins for Google Cloud and using Jenkins with Gitlab for CI. It may be helpful for your CI workflow.

Springboot app Gradle build works locally but not when deployed to Heroku

I have a springboot rest server that I can build with ./gradlew build -x test works fine locally. When I push my master branch to Heroku it fails with the below stack trace.
-----> Gradle app detected
-----> Spring Boot detected
-----> Installing JDK 1.8... done
-----> Building Gradle app...
-----> executing ./gradlew build -x test
Downloading https://services.gradle.org/distributions/gradle-4.10.2-bin.zip
..........................................................................
> Task :compileJava
/tmp/build_20fcdda80fef571f4d65e4396cb813c1/src/main/java/com/edge/riskassesmentwebapp/dto/OnsiteAbandonmentDto.java:10: error: class OnSiteAbandonmentDto is public, should be declared in a file named OnSiteAbandonmentDto.java
... (it repeats the above error for a bunch of classes)
This is my first time deploying a springboot application to Heroku and I'm not sure how to fix the build if it works locally.
try to rename the file OnsiteAbandonmentDto to OnSiteAbandonmentDto.
Note the difference in capitalization

spring boot with bluemix error: None of the buildpacks detected a compatible application

Steps:
create new project with start.spring.io
run it localy - works
run gradle task jar
push jar to bluemix cf push demoWar.jar
Downloaded app package (20.1M) Staging... None of the buildpacks
detected a compatible application Exit status 222 Staging failed:
Exited with status 222 Destroying container
FAILED Error restarting application: NoAppDetectedError
TIP: Buildpacks are detected when the "cf push" is executed from
within the dire ctory that contains the app source code.
Try two things:
1. Use the -p command to target your deployable artifact. This would look something like cf p APP_NAME -p PATH_TO_YOUR_WAR. I usually chain my build and deploy commands so: mvn clean package && cf p APP_NAME -p PATH_TO_YOUR_WAR.
If this doesn't work then you can specify a build pack. So cf p APP_NAME -p PATH_TO_YOUR_WAR -b SOME_BUILDPACK. You can see the available build packs by calling cf buildpacks.
Hope this helps.
When deploying first time your app on cloud foundry then following command will not work
cf push TestService
you need to use following command
cf push -p TestService-0.0.1-SNAPSHOT.jar testService
Useful link :
https://discuss.pivotal.io/hc/en-us/articles/226273647-Troubleshooting-error-None-of-the-buildpacks-detected-a-compatible-application-exit-status-222-
https://docs.cloudfoundry.org/buildpacks/detection.html
Else add manifest.yml on root
applications:
- name: Demo
memory: 2G
disk_quota: 2G
instances: 1
path: target/demo-local-0.0.1-SNAPSHOT.jar
env:
SPRING_PROFILES_ACTIVE : "dev"
routes:
- route: demo.app.dev.vk.vaquar.khan.com
after that go to path and run cf push < JAR_NAME>

Managed VM deploy failed because "env" setting is not supported

Trying to deploy a Java app to Google Appengine Managed VM. I'm using console gcloud and already prepared WAR file. Plus app.yaml.
Using following command:
gcloud preview app deploy ./build/libs/app.yaml
Right now it fails with:
Building and pushing image for module [default]
-------------------------------------------------------------------------------- DOCKER BUILD OUTPUT --------------------------------------------------------------------------------
Step 0 : FROM gcr.io/google_appengine/jetty9
---> 005014071b64
Step 1 : ADD webapp-webapp.war $JETTY_BASE/webapps/root.war
---> 3e9023930cc8
Removing intermediate container 342e8a2f5750
Successfully built 3e9023930cc8
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Beginning teardown of remote build environment (this may take a few seconds).
Updating module [default]...failed.
ERROR: (gcloud.preview.app.deploy) Error Response: [400] "env" setting is not supported for this deployment.
I see similar error (there) for maven-gcloud-plugin that happens when project is not configured as WAR. But notice that:
i'm using plain command line tool gcloud, a latest version
and my project is packaged into WAR already
Also i'm using following app.yaml (which i've got from maven plugin sources):
runtime: java
env: 2
api_version: 1
handlers:
- url: .*
script: dynamic
So the question, where from this error is coming from (docker image is already prepared at this moment, right?). What it means? And how to fix this?
Update
I noticed that it uses FROM gcr.io/google_appengine/jetty9 for VM. But for Appengine it should be FROM gcr.io/google_appengine/jetty9-compat. I've tried to switch to exploded app instead of WAR, and it started using correct Docker base image. But still fails:
Building and pushing image for module [default]
-------------------------------------------------------------------------------- DOCKER BUILD OUTPUT --------------------------------------------------------------------------------
Step 0 : FROM gcr.io/google_appengine/jetty9-compat
---> 2ad8572ef3d8
Step 1 : ADD . /app/
---> b10f4bc6718e
Removing intermediate container 8b149f4baf9c
Successfully built b10f4bc6718e
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Beginning teardown of remote build environment (this may take a few seconds).
Updating module [default]...failed.
ERROR: (gcloud.preview.app.deploy) Error Response: [400] "env" setting is not supported for this deployment.
The reason was this line in app.yaml:
env: 2
it was too simple and too obvious to try to deploy w/o this option. Also, every doc, official and unofficial, mentions that you need to have env: 2 option set to deploy your app as Appengine app. That's really strange.
Removing this line also changed base Docker image to gcr.io/google_appengine/java-compat. I guess it means that jetty images, including jetty9-compat, aren't compatible with Appengine apps

Categories

Resources