How call GAE EndpointV2 from Java Client - google-app-engine

How can I call GAE Endpoints V2 from my Java Client using google-api-client:1.23.0 library.
I followed the migration description (https://cloud.google.com/endpoints/docs/frameworks/java/migrating) for the backend . Deployment worked fine.
But using the generated endpoints client libs I get the error:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoSuchMethodError: com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient$Builder.setBatchPath(Ljava/lang/String;)Lcom/google/api/client/googleapis/services/AbstractGoogleClient$Builder;
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:133)
Caused by: java.lang.NoSuchMethodError: com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient$Builder.setBatchPath(Ljava/lang/String;)Lcom/google/api/client/googleapis/services/AbstractGoogleClient$Builder;
at com.example.qwarks.backend.qwarksApi.QwarksApi$Builder.setBatchPath(QwarksApi.java:2098)
at com.example.qwarks.backend.qwarksApi.QwarksApi$Builder.<init>(QwarksApi.java:2077)
at com.example.qwarks.utility.Api.<clinit>(Api.java:24)
at com.example.qwarks.screens.SplashScreen.<init>(SplashScreen.java:105)
at com.example.qwarks.Qwarks.create(Qwarks.java:59)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)

I found the problem, I had to remove
compile project(path: ':backend', configuration: 'endpoints')
from my gradle dependencies

Related

Eclipse Oxygen and Google Cloud Tools Missing javax.servlet Classes from Build Path

