Spring Boot web application running on Google App Engine - throws jetty exception - google-app-engine

When I execute gradlew appengineRun, I consistently get:
Starting a Gradle Daemon (subsequent builds will be faster)
Mar 26, 2018 5:47:48 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
2018-03-26 17:47:51.665:INFO::main: Logging initialized #3872ms
2018-03-26 17:47:53.727:INFO:oejs.Server:main: jetty-9.3.18.v20170406
2018-03-26 17:48:01.040:WARN:oeja.ClassInheritanceHandler:qtp99347477-18:
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
at org.eclipse.jetty.annotations.ClassInheritanceHandler.addToInheritanceMap(ClassInheritanceHandler.java:72)
at org.eclipse.jetty.annotations.ClassInheritanceHandler.handle(ClassInheritanceHandler.java:58)
at org.eclipse.jetty.annotations.AnnotationParser$MyClassVisitor.visit(AnnotationParser.java:476)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:650)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:525)
at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:978)
at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:958)
at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:902)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:851)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:163)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:546)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:745)
2018-03-26 17:48:01.087:WARN:oeja.ClassInheritanceHandler:qtp99347477-19:
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)
at org.eclipse.jetty.annotations.ClassInheritanceHandler.addToInheritanceMap(ClassInheritanceHandler.java:72)
at org.eclipse.jetty.annotations.ClassInheritanceHandler.handle(ClassInheritanceHandler.java:58)
at org.eclipse.jetty.annotations.AnnotationParser$MyClassVisitor.visit(AnnotationParser.java:476)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:650)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:525)
at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:978)
at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:958)
at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:902)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:851)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:163)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:546)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:745)
2018-03-26 17:48:01.103:WARN:oeja.ClassInheritanceHandler:qtp99347477-12:
java.lang.NullPointerException
I have a Windows 7 host. The same program runs fine with gradlew bootRun.
I am not using a web.xml. But my build.gradle is along the lines of https://cloud.google.com/appengine/docs/standard/java/tools/gradle.
I am not running through eclipse (similar problem is reported here: mvn appengine:run - error 403 (spring boot web with jsp)).
springBootVersion = '2.0.0.BUILD-SNAPSHOT'
build.gradle:
buildscript {
ext {
springBootVersion = '2.0.0.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+' // latest App Engine Gradle tasks
}
}
apply plugin: 'java' // standard Java tasks
apply plugin: 'war'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
ext['thymeleaf.version'] = '3.0.9.RELEASE'
compileJava {
options.warnings = true
options.debug = true
options.compilerArgs += ["-Xlint:deprecation"]
}
sourceSets {
main {
java {
exclude '**/RedirectHttpToHttpsOnTomcatConfig.java'
exclude '**/RedirectHttpToHttpsOnJettyConfig.java'
exclude '**/RedirectHttpToHttpsOnJetty2Config.java'
exclude '**/RedirectHttpToHttpsOnJetty3Config.java'
exclude '**/RedirectHttpToHttpsOnJetty4Config.java'
}
}
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile 'com.google.appengine:appengine-api-1.0-sdk:+' // Latest App Engine Api's
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
compile 'jstl:jstl:1.2'
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4')
compile("org.springframework.boot:spring-boot-starter-jdbc") {
exclude module: "org.apache.tomcat:tomcat-juli"
}
compile("org.springframework.boot:spring-boot-starter-data-jpa") {
exclude module: "org.apache.tomcat:tomcat-juli"
}
compile("com.h2database:h2")
providedRuntime 'org.slf4j:jul-to-slf4j'
}
configurations {
compile.exclude module: 'spring-boot-starter-tomcat'
runtime.exclude module: 'spring-boot-starter-tomcat'
}
appengine { // App Engine tasks configuration
deploy { // deploy configuration
}
}
sourceCompatibility = 1.8 // App Engine Flexible uses Java 8
targetCompatibility = 1.8 // App Engine Flexible uses Java 8

The issue is being tracked upstream by https://issuetracker.google.com/issues/65200034. Please star that issue to receive updates.
Details
We believe your issue is https://github.com/eclipse/jetty.project/issues/1892. https://issuetracker.google.com/issues/65200034 was originally about https://github.com/eclipse/jetty.project/issues/1692, but it has expanded to cover your issue too.

Related

how to configure ecosystem.config.js file for next.js on apache

am trying to deploy nextjs app on apache using pm2.
I have installed latest versions of node, pm2. and apache is configured as reverse proxy.
but when am trying to start daemon process, it is not doing it. I cloned a project from github and ran 'npm run build, which created .next file and in that file, I created ecosystem.config.js file for pm2, it looks like this :
module.exports = {
apps : [{
name: "nextjs-app",
script: "npm",
args: "run build",
env: {
NODE_ENV: "production"
}
}]
};
but when I ran pm2 start npm -- start , terminal is giving me respone like this:
pm2 start npm -- start
[PM2] Spawning PM2 daemon with pm2_home=/home/georgianar/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /usr/local/bin/npm in fork_mode (1 instance)
[PM2] Done.
but when I try to see list of process, there is none, and when user tries to enter the website, site log shows that there is no service on port 3000
(111)Connection refused: AH00957: http: attempt to connect to 127.0.0.1:3000 (localhost:3000) failed
and
AH01114: HTTP: failed to make connection to backend: localhost
I dont know why, any idea why it is doing so?

