GAE migration from java 7 to 8 on android studio - android-studio

I'm trying to migrate Google App Engine to java8 using the migration guide below.
https://cloud.google.com/appengine/docs/standard/java/migrating-to-java8
it says that: -
To have App Engine run your application in the Java 8 runtime, add
<runtime>java8</runtime>
to your appengine-web.xml file and redeploy the app.
when i try to do that i get the following error at the "runtime" tag:
element runtime is not allowed here
did i miss anything? This GAE is a backend module for my android app. I am using gradle on Android studio as the development environment.
prior to this, I have also migrated successfully to cloudEndpoints V2 using https://cloud.google.com/endpoints/docs/frameworks/java/migrating
edit: added error log
Jan 03, 2018 3:39:52 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
SEVERE: Received exception processing D:\GitlabProjects\XushuNarrator\backend\build\exploded-backend\WEB-INF/appengine-web.xml
com.google.apphosting.utils.config.AppEngineConfigException: Unrecognized element <runtime>
at com.google.apphosting.utils.config.AppEngineWebXmlProcessor.processSecondLevelNode(AppEngineWebXmlProcessor.java:183)
at com.google.apphosting.utils.config.AppEngineWebXmlProcessor.processXml(AppEngineWebXmlProcessor.java:65)
at com.google.apphosting.utils.config.AppEngineWebXmlReader.processXml(AppEngineWebXmlReader.java:132)
at com.google.apphosting.utils.config.AppEngineWebXmlReader.readAppEngineWebXml(AppEngineWebXmlReader.java:76)
at com.google.apphosting.utils.config.EarHelper.readWebModule(EarHelper.java:165)
at com.google.appengine.tools.development.ApplicationConfigurationManager$WarModuleConfigurationHandle.readConfiguration(ApplicationConfigurationManager.java:414)
at com.google.appengine.tools.development.ApplicationConfigurationManager.<init>(ApplicationConfigurationManager.java:159)
edit 2: the following is the gradle build for the backend. (After migration from V1 to V2)
//MIGRATION GUIDE
//https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating
buildscript {
repositories {
jcenter()
}
dependencies {
// V2: Add the new App Engine and Endpoints Frameworks plugin dependencies
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.2'
// classpath 'com.google.appengine:gradle-appengine-plugin:1.9.59'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
// V2: Apply new App Engine and Endpoints Framework server plugins
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
//apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
// appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.59'
// compile 'com.google.appengine:appengine-endpoints:1.9.59'
// compile 'com.google.appengine:appengine-endpoints-deps:1.9.59'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.googlecode.objectify:objectify:5.1.9'
compile 'javax.inject:javax.inject:1'
// V2: Endpoints Framework v2 migration
compile 'com.google.endpoints:endpoints-framework:2.0.7'
}
// V2: Define deployment configuration using the new App Engine plugin
// with the appengine closure
appengine { // App Engine tasks configuration
deploy { // deploy configuration
// The following is used for acceptance tests and
// is not required for a migration.
project = "ultra-tube-89909"
version = "2" //changed to GAE API v2
/*
Run the following command to initalize the Cloud SDK:
gcloud init
Use Application Default Credentials:
gcloud auth application-default login
Install the app-engine-java component:
gcloud components install app-engine-java
*/
// project = findProperty("appengine.deploy.project")
// version = findProperty("appengine.deploy.version")
def promoteProp = findProperty("appengine.deploy.promote")
if (promoteProp != null) {
promote = new Boolean(promoteProp)
}
}
}

It's highly advised to keep the Google Cloud SDK up to date as there are bug fixes and new features introduced quite often. So, I recommend that you to update your Cloud SDK version by the running the following command:
gcloud components update
Also, according to the migration documentation the following change is needed to upgrade the Gradle App Engine plugin, so that it may recognize the new ‘Java8’ runtime:
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'

I had the exact same thing but even though I had the error
element runtime is not allowed here
I still redeployed the backend via Gradle and it all worked. Then when I check my google cloud console, the newly deployed app engine version has java 8 listed as the run time and my app still works. So all seems ok.

Related

Unexpected attribute app_engine_apis error deploying Python 3 App Engine Flask app

I use Google App Engine standard environemment with Flask Python3 for a current project.
This project use as cache the App Engine Memcache (google.appengine.api.memcache).
Currently the cache doesn't work and I think that it's probably because of the dependency on App Engine APIs that need to be enable because when I try to deploy my app (gcloud app deploy) I have this warning: WARNING: There is a dependency on App Engine APIs, but they are not enabled in your app.yaml. Set the app_engine_apis property.
My issue is that when I try to set the dependancy in my app.yaml and deploy, I have then this error: Unexpected attribute 'app_engine_apis' for object of type AppInfoExternal.
I also tried with the exact same yaml file than the Google example: https://github.com/googlecodelabs/migrate-python2-appengine/blob/master/mod12b-memcache/app.yaml, it doesn't work.
Here the current app.yaml that I'm trying to use:
runtime: python39
env: standard
app_engine_apis: true
resources:
cpu: 2
memory_gb: 4
disk_size_gb: 15
manual_scaling:
instances: 2
This issue is almost the same as this question but I couldn't use it to solve my problem: How to deal with `app_engine_apis` warning when updating app.yaml from go114 to go115
Thank you for your help.
Your Google Cloud SDK is outdated. Per the comments in #NoCommandLine's answer, your SDK being version 300 is from Jul 2020 whereas the bundled services for 2nd-gen runtimes like Python 3 didn't go into private preview until Jun 2021. They became generally available in Sep 2021. If you run gcloud components update to get the latest SDK (at the time of this post, it's 410), you should be able to run gcloud app deploy to deploy a Python 3 App Engine app that can access the Memcache bundled service. TL;DR to using bundled services in Python 3:
Add app_engine_apis: true to app.yaml
Add appengine-python-standard to requirements.txt
Import the WSGI wrapper: from google.appengine.api import wrap_wsgi_app
Wrap your WSGI object (Flask): app = Flask(__name__); app.wsgi_app = wrap_wsgi_app(app.wsgi_app)
Review these instructions, esp. if you're not using Flask
Update your Cloud SDK: gcloud components update
NOTE: You no longer need to run pip install -t lib -r requirements.txt to vendor/self-bundle package dependencies... they're now automatically installed for Py3 users (but not Py2 though) when you deploy your app to the cloud.
I recently published a video & codelab (hands-on tutorial) on how to access the bundled services from "Gen2" but realize now I should've mentioned updating your SDK, meaning it covers almost all of the instructions above. :P
For those interested in eventually migrating off Memcache to something more powerful like Redis, I also published content on migrating from Memcache to Cloud Memorystore for Redis, relatively recently as well.
Your version of gcloud probably means the app_engine_apis are in the beta version and so you have to do
gcloud beta app deploy

Publish Jar into Azure Artifact using gradle error

What I'm trying to do is to publish a Jar file into the Azure DevOps artifact using Gradle but I got this error massage:
FAILURE: Build failed with an exception.
What went wrong:
Task 'publish' not found in root project 'Project1'.
Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
and the Build.gradle file is this:
apply plugin: 'java'
apply plugin: 'maven-publish'
publishing {
publications {
myPublication(MavenPublication) {
groupId 'soft'
artifactId 'crypto-utils'
version '5.2.0'
artifact 'C:\Users\d\Desktop\Project1\crypto-utils-5.2.0.jar'
}
}
// Repositories *to* which Gradle can publish artifacts
repositories {
maven {
url 'https://pkgs.dev.azure.com/soft/pm/_packaging/myFeed/maven/v1'
credentials {
username "myFeed"
//The Azure DevOps Services build system will use the "SYSTEM_ACCESSTOKEN" to authenticate to Azure DevOps Services feeds
password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") != null ? System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") : vstsMavenAccessToken
}
}
}
}
// Repositories *from* which Gradle can download dependencies; it's the same as above in this example
repositories {
maven {
url 'https://pkgs.dev.azure.com/soft/pm/_packaging/myFeed/maven/v1'
credentials {
username "myFeed"
//The Azure DevOps Services build system will use the "SYSTEM_ACCESSTOKEN" to authenticate to Azure DevOps Services feeds
password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") != null ? System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") : vstsMavenAccessToken
}
}
}
Any help please
The problem may be caused by using gradle in the wrong path. You need to run gradle in the same directory as the Build.gradle file.
If you are using Azure DevOps build pipeline, the root directory path of the repository is $(system.defaultworkingdirectory).
Other than that, you can try gradle clean build instead of gradle build.

