Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

any java11 (beta) supported? #355

Closed
peterweb2005 opened this issue Jul 15, 2019 · 25 comments
Closed

any java11 (beta) supported? #355

peterweb2005 opened this issue Jul 15, 2019 · 25 comments

Comments

@peterweb2005
Copy link

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

@loosebazooka
Copy link
Contributor

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

@peterweb2005
Copy link
Author

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

@loosebazooka
Copy link
Contributor

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?

@peterweb2005
Copy link
Author

peterweb2005 commented Jul 15, 2019

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?

@loosebazooka
Copy link
Contributor

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.

@peterweb2005
Copy link
Author

peterweb2005 commented Jul 15, 2019

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

@peterweb2005
Copy link
Author

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

@loosebazooka
Copy link
Contributor

loosebazooka commented Jul 15, 2019

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.

@peterweb2005
Copy link
Author

sorry, i dont get all of it

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

@loosebazooka
Copy link
Contributor

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.

@peterweb2005
Copy link
Author

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

@peterweb2005
Copy link
Author

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

@loosebazooka
Copy link
Contributor

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.

@peterweb2005
Copy link
Author

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

@loosebazooka
Copy link
Contributor

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.

@peterweb2005
Copy link
Author

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?

@peterweb2005
Copy link
Author

peterweb2005 commented Jul 17, 2019

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!

@peterweb2005
Copy link
Author

Sorry, ok now.

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

@loosebazooka
Copy link
Contributor

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

@peterweb2005
Copy link
Author

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

@loosebazooka
Copy link
Contributor

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/

@peterweb2005
Copy link
Author

thanks

but bootJar can make jar

how to make jar without boot? just jar??

@chanseokoh
Copy link
Contributor

chanseokoh commented Jul 25, 2019

@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.

@kswat
Copy link

kswat commented Mar 22, 2022

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

@elefeint
Copy link
Contributor

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants