Is anyone using Google AppEngine Flex for their Gr...
# questions
p
Is anyone using Google AppEngine Flex for their Grails projects? I'm having trouble getting it built/configured to find the main class at startup. Up until now I've been using the Java8 environment on AppEngine flex and it was working just fine. 😞
j
I am not using Google AppEngine, but do you have these in your
build.gradle
file?
Copy code
application {
    mainClass.set("com.yourpackage.Application")
}
Copy code
springBoot {
    mainClass.set("com.yourpackage.Application")
}
p
Interesting... not exactly. I have:
Copy code
springBoot {
    mainClassName = "sourcingpro.Application"
}
I'll try your example.
Hm.
Copy code
Could not get unknown property 'mainClass' for object of type org.springframework.boot.gradle.dsl.SpringBootExtension.
j
Ok, it looks like
mainClassName
was deprecated in favor of
mainClass
in Spring Boot 2.4.0 and was scheduled for removal in 2.6.0. So you are on something pre 2.6. I'd experiment with the application gradle plugin config. It also changed from
mainClassName
to
mainClass
at some point. that's my last guess
application {
mainClassName = "sourcingpro.Application"
}
or
application {
mainClass = "sourcingpro.Application"
}
p
Copy code
Could not find method application()
The classNotFound error I'm getting is on the server, as it's unpacking the build and attempting to run it. The config file for the server (app.yaml) is specifying the entrypoint class but it can't find it so I'm wondering if it's something to do with the .war file not being populated correctly. It looks like AppEngine, in the move from Java8 to Java11 runtimes now expects the deployment to have its own Jetty server (rather than provide one in the environment) so there are rather more moving parts to this than I thought. What do most folks use for deploying their projects? GCP? AWS? Complete containers, PaaS? Curious...
j
For AWS Elastic Beanstalk I use the war file from build/lib generated by
grails prod package
or
gradle -Dgrails.env=prod assemble
AWS has an option with Tomcat or without. I use the one without and it executes the app with
java -jar admin.war
https://docs.grails.org/6.2.0/guide/single.html#_runnable_war_or_jar_file I also have a custom gradle task to put the war in a zip file with some aws specific config, but that is not required for it to run the war.
p
Thanks James. That's where I'm heading but struggling to get AppEngine to find the
.war
and the
main()
class. I'm missing some key instruction somewhere...
For anyone else reading this, I solved it for AppEngine Flex by building with
./gradlew bootJar appengineStage
(I'm using Atlassian Pipelines to build, hence
apengineStage
instead of
appengineDeploy
and there are more steps after that). Also getting the right 'entrypoint' command in the
app.yaml
file:
Copy code
runtime: java
env: flex

runtime_config:
    operating_system: "ubuntu18"
    runtime_version: "11"
entrypoint: 'java -jar -Dserver.port=80 sourcingpro-0.1.jar --port=80'
I also had problems getting it to start on port 80, hence the i'm-not-taking-any-chances-with-the-port approach.