Generating Endpoints class from objectify - google-app-engine

As stated in the title, is there a way of doing this using Google Plugin for eclipse?
I tried to generate it using Generate Cloud Endpoints class in GPE, I got this error in appengine log:
org.datanucleus.metadata.MetaDataManager loadPersistenceUnit: Class com.UserDataEndpoint was specified in persistence-unit transactions-optional but not annotated, so ignoring
All the classes I generate using "Generate Cloud Endpoints class" have this error, and can't do any transactions in the API Explorer.
I read in other thread of Stackoverflow, but there is no clear guide on doing this correctly, so I opened a new thread.
Thank you
EDIT : I forgot to mention that I'm using GPE App Engine Connected Android Project wizard to deal with Objectify 5

Related

Jenkins with Google Cloud Source Repository

I am trying to use Jenkins for CI/CD.
I've developed a Python flask application. I am deploying this application into Google App Engine. So far I am using gcloud app deploy app.yaml command to deploy application to Google App Engine.
Code for this application is present in Google Cloud Source Repository.
Since the authentication to git(Google Cloud Source Repository) requires Google OAuth, I've installed Google OAuth Credentials Plugin
Now I am facing two issues
When I use "Google Service Account from metadata" Credential Kind, I am not seeing the credentials listed in "Source Code Management".
when I use "Google Service Account from private key", I am able to see credentials. But when I run my jenkins job I am getting below error
FATAL: Could not call
com.google.jenkins.plugins.source.GoogleRobotUsernamePassword.writeObject()
: Failed to serialize
com.google.jenkins.plugins.source.GoogleRobotUsernamePasswordModule$ForRemote#credentials
for class
com.google.jenkins.plugins.source.GoogleRobotUsernamePasswordModule$ForRemote
---- Debugging information ---- message : Could not call com.google.jenkins.plugins.source.GoogleRobotUsernamePassword.writeObject()
cause-exception : java.lang.RuntimeException cause-message :
Failed to serialize
com.google.jenkins.plugins.source.GoogleRobotUsernamePasswordModule$ForRemote#credentials
for class
com.google.jenkins.plugins.source.GoogleRobotUsernamePasswordModule$ForRemote
------------------------------- java.lang.UnsupportedOperationException: Refusing to marshal
org.joda.time.DateTime for security reasons; see
https://jenkins.io/redirect/class-filter/ at
hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:543)
at
com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at
com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
at
com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
Question: How can I authenticate Google Cloud Source repository in Jenkins? What are the steps|plugins required to use Google Cloud Source repository in Jenkins?
Solution
You probably need to add a missing scope to the Compute Engine VM Instance running Jenkins that would give it access to Cloud Source Repository. You can follow the documentation or this steps, which ever you find convenient.
Go to Cloud Deployment Manager
Click on the name of the Jenkins deployment in question
Click on the instance name in the left info pane and it will redirect you to VM instance details
Stop the instance
Press Edit and set the right access scope for Cloud Source Repository
After your start the VM instance, try adding your git repository again and once you select the credentials, either "Google Service Account from metadata" or from service account, everything should work properly.
Elaboration
I stumbled upon the "Invalid authentication credentials." issue while trying to add a Cloud Source Repository after deploying Jenkins from Launcher.
In my case the reason why it happened was that during the process of deployment the Cloud API access scope for Cloud Source Repositories on the Compute Engine VM instance was set to Disabled, which prevented any interaction from that instance even if a service account had all the necessary roles/permissions.
Here are the scopes that are reconfigured by Launcher:
scopes:
- 'https://www.googleapis.com/auth/cloud.useraccounts.readonly'
- 'https://www.googleapis.com/auth/devstorage.read_only'
- 'https://www.googleapis.com/auth/logging.write'
- 'https://www.googleapis.com/auth/monitoring.write'
{% if enableComputeApi %}
- 'https://www.googleapis.com/auth/compute'
{% endif %}
- 'https://www.googleapis.com/auth/cloudruntimeconfig'
Adding the following scope to the VM instance running Jenkins was enough to fix the error:
https://www.googleapis.com/auth/source.read_only
Extra:
List of scopes for Google APIs.
I updated the plugin to 0.6 version.
In 0.6 version, I have the same problem in Jenkins "Free-style" project.
Bit I can success to checkout in Jenkins "pipeline" project.
I just copy the "checkout syntax" in others project and replace 2 parts of the syntax to the right:
credentialsid -> replace to your right credentials id that you created Google Service Account from private key in jenkins.
url ->replace to your google source repository url

Persistent class does not seem to have been enhanced while accessing Google DataStore using Datanucleus JDO