I have a GAE project in Eclipse that has been working without a problem. I recently upgraded to the Google Cloud SDK 179.0.0 and Eclipse Oxygen.1a Release (4.7.1a) and now, when I open the project, I'm getting build path errors on classes in the javax.servlet.http package. Specifically, the following classes are missing from my project's build path.
javax.servlet.ServletContext
javax.servlet.http.HttpServlet
If you start Eclipse from the console using the following commands (assuming Eclipse is installed in your /Applications folder):
cd /Applications/Eclipse.app/Contents/MacOS
./eclipse
And you watch the terminal window, you'll see a bunch of stack traces similar to the following:
Nov 10, 2017 9:24:57 AM com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider doResolveClasspathContainer
WARNING: Failed to initialize libraries
org.eclipse.core.runtime.CoreException: Could not resolve artifact com.google.appengine:appengine-api-1.0-sdk:jar:1.9.57
at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:776)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$5.call(MavenImpl.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:743)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.resolve(MavenImpl.java:720)
at com.google.cloud.tools.eclipse.util.MavenUtils.resolveArtifact(MavenUtils.java:69)
at com.google.cloud.tools.eclipse.appengine.libraries.repository.MavenHelper.resolveArtifact(MavenHelper.java:46)
at com.google.cloud.tools.eclipse.appengine.libraries.repository.M2RepositoryService.resolveArtifact(M2RepositoryService.java:50)
at com.google.cloud.tools.eclipse.appengine.libraries.repository.LibraryClasspathContainerResolverService.resolveLibraryFileAttachSourceSync(LibraryClasspathContainerResolverService.java:245)
at com.google.cloud.tools.eclipse.appengine.libraries.repository.LibraryClasspathContainerResolverService.resolveLibraryAttachSourcesSync(LibraryClasspathContainerResolverService.java:106)
at com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider.doResolveClasspathContainer(ServletClasspathProvider.java:100)
at com.google.cloud.tools.eclipse.appengine.localserver.ServletClasspathProvider.resolveClasspathContainer(ServletClasspathProvider.java:79)
at org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate.resolveClasspathContainerImpl(RuntimeClasspathProviderDelegate.java:135)
at org.eclipse.jst.server.core.internal.RuntimeClasspathProviderWrapper.resolveClasspathContainerImpl(RuntimeClasspathProviderWrapper.java:155)
at org.eclipse.jst.server.core.internal.RuntimeClasspathContainer.getClasspathEntries(RuntimeClasspathContainer.java:77)
at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2693)
at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2851)
at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1956)
at org.eclipse.jdt.internal.core.ExternalFolderChange.updateExternalFoldersIfNecessary(ExternalFolderChange.java:39)
at org.eclipse.jdt.internal.core.ChangeClasspathOperation.classpathChanged(ChangeClasspathOperation.java:59)
at org.eclipse.jdt.internal.core.SetContainerOperation.executeOperation(SetContainerOperation.java:111)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:724)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:795)
at org.eclipse.jdt.internal.core.JavaModelManager$10.run(JavaModelManager.java:3001)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.jdt.internal.core.JavaModelManager.initializeAllContainers(JavaModelManager.java:3017)
at org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:2038)
at org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:3497)
at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2687)
at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2851)
at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1956)
at org.eclipse.jdt.internal.core.DynamicProjectReferences.getDependentProjects(DynamicProjectReferences.java:34)
at org.eclipse.core.internal.resources.ProjectDescription.computeDynamicReferencesForProject(ProjectDescription.java:950)
at org.eclipse.core.internal.resources.ProjectDescription.getAllBuildConfigReferences(ProjectDescription.java:265)
at org.eclipse.core.internal.resources.ProjectDescription.getAllReferences(ProjectDescription.java:221)
at org.eclipse.core.internal.resources.Project.getReferencedProjects(Project.java:469)
at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.buildConnectedComponents(CloseUnrelatedProjectsAction.java:78)
at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.computeRelated(CloseUnrelatedProjectsAction.java:195)
at org.eclipse.ui.actions.CloseUnrelatedProjectsAction.getSelectedResources(CloseUnrelatedProjectsAction.java:211)
at org.eclipse.ui.actions.SelectionListenerAction.selectionIsOfType(SelectionListenerAction.java:240)
at org.eclipse.ui.actions.CloseResourceAction.updateSelection(CloseResourceAction.java:187)
at org.eclipse.ui.actions.BaseSelectionListenerAction.selectionChanged(BaseSelectionListenerAction.java:124)
at org.eclipse.ui.internal.navigator.resources.actions.ResourceMgmtActionProvider.updateActionBars(ResourceMgmtActionProvider.java:254)
at org.eclipse.ui.internal.navigator.resources.actions.ResourceMgmtActionProvider.fillActionBars(ResourceMgmtActionProvider.java:84)
at org.eclipse.ui.navigator.NavigatorActionService$3.run(NavigatorActionService.java:265)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.navigator.NavigatorActionService.fillActionBars(NavigatorActionService.java:258)
at org.eclipse.ui.navigator.CommonNavigatorManager$UpdateActionBarsJob$1.run(CommonNavigatorManager.java:95)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.navigator.CommonNavigatorManager$UpdateActionBarsJob.runInUIThread(CommonNavigatorManager.java:89)
at org.eclipse.ui.progress.UIJob.lambda$0(UIJob.java:95)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4033)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3700)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1044)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
Contains: Missing com.google.appengine:appengine-api-1.0-sdk:jar:1.9.57
With the 179.0 version of the Google Cloud SDK installed, I now have App Engine 1.9.59 installed versus 1.9.57.
The Eclipse build path contains the following libraries:
App Engine Standard Runtime [App Engine Standard Runtime]
EAR Libraries
JRE System Library [JavaSE-1.8]
TestNG
Web App Libraries
I encounter this same problem with the following Eclipse releases:
4.7.0 (Build Id: 20170620-1800)
4.7.1a (Build Id: 20171005-1200)
The following is a list of errors my project now has:
RequestDispatcher cannot be resolved to a type
The project was not built since its build path is incomplete. Cannot find the class for javax.servlet.ServletContext. Fix the build path then try building this project
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
The type javax.servlet.ServletContext cannot be resolved. It is indirectly referenced from required .class files
Creating a new App Engine Standard Edition project as a Maven project specifies a dependency on the 1.9.57 version of the App Engine API.
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.57</version>
<scope>provided</scope>
</dependency>
Created issue #2754 for this problem on GitHub under the "GoogleCloudPlatform/google-cloud-eclipse" project.
https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/2574
Version Information
Eclipse Oxygen.1a Release (4.7.1a Build: 20171005-1200)
Google Cloud Platform for Eclipse 4.5 and later 1.4.1.201710261936
Google Cloud SDK 179.0.0
alpha 2017.09.15
app-engine-java 1.9.59
app-engine-python 1.9.62
beta 2017.09.15
bq 2.0.27
core 2017.11.06
gcd-emulator v1beta3-1.0.0
gcloud
gsutil 4.28
kubectl
pubsub-emulator 2017.09.15
I don't know the exact cause of the problem, but rebooting my computer resolved the problem reported in this bug. In the course of trying to resolve this problem, I did stop and start Eclipse several times in an effort to address the problem. I started new terminal window sessions in an effort to fix the problem, but that didn't work.
After completely rebooting my machine, the problem reported in this bug went away.

