getting-started-java | The code for the samples | Build Tool library
kandi X-RAY | getting-started-java Summary
kandi X-RAY | getting-started-java Summary
The code for the samples is contained in individual folders on this repository. Follow the instructions at Getting Started on Google Cloud Platform for Java or the README files in each folder for instructions on how to run locally and deploy. Managed VMs on Google Cloud Platform use the Java Servlets & Java Server Pages on Jetty.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Example of performing a POST request .
- Adds a session cookie to the session .
- Set up the context attributes .
- Lists books for a given user .
- Uploads a file to the specified bucket .
- Converts a document to a Book .
- Returns the form .
- String representation .
- Gets information about the JVM .
- Gets the attributes .
getting-started-java Key Features
getting-started-java Examples and Code Snippets
Community Discussions
Trending Discussions on getting-started-java
QUESTION
I'm trying to build a Compute client based on a key .JSON file. I'm looking at the examples found here but they are outdated and not working anymore.
I can't find any example in the current offical docs here.
Here is what I'm currently trying:
...ANSWER
Answered 2020-Apr-30 at 05:25You need these two dependencies:
QUESTION
I try to add custom spans and annotations to an AppEngine Standard application. In the Traces page of the GCP console, I see the default spans but not the custom spans that I have added.
I follow the documentation: https://cloud.google.com/trace/docs/setup/java I use the latest version of opencensus-api 0.23.0
The Stackdrive Trace API is enabled and I see in the metrics page of the API that the application does successful google.devtools.cloudtrace.v2.TraceService.BatchWriteSpans
calls.
I created a sample application based on the official helloworld application that reproduces this problem.
The interesting parts:
...ANSWER
Answered 2019-Aug-27 at 14:52I checked your issue and I made some reproductions on my side and I was able to add the custom span "MyChildWorkSpan" and the annotation "annotation example" making same changes as your did from your code to the Helloworld application in AppEngine Standard with Java 8.
I've used both versions of the io.opencensus (0.12.2 as documented here (with Maven) and 0.23.0 which is the version you're trying to use). In both cases, I was succeeded to see the custom span in the Stackdriver Trace list.
Could you attach a screenshot of what you're seeing in your Google Cloud console > Stackdriver Trace list when browsing to the ? Can you see the custom span "MyChildWorkSpan" and the annotation "annotation example" there? Or is there any other custom span/annotation you're not seeing?
QUESTION
I've deployed a spring boot 2 application on appengine and its doing great.
The only thing is that the standard logging mechanism clashes with the gcp logging system. What I get are hundred of info logs, even when there's an exception thrown or a warning.
I think the problem is that the logs are really long and starts with some unnecessary data.
In my configuration I use lombok+Slf4j to log inside my application, and I think logback is enabled by default since I've spring-boot-starter-web.
my pom has these depencencies:
...ANSWER
Answered 2019-Jul-26 at 10:17In the end I didn't find the proper way to display the logs by console printer in app engine standard with spring boot. However, by using the stackdriver api the logs are indeed prettier.
What I did was including:
QUESTION
I'm building a simple web application using spring boot + app engine. I've followed the guidelines suggested in the getting started github page and everything was working fine until I've tried to implement a simple Filter:
...ANSWER
Answered 2019-Jun-03 at 10:01I've got it.
I didn't follow the getting started page correctly.
I've to exclude spring-boot-starter-tomcat from spring-boot-starter-web and include servlet-api.
Thanks @Saheb for pointing me to the right direction :)
QUESTION
fresh meat newbie on GCP / Maven on
- OSX 10.14.3 with Visual Studio Code (latest)
- GCP SpringBoot API with Maven
- other questions on jetty seem to be further along than me.
- the 'flow' below is to reveal steps to get to my question in the title...I think it's important to see how I got to where I am, and if you are so kind to offer help, you would want to know this? ok, here we go...
I downloaded the GCP getting-started-java github example and want to run the bookshelf example.
When I look at the multiple POM files I see that each references a project ID for GCP.
I can't use the same project ID as they are unique, just like GCP bucket names.
So, when I run
gcloud init
and select or create a configuration and make my own project with a unique project id, does that automatically override every POM file definition of project ID? Or do I need to do some maven clean command to change it???
Well... when I RTFM in each folder, it says to
mvn clean jetty:run-exploded -Dbookshelf.bucket=MY-BUCKET
heck even tried:
mvn jetty:run
and I get a build failure that says:
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups
so... I
brew install jetty
Then to 'get started' jetty says I have to copy the 'plug in' details into my POM file... which one, as there are several??
But when I installed the VS Code plugin, it already updated all POM files; I still get the "No plugin found for prefix 'jetty'" error
I guess I'll stop with that question:
how do I get maven to 'know' that jetty is installed and work with it?
...ANSWER
Answered 2019-Feb-25 at 16:33When you use the shorthand plugin goal jetty:run-exploded
or jetty:run
maven is attempting to find the plugin. This shorthand form will need to resolve the groupId:artifactId:version:goal
in order to run.
The long-hand form of that would be ...
QUESTION
I am trying to run the getting-started samples from Google for Google Cloud Appengine (https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/helloworld). Although the deployment works and it is running in Google Cloud, I fail to start it for the local Java appengine emulator. Google SDK is newest (231), Maven 3.5, Java 8. I try to start that with "mvn appengine:run"
...ANSWER
Answered 2019-Jan-27 at 22:03I found now the error myself. It is simply not working with "java-ibm-x86_64-80" in JAVA_HOME. I am using now instead "java-8-openjdk-amd64" as JAVA_HOME and no problem anymore.
QUESTION
I am trying to add a feature on the "Bookshelf App for Java on App Engine Standard Environment" that lists books based on read or not read. The codes are available here https://github.com/GoogleCloudPlatform/getting-started-java There is a Book.java file that defines the model a book. If I want to add the feature of read or not read do I add a boolean variable in Book.java? Is this a right approach? Or just keep a database table of bookID, user, readOrNot? Or the are some other smart approaches?
...ANSWER
Answered 2018-Jun-21 at 17:28In general, a class like Book.java should only contains properties specific to a book like title, author, published date. If you want to add information like number of pages, you would add it to the book class. In the case of the read or not read feature, it is better to keep this information in a database where book IDs would be attached to a specific user. The user class could keep a book read list but I would recommend a database class that exposes an API to get a list of books for a user. The code would be more reusable. I hope this help you a bit.
QUESTION
I am following the quickstart provided by Google for Java apps on GCloud:
https://cloud.google.com/appengine/docs/standard/java/quickstart
The run phase does work (the app deploys locally), but running mvn appengine:deploy
produces a failed build. Help?
The log:
...ANSWER
Answered 2018-Feb-06 at 10:07There's an open report on the Cloud SDK public issue tracker that might be the same problem: https://issuetracker.google.com/issues/72808542
You could try running:
QUESTION
I was trying to deploy Spring Boot application on Google App Engine (standard environment). At first I cloned example app from this nice tutorial https://springframework.guru/spring-boot-web-application-part-4-spring-mvc/
For example I called http://localhost:8080/products and template with data was displayed.
So everything ran without problems, I was able to call all controller methods locally. Then I decided as experiment to deploy it on GAE. I adjusted pom.xml according to instructions from here https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard
It means I excluded Tomcat dependency, changed packaging from jar to war, created appengine-web.xml file etc. As next step, I created GAE project in GAE console and copied APP ID into appengine-web.xml. Then I ran mvn clean package and war was created in target folder. Finally I started with GAE deployment and it also went smoothly without errors.
My app is now deployed on this URL https://20180109t135551-dot-oe-gae-test.appspot.com/
If you try it, you will see Hello World in browser. But if I try to call /products controller method like this https://20180109t135551-dot-oe-gae-test.appspot.com/products I get "not found" error.
Can you give me advice on which URL should I call my controller methods? Did I forget to implement something like web.xml servlet mapping? Or is it some specific Spring Boot - Google App Engine problem?
I will be grateful for any hint.
Thank you all in advance
...ANSWER
Answered 2018-Jan-15 at 20:05Following this steps translates into the following for the code:
In pom.xml, change
jar
towar
In the package
guru.springframework
add this class:
Code:
QUESTION
I'm trying to following the step-by-step tutorial found here, but the deploy just does not work, always returning Error Response: [13] An internal error occurred
.
I did not change anything in the example code itself. As I said, I just followed the linked tutorial carefully. It fails and return the error above when I try gcloud app deploy
.
Using gcloud app deploy --verbosity debug
it brings some stacktrace, but without any usefull meaning. I'm copying below for completeness:
ANSWER
Answered 2018-Jan-10 at 16:05If the app.yaml file you are using is exactly the same as the one you copied in your question then there seems to be an error in the name and config-id you are entering. With the info provided in your question your app.yaml should look like:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install getting-started-java
Helloworld-servlet Servlet based Hello World app
HelloWorld-jsp Java Server Pages based Hello World app
Bookshelf A full featured app that demonstrates Authentication and CRUD operations for Cloud Datastore and Cloud SQL.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page