I am getting the "class does not seem to have been enhanced" error while accessing the Google Data Store in GAE Application. This application was working fine before and was able to pull the data from gae datastore. But I recently updated the GAE SDK to the latest one, imported the project (deleted old one and recreated by importing it in eclipse in the same workspace recently because of another issue) and deployed it to GAE. Since then the web app is getting this error.
I tried few things.
Removed #PersistenceCapable and added it once again. (Rebuilt project after removing and saving it).
In App Engine Settings --> ORM, I removed src and mentioned selected the required folders.
In the .project file, the com.google.appengine.eclipse.core.enhancerbuilder is available.
The Use GWT is enabled.
org.datanucleus.api.jdo.NucleusJDOHelper getJDOExceptionForNucleusException: Exception thrown
Persistent class "Class com.ltt.MyEntity does not seem to have been enhanced. You may want to rerun the enhancer and check for errors in the output." has no table in the database, but the operation requires it. Please check the specification of the MetaData for this class.
org.datanucleus.store.exceptions.NoTableManagedException: Persistent class "Class com.lalit.learn.data.CourseEntity does not seem to have been enhanced. You may want to rerun the enhancer and check for errors in the output." has no table in the database, but the operation requires it. Please check the specification of the MetaData for this class.
at com.google.appengine.datanucleus.DatastoreManager.getDatastoreClass(DatastoreManager.java:551)
None of this resolved the issue. Kindly help me in resolving this issue.

SP implementation using Spring SAML extension with Google App Engine in Java

I try to make a SP hosted on Google app engine, with a third party IdP, and I'm facing multiple problems.
I'm using Spring SAML extension for java. I was able to run the stand alone (not in GAE) demo app, from the official guide http://docs.spring.io/spring-security-saml/docs/1.0.x/reference/html/chapter-quick-start.html using as IdP idp.ssocircle.com.
Now my problem comes whey I tried to integrate this code in my GAE project. When running with GAE I can get to the phase where I'm redirected to do the login on ssocircle.com and from there when I should be redirected back to my page I'm getting this error: "Error 401 Authentication Failed: Error decoding incoming SAML message", and on local GAE server logs I can see this message
"[INFO] Dec 17, 2014 5:21:23 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry [INFO] INFO: I/O exception (java.net.SocketException) caught when processing request: Permission denied: Not allowed to issue a socket bind: permission denied."
I was wondering if this is a limitation from GAE regarding sockets: 1) Sockets are available only for paid apps (I don't have a paid app, but could consider this options) 2) You cannot create a listen socket; you can only create outbound sockets. 3) You cannot bind to specific IP addresses or ports. (for me this one sounds like it is my problem).
And whey I tried to deploy on GAE, the app remained in a start-up loop because of other errors regarding "nested exception is java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")", that sounds like another GAE limitation to me.
At some point I was ready to gave up, because I was thinking that SAML Spring extension can't work with GAE, because of limitations present on GAE. But I see you have the same project running as a demo on GAE (or at least I think it is running on GAE because of the appspot part in domain name). https://saml-federation.appspot.com/saml/discovery?returnIDParam=idp&entityID=saml-federation.appspot.com
I would appreciate if you can give me some hints regarding my problems, and best would be if you could help me with the source code of this demo project (could not find it anywhere), and all configuration that is needed for GAE.
I've created a new repository https://github.com/vschafer/spring-security-saml-gae which includes instructions for deployment of Spring SAML applications on Google Application Engine. It also includes classes helping to avoid issues you're facing (sockets and threads).
In order to use it:
include the jar created from the repo in your project
use the provided org.springframework...StaticFilesystemMetadataProvider for loading of your metadata
in case you are using HTTP-Artifact binding replace bean org.springframework...ArtifactResolutionProfileImpl with org.springframework...google.ArtifactResolutionProfileGAE
Please comment if you spot some mistakes in the documentation or code.

Google Cloud Endpoints .api file not generated

I am using GAE/J to create Google Could Endpoints using #Api and #ApiMethod annotations.
I successfully created an API and was able to test and view it on APIs Explorer but the <appname>-v1.api file is no more generated after I added one more method to the Api class.
I tried removing the new method to check if that was a problem, but even with just the old methods, the .api is not getting generated.

How to access gmail inbox using GAE

We are trying to access gmail inbox from our application in Java. We can read inbox, message, add label, but we are in progress to achieve all the desired functionality.
Our conclusions:
-javax.mail embedded in GAE SDK doesn't work, we can't get the content of e-mail, it returns always null (as expected to not work with IMAP protocol).
With the package mail.jar (https://java.net/projects/javamail/pages/Home), the libraries throws an error because there are two libraries with the same name. (javax)
We investigated and we found a solution on Google Groups consisting in copy the files from javamail.jar to our WEB-INF/classes directory in to our project.
After that, javamail library works but com.sun package is not recognized by our project (eclipse) so we can't get the content of an attachment indeed we need to use "com.sun.mail.util" package.
How can add this libraries to our project?
We use:
App Engine Java SDK 1.7.7
GWT 2.5.1
Java Sun 1.6
Eclipse 3.7.2
You should make sure for recieving emails you should turn on the inbound mail services to true
<inbound-services>
<service>mail</service>
</inbound-services>
There is more configuration details that you can read thro in the documentation.,
Recieve email

Resources