deploy scala sbt to google app engine

While importing my scala sbt project to intellij i get the following error
Error while importing SBT project: ...
[info] Loading project definition from /home/dnilesh/Desktop/app-engine/sbt-appengine-demo-master/project
java.lang.RuntimeException: You need to set APPENGINE_SDK_HOME
at scala.sys.package$.error(package.scala:27)
at sbtappengine.Plugin$AppEngine$.buildAppengineSdkPath(AppenginePlugin.scala:103)
at sbtappengine.Plugin$$anonfun$baseAppengineSettings$33.apply(AppenginePlugin.scala:219)
at sbtappengine.Plugin$$anonfun$baseAppengineSettings$33.apply(AppenginePlugin.scala:219)
at sbt.Init$Value$$anonfun$apply$13.apply(Settings.scala:604)
at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$constant$1.apply(INode.scala:163)
at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$constant$1.apply(INode.scala:163)
at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:175)
at sbt.EvaluateSettings$INode.evaluate(INode.scala:135)
at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:69)
at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:78)
at sbt.EvaluateSettings$$anon$3.run(INode.scala:74)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[error] You need to set APPENGINE_SDK_HOME
[error] Use 'last' for the full log.
Invalid response.
See complete log in file:/home/dnilesh/.IdeaIC2017.2/system/log/sbt.last.log Consult IDE log for more details (Help | Show Log)
and while deploying same app to google app engine from terminal i get the same error after that, In terminal i set APPENGINE_SDK_HOME to my google cloud installation directory /usr/lib/google-cloud-sdk/platform/google_appengine/. then i get the following error.
So how can i set APPENGINE_SDK_HOME and to which path so that sbt appengineDeploy command will work.
root#dnilesh-pc:/home/dnilesh/Desktop/app-engine/sbt-appengine-demo-master# sbt appengineDeploy
[info] Loading project definition from /home/dnilesh/Desktop/app-engine/sbt-appengine-demo-master/project
java.lang.RuntimeException: not found appengine api jar.
at scala.sys.package$.error(package.scala:27)
at sbtappengine.Plugin$AppEngine$.buildSdkVersion(AppenginePlugin.scala:114)
at sbtappengine.Plugin$$anonfun$baseAppengineSettings$32.apply(AppenginePlugin.scala:218)
at sbtappengine.Plugin$$anonfun$baseAppengineSettings$32.apply(AppenginePlugin.scala:218)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:175)
at sbt.EvaluateSettings$INode.evaluate(INode.scala:135)
at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:69)
at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:78)
at sbt.EvaluateSettings$$anon$3.run(INode.scala:74)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] not found appengine api jar.
[error] Use 'last' for the full log.
Steps I did to sort out this issue:
Download the App Engine SDK for Java:
Google App Engine
Direct Download Link
Extract it in your computer regardless your GCloud installed path.
set APPENGINE_SDK_HOME :
export APPENGINE_SDK_HOME= /PATH/TO/SDK/appengine-java-sdk-1.9.54
Download Sample Scala sbt application.
Github Sample Scala App
run sbt appengineDeploy command to run app. change project id to your project id on google cloud. Steps before running app
Notes:
You cannot install third party databases like mongodb on gae.
gae does not support akka framework.
gae does not support multithreading.