Docker and AzureKeyVault: unable to load shared library 'libsecret-1.so.0'

I have Asp.net core Xunit integration tests that connect to MongoDb to test basic repositories on collections. The tests are built and run in a container in AKS. I have setup the test fixture to connect Azure Key Vault to retrieve connection string to a MongoDb.
var pathToSetting= Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var configuration = new ConfigurationBuilder()
.SetBasePath(pathToSetting)
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
var secretClient = new SecretClient(
new Uri("url_to_Azure_keyVault"),
new DefaultAzureCredential(),
new SecretClientOptions()
{
Retry =
{
Delay = TimeSpan.FromSeconds(2),
MaxDelay = TimeSpan.FromSeconds(4),
MaxRetries = 2,
Mode = RetryMode.Exponential
}
});
configuration.AddAzureKeyVault(secretClient, new KeyVaultSecretManager());
I am using the following Docker file for the integration tests:
#Grab an OS image made to run the .Net Core SDK
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
#copy files for build
WORKDIR /testProject
COPY . .
RUN dotnet build tests/integrationTest.csproj --output /testProject/artifacts
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS final
COPY --from=build ["/testProject/artifacts", "/testProject/artifacts"]
ENTRYPOINT dotnet test /testProject/artifacts/integrationTest.dll
The tests run fine locally from Visual Studio but fail with exception below when run in container both locally and in AKS.
[xUnit.net 00:00:03.10] IntegrationTest1 [FAIL]X
Test1 [1ms]
Error Message:
System.AggregateException : One or more errors occurred. (SharedTokenCacheCredential authentication failed: Persistence check failed. Inspect inner exception for details) (The following constructor parameters did not have matching fixture data: TestFixture testFixture)
---- Azure.Identity.AuthenticationFailedException : SharedTokenCacheCredential authentication failed: Persistence check failed. Inspect inner exception for details
-------- Microsoft.Identity.Client.Extensions.Msal.MsalCachePersistenceException : Persistence check failed. Inspect inner exception for details
------------ System.DllNotFoundException : Unable to load shared library 'libsecret-1.so.0' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment
variable: liblibsecret-1.so.0: cannot open shared object file: No such file or directory
Any ideas how to troubleshoot this error ?
I came across this potential fix while working on my own issue:
Wherever you create new DefaultAzureCredentialOptions, you should also set the property ExcludeSharedTokenCacheCredential to true.
In your WSL environment install libsecret-1-dev. In Ubuntu for example, run the command sudo apt install libsecret-1-dev. This will add libsecret-1.so.0 to your system so that MSAL can find it.
https://hungyi.net/posts/wsl2-msal-extensions/
It didn't work for me, but I am using a docker container that doesn't have full access to apt. I can't install libsecret-1-dev.
Not a root cause, but same error popped up for me this morning. Rolling Microsoft.Web.Identity package down from 1.7.0 to 1.6.0 did the trick.
Looks like from the GitHub issues on other Azure packages, wrapping these exceptions is a common bug that gets logged.
Switching Azure.Identity 1.2.3 to 1.2.2 did the trick for me (this page helped me https://hungyi.net/posts/wsl2-msal-extensions/).

Azure CD pipeline can't find build artifacts

Below is Azure error log from the Azure release pipeline.
2020-07-24T05:17:13.7712974Z ##[section]Starting: Deploy Azure App Service
2020-07-24T05:17:14.0464143Z ==============================================================================
2020-07-24T05:17:14.0465719Z Task : Azure App Service deploy
2020-07-24T05:17:14.0469391Z Description : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
2020-07-24T05:17:14.0469849Z Version : 3.163.5
2020-07-24T05:17:14.0470410Z Author : Microsoft Corporation
2020-07-24T05:17:14.0470921Z Help : https://aka.ms/azureappservicetroubleshooting
2020-07-24T05:17:14.0471274Z =============================================================================
2020-07-24T05:17:16.0650643Z Got connection details for Azure App Service:'XXXXX'
2020-07-24T05:17:17.6576087Z (node:764) Warning: Use Cipheriv for counter mode of aes-256-ctr
**2020-07-24T05:17:17.6627737Z ##[error]Error: No package found with specified pattern: D:\a\r1\a\Drop<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.**
2020-07-24T05:17:22.9168975Z Successfully added release annotation to the Application Insight : XXXXX
2020-07-24T05:17:24.8686063Z Successfully updated deployment History at https://XXXXX.scm.azurewebsites.net/api/deployments/231595567842919
2020-07-24T05:17:24.8933576Z ##[section]Finishing: Deploy Azure App Service
P.S. I have checked build pipeline, I can download build Artificats, but it displays below warning.
[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.
Assuming you meant you have solved the build artifact empty issue, but the release pipeline still had issue in Azure App Service deploy task.
As the error mentioned, there is "No package found with specified pattern: D:\a\r1\a\Drop", you need to check how you define the package, try format $(System.DefaultWorkingDirectory)/**/*.zip instead of $(System.DefaultWorkingDirectory)\Drop.
As task "Publish Build Artifact" publish artifact from $(build.artifactstagingdirectory), so we need add a task "Copy files" to copy your files ** from $(system.defaultworkingdirectory) to $(build.artifactstagingdirectory) **. which copied my build to stagingdirectory.

After upgrading the Azure SDK version to 1.7.0, authentication code failed java.lang.NoClassDefFoundError:

After upgrading the Azure SDK version to 1.7.0, authentication code failed with "java.lang.NoClassDefFoundError: com/microsoft/azure/management/batchai/implementation/BatchAIManager"
My authentication code is
/**
* Default constructor.
*/
public Azure() {
try {
credentials = new ApplicationTokenCredentials(Config.AzureclientId_admin, Config.AzuretenantId_admin,
Config.Azuresecret_admin, AzureEnvironment.AZURE);
azure = com.microsoft.azure.management.Azure.authenticate(credentials)
.withSubscription(Config.AzuresubscriptionId_admin);
} catch (Exception ex) {
Log.Message("Unable to create the Azure object", LogLevel.ERROR);
ex.printStackTrace();
}
}
This looked to be maven issue. The dependency was downloaded and seen in the .m2 directory but was not loaded in Eclipse Maven dependency. I deleted azure directory from the .m2 and compiled it again which resolved the issue.

Resources