How do I deploy an react app to azure and change the default page

I'm trying to deploy a react app to azure. I tested that my build runs, at that works fine. When I deploy my app, I get the default 'hey, node developers' page. I have then tried to add a index.js file as described on some sites, like this https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/#NodeHome
but now I'm getting an error...
*/home/LogFiles/2020_01_13_RD0003FF73402D_default_docker.log (https://sbwebtest.scm.azurewebsites.net/api/vfs/LogFiles/2020_01_13_RD0003FF73402D_default_docker.log)
2020-01-13T11:39:01.618020509Z 11:39:01 0|index | at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:27:21)
2020-01-13T11:39:01.619118659Z 11:39:01 0|index | at Module._compile (internal/modules/cjs/loader.js:956:30) {
2020-01-13T11:39:01.620286813Z 11:39:01 0|index | code: 'MODULE_NOT_FOUND',
2020-01-13T11:39:01.628165973Z 11:39:01 0|index | requireStack: [ '/home/site/wwwroot/index.js' ]
2020-01-13T11:39:01.629324326Z 11:39:01 0|index | }
2020-01-13T11:39:01.649097230Z 2020-01-13T11:39:01: PM2 log: App [index:0] exited with code [1] via signal [SIGINT]
2020-01-13T11:39:01.650858410Z 2020-01-13T11:39:01: PM2 log: Script /home/site/wwwroot/index.js had too many unstable restarts (16). Stopped. "errored"
2020-01-13T11:39:01.657846830Z 11:39:01 PM2 | App [index:0] exited with code [1] via signal [SIGINT]
2020-01-13T11:39:01.659306496Z 11:39:01 PM2 | Script /home/site/wwwroot/index.js had too many unstable restarts (16). Stopped. "errored"*
I have deployed using the azure tool in VS code.
Anyone know what to do ?
If you are based on Windows OS, this screenshot will tell you how to fix it:
If you are based on Linux OS, there are two ways to resolve this problem.
First method:
The premise of this method is you have Node.js env and have installed npm tools.
1.add a file name index.js under the site/wwwroot.
index.js:
var express = require('express');
var server = express();
var options = {
index: 'index.html' //Fill path here.
};
server.use('/', express.static('/home/site/wwwroot', options));
server.listen(process.env.PORT);
2.install express:
run this command under the wwwroot directory,
npm install -save express
3.restart your app service and wait for minutes.
Second method:
1.Create a .htaccess file under the root directory.
.htaccess file:
DirectoryIndex public_html/index.php
2.Restart your web app and wait for minutes.
This is the structure of my web app:
Success:
Let me know if you have more doubts.

Zap export report is not working in Jenkins

Trying to export report using ZAP in Jenkins.
Getting below errors :-
[ZAP Jenkins Plugin] INITIALIZATION [ SUCCESSFUL ]
REQUIRED PLUGIN(S) ARE MISSING
[ZAP Jenkins Plugin] SHUTDOWN [ START ]
and in local OWASP ZAP/zap.log:-
2018-11-18 09:52:48,551 [main ] INFO Options ParamCertificate - Unsafe SSL renegotiation disabled.2018-11-18 09:52:49,684 [main ] INFO ENGINE - open start - state not modified 2018-11-18 09:52:50,085 [main ] INFO ENGINE - dataFileCache open start2018-11-18 09:52:50,134 [main ] INFO ENGINE - dataFileCache open end2018-11-18 09:52:50,498 [ZAP-daemon] INFO ExtensionFactory - Loading extensions2018-11-18 09:52:50,746 [ZAP-daemon] ERROR ExtensionAutoUpdate - Unable to load the configuration org.apache.commons.configuration.ConfigurationException: Unable to load the configuration
I resolved this issue:- Added add-on exportreport-alpha-5 plugin in the ZAP Home directory (in plugin directory) .

Firebase Admin SDK on app engine standard