AppEngine Remote API NoClassDefFoundError Base64

What jar is Base64 in?
com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64.class is contained in google-http-client-1.13.1-beta.jar, but adding that to the claspath doesn't resolve it.
I just can't figure out what jar has com/google/appengine/repackaged/...
Grrrr... using Appengine.1.9.25 works but switching in 1.9.37 fails....
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/appengine/repackaged/com/google/api/client/repackaged/org/apache/commons/codec/binary/Base64
at com.google.appengine.repackaged.com.google.api.client.util.Base64.encodeBase64URLSafeString(Base64.java:79)
at com.google.appengine.repackaged.com.google.api.client.json.webtoken.JsonWebSignature.signUsingRsaSha256(JsonWebSignature.java:634)
at com.google.appengine.repackaged.com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:378)
at com.google.appengine.repackaged.com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489)
at com.google.appengine.repackaged.com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
at com.google.appengine.repackaged.com.google.api.client.http.HttpRequest.execute(HttpRequest.java:868)
at com.google.appengine.tools.remoteapi.OAuthClient.get(OAuthClient.java:64)
at com.google.appengine.tools.remoteapi.RemoteApiInstaller.getAppIdFromServer(RemoteApiInstaller.java:413)
at com.google.appengine.tools.remoteapi.RemoteApiInstaller.loginImpl(RemoteApiInstaller.java:376)
at com.google.appengine.tools.remoteapi.RemoteApiInstaller.login(RemoteApiInstaller.java:337)
at com.google.appengine.tools.remoteapi.RemoteApiInstaller.install(RemoteApiInstaller.java:173)
Try to use 1.9.26 version. Seems Google missed to package commons-codec into 1.9.37.

JBoss Fuse 6.1: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl could not be instantiated

Environment: JBoss Fuse 6.1 Fabric.
I have a Camel processor where I am trying to instantiate a DocumentBuilderFactory within my java code using
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
And for some reason, I am getting the following error:
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl could not be instantiated: java.lang.IllegalStateException: Bundle is uninstalled
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:110)
at com.cigna.dom.util.DocumentUtils.getDocumentBuilder(DocumentUtils.java:464)
at com.cigna.dom.util.DocumentUtils.createDocument(DocumentUtils.java:489)
at com.cigna.commons.schema.XmlSchemaUtil.documentFromSchema(XmlSchemaUtil.java:70)
at com.cigna.camel.processor.response.DOMResponseProcessor.process(DOMResponseProcessor.java:75)
at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)
I am not sure which bundle is uninstalled here. I tried adding the following bundle to features.xml but of no use.
<bundle dependency="true" start-level="30">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xerces/2.11.0_1</bundle>
This error is not happening all the time. It is very sporadic and sometimes it goes away after restarting the Fuse container.
Any help would be really appreciated. Thanks.

WSDL2Java tool error Apache CXF

We get the following error when we use WSDL2Java tool to generate stubs. The webservice is up and running.
WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsd
l definition from : http://scheduler.heartbeatsoftware.com/scheduler/WebServices
/SampleSNMWebService?wsdl
Caused by : WSDLException: faultCode=PARSER_ERROR: java.lang.IllegalArgumentExce
ption: InputSource must have a ByteStream or CharacterStream
If we donwload the wsdl and generate stubs from that wsdl, they are generated. But the java client using those stubs throws the same exception as above
Strangely when we deploy the same webservice on our LAN such a problem is not encountered stubs are generated sucessfully and the subsequent java client works well.
The webservice is created using apache cxf version 2.2.5 and hosted on tomcat 6
Any pointers would be appreciated
regards
Sameer
Found solution. Just need to modify the wsdl.java.bat to include proxy settings
-Dhttp.proxyHost= -Dhttp.proxyPort=8080

Resources