GoogleCloudPlatform / app-gradle-plugin

The library has moved to https://github.com/GoogleCloudPlatform/appengine-plugins/tree/main/app-gradle-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

any java11 (beta) supported?

peterweb2005 opened this issue · comments

https://cloud.google.com/appengine/docs/standard/java11/java-differences

tried to migrate, updated config to yaml, and added main class,
and the problem is:
dont know how to package jar (or war??) file??

and the error log are:
Could not find or load main class XXX-1.0.war A
java.lang.ClassNotFoundException: XXX-1.0.war A

from the "WAR migration example" (refer to 1st link),
helloworld-servlet project depends appengine-simple-jetty-main project (pom.xml)
and also has entry point:
entrypoint: 'java -cp * com.example.appengine.demo.jettymain.Main helloworld.war' (app.yaml)

can it be done for only 1 project?
or simply CANT it be done in gradle plugin?

thanks

commented

I'm not sure I understand your issue. Can you provide some more detail on what you're trying to do?

trying

I'm not sure I understand your issue. Can you provide some more detail on what you're trying to do?

thanks,
to deploy runtime java11 using the gradle plugin instead of "official supported" maven plugin

commented

So you're having trouble packaging it as a war?

The gradle java plugin automatically generates jars when you build (https://docs.gradle.org/current/userguide/java_plugin.html), and the war plugin changes the build artifact to be war (https://docs.gradle.org/current/userguide/war_plugin.html)

Do you already have a working maven build?

So you're having trouble packaging it as a war?

The gradle java plugin automatically generates jars when you build (https://docs.gradle.org/current/userguide/java_plugin.html), and the war plugin changes the build artifact to be war (https://docs.gradle.org/current/userguide/war_plugin.html)

Do you already have a working maven build?

no, seldom use maven, because just like google, moving away from xml

i just check that there is no app jar (supposed "my-project".jar) generated in build */*, is that normal?

commented

When you run ./gradlew jar you should see a jar in build/libs unless you are generating a war

It might be helpful to do a few gradle tutorials to understand the build system. Gradle has it's own conventions and behavior that would be helpful for you to understand your problem.

yes, there is the war
but
having entrypoint: 'java -cp * <package>.Main XXX.war' in app.yaml
still
Could not find or load main class XXX-1.0.war A
java.lang.ClassNotFoundException: XXX-1.0.war A

is it the "1.0" problem, no version in entrypoint??
but tried:
entrypoint: 'java -cp * <package>.Main XXX-1.0.war' in app.yaml
still the above error

previously tried this type of entrypoint:
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/appengine-java11/custom-entrypoint/app.yaml
similiar:
Error: Could not find or load main class "package".Main.java

commented

I mean those are sample instructions. You do not have a XXX.war, so this is definitely not going to work.

It would probably be helpful for you to understand what a container entrypoint is, otherwise these instructions aren't going to make sense. In general see here: https://github.com/opencontainers/image-spec/blob/e562b04403929d582d449ae5386ff79dd7961a11/specs-go/v1/config.go#L34 or any other resource if you search "entrypoint container"

In this specific case, this is the command appengine is using to start your application. You might start off by figuring out how to run your application locally. I would assume something like java -jar my-project.jar (you might have to include all dependencies and a main class definition using some sort of fat jar plugin like: https://github.com/johnrengelman/shadow). Giving it something that has nothing to do with your app wont make sense.

It should be the same command you are using to run your app locally.

sorry, i dont get all of it

in jetty, command line run needed a start.jar;
does appengine need?

commented

I would start with an example and see if you could get it to work: https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appengine-java11/appengine-simple-jetty-main

It's a java11 example with jetty.

I would start with an example and see if you could get it to work: https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appengine-java11/appengine-simple-jetty-main

It's a java11 example with jetty.

many thanks

4 ways??:

  1. no endpoint, correct jar manifest to main class
    -the plugin not jar artfitact
  2. endpoint to main class
    -same problem as 1
  3. endpoint call jar to war
    -not tried, dont want exta project
  4. spring boot similar to 3
    -dont want spring, too many deps & seems slow
commented

Its hard to understand your problem. '4 ways??' is hard to parse. If you could be more clear, it might help us help you? Prefer full descriptive sentences of everything you tried, things you don't understand and you goals.

Its hard to understand your problem. '4 ways??' is hard to parse. If you could be more clear, it might help us help you? Prefer full descriptive sentences of everything you tried, things you don't understand and you goals.

Sorry, seems 4 ways to make the deploy work, because it always need jar for command line.
And if the plugin support runtime java 11 beta, I think it should enable 1,2, and therefore make the artifcat jar and can run through command line, thanks

commented

Okay so I still can't understand what you need.
How about you provide us with a minimized version of your java8 app and we can see how to move it to java11. I'm afraid I've been unable to decipher what the issue us just from the comments.

beta java11 can only run in command line, so need jar file

but the plugin now can only build war, can it build jar?
Or I miss something?

tried maven example of spring boot:
https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appengine-java11/springboot-helloworld

it works.

then tried use gradle instead, trying task of gradle plugin to replace:
(DONT know how to write xml here, repackage goal in maven plugin)

<plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>2.1.6.RELEASE</version>
          <executions>
              <execution>
                  <goals>
                      <goal>repackage</goal>
                  </goals>
              </execution>
          </executions>
      </plugin>

with
bootJar {}

but failed:

Failed to create directory 'D:\peter\w\appengine_springboot\build\staged-app'

and can java -jar XXX.jar in build/libs:
Hello world!

Sorry, ok now.

but need manually copy jar from build/libs to build/staged-app
and need spring boot

commented

It looks like you're trying to specify the artifact.

Try setting the artifact:

appengine {
  stage {
    artifact = "path/to/springbootjar"
  }
}

See https://github.com/GoogleCloudPlatform/app-gradle-plugin/blob/master/USER_GUIDE.md#app-engine-appyaml-based-projects for configuring you build

thanks,
but if (i) dont like spring, and also its boot,
any updates scheduled?

commented

You can specify the artifact to be whatever jar you want, doesn't have to be spring boot. In order for us to help you, you must specify clearly what you want in great detail. You might benefit from spending a few days learning about how gradle works and the java artifacts it builds before you continue with your project. Unfortunately this is not an extensive support channel so we cannot work through your issue and help you understand java web apps step by step. If you wish to get more support you can contact cloud support directly: https://cloud.google.com/support/

thanks

but bootJar can make jar

how to make jar without boot? just jar??

@peterweb2005 I just saw GoogleCloudPlatform/java-docs-samples#1517 and other activities on that repo. Looks like you've managed to migrate to the Java 11 runtime. Closing the issue.

commented

I'm unable to deploy my springboot war into Appengine. The project uses gradle (not maven). Is there a gradlew example?

@kswat https://github.com/GoogleCloudPlatform/app-gradle-plugin#how-to-use
In the future, please open a new issue with reproduction steps, rather than commenting on a closed issue.