is it possible to use Firebase on app engine standard environment? I am aware that the standard environment threading capabilities are very limited and since the Firebase SDK runs a background synchronization thread it might not be compatible. I've gave it a try and I've encountered the following error, which I can't seem to overcome:
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
Here is the servlet code:
public class GeneratorServlet extends HttpServlet {
FirebaseDatabase database = null;
#Override
public void init(ServletConfig config) {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// InputStream serviceAccount = classloader.getResourceAsStream("serviceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.applicationDefault())
// .setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl("https://app-name.firebaseio.com/")
.build();
FirebaseApp defaultApp = FirebaseApp.initializeApp(options);
this.database = FirebaseDatabase.getInstance(defaultApp);
}
#Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
PrintWriter out = resp.getWriter();
out.println(this.database);
this.loadData();
}
private void loadData() {
// The following line throws the error
DatabaseReference ref = this.database.getReference("/publiclyReadable");
}
}
Am I doing it wrong or is it caused by the limitations of the standard environment? I chose the standard environment over flexible because flexible version is not recommended for a production use yet.
Thanks, Jan
Edit:
appengine-web.xml
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>doctor-appointment-system</application>
<version>0</version>
<threadsafe>true</threadsafe>
<instance-class>B1</instance-class>
<manual-scaling>
<instances>1</instances>
</manual-scaling>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
</appengine-web-app>
Edit:
web.xml
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>generator</servlet-name>
<servlet-class>com.example.bookingtimes.GeneratorServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>generatorinfo</servlet-name>
<servlet-class>com.example.bookingtimes.GeneratorInfoServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>generator</servlet-name>
<url-pattern>/times/generate</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>generatorinfo</servlet-name>
<url-pattern>/times/change</url-pattern>
</servlet-mapping>
</web-app>
build.gradle:
buildscript { // Configuration for building
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+'
}
}
repositories { // repositories for Jar's you access in your code
maven {
url 'https://maven-central.storage.googleapis.com'
}
jcenter()
mavenCentral()
}
apply plugin: 'java' // standard Java tasks
apply plugin: 'war' // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
dependencies {
providedCompile group: 'javax.servlet', name: 'servlet-api', version: '2.5'
compile 'com.google.appengine:appengine:+'
compile 'com.google.firebase:firebase-admin:4.1.0'
}
appengine { // App Engine tasks configuration
run { // local (dev_appserver) configuration (standard environments only)
port = 8080 // default
}
deploy {
stopPreviousVersion = true // default - stop the current version
promote = true // default - & make this the current version
}
}
group = 'com.example.appengine'
version = '0.1'
sourceCompatibility = 1.7
targetCompatibility = 1.7
The Firebase Database client can be used on App Engine Standard Environment, as long as you put it in manual scaling mode. See the documentation on cloud.google.com.
We recently fixed a problem when using the SDK on App Engine (release notes), so be sure to use the latest version.
I switched to App Engine Flexible (which was straightforward) and everything is working now.

gcloud app deploy give 400 / forbidden error / cannot push img to google container registry

I am trying to deploy .net core application from google compute vm to google app engine using gcloud app deploy. I get the following error
> WARNING: We couldn't validate that your project is ready to deploy to App Engine Flexible Environment. If deployment fails, please check the following mess
age and try again:
Server responded with code [400]:
Bad Request Unexpected HTTP status 400.
Failed Project Preparation (app_id='s~project-id'). Out of retries. Last error: Temporary error occurred while verifying project: TEMPORARY_ERROR: Unabl
e to check API status
Beginning deployment of service [default]...
WARNING: Deployment of App Engine Flexible Environment apps is currently in Beta
Building and pushing image for service [default]
Some files were skipped. Pass `--verbosity=info` to see which ones.
ERROR: (gcloud.app.deploy) Could not copy [/tmp/tmpLwvVOb/src.tgz] to [us.gcr.io/project-id/appengine/default.20170118t043919:latest]: HttpError accessing
<https://www.googleapis.com/resumable/upload/storage/v1/b/staging.project-id.appspot.com/o?uploadType=resumable&alt=json&name=us.gcr.io%2Fcasepro-v3%2Fappe
ngine%2Fdefault.20170118t043919%3Alatest>: response: <{'status': '403', 'content-length': '166', 'vary': 'Origin, X-Origin', 'server': 'UploadServer', 'x-g
uploader-uploadid': 'AEnB2UqprxH-2tIhsSZdGxDOtS8UnWSI29YTo4kaptNK67SWJpLVqR0zEtCAHgFyE64wj1HfCyUL5sy9z4AZkTRFYuxXfdw5TA', 'date': 'Wed, 18 Jan 2017 04:40:0
0 GMT', 'alt-svc': 'quic=":443"; ma=2592000; v="35,34"', 'content-type': 'application/json; charset=UTF-8'}>, content <{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
>. Please retry.
I have already enabled billing api, app engine admin api and storage api. Service a/c that is being used has editor rights. VM instance has been created using cloud launcher for Jenkins Bitnami package. I am trying to deploy app from command line from the vm before I configure Jenkins to do the same.
What to do to resolve this?
The problem is that gcloud app deploy is trying to deploy to the project id 'project-id', which cannot be your project id.
Try setting the project like this:
gcloud config set project MY-PROJECT-ID
Then, retry the gcloud app deploy command.
If this fails, please reply with your full gcloud command line, and the results of these two commands:
gcloud config list
gcloud version

Resources