Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encountered JAVA com.google.apphosting.api.ApiProxy$CallNotFoundException when using geocoding in GCP app-engine #682

Open
frochi42 opened this issue May 14, 2020 · 1 comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@frochi42
Copy link

I need to call GeocodingApi.reverseGeocode from with a java app running in an GCP app-engine. My code looks like:

context = new GeoApiContext.Builder(new GaeRequestHandler.Builder())
.apiKey("").build();

LatLng location = new LatLng(posLat, posLong);
GeocodingApiRequest request = GeocodingApi.reverseGeocode(context, location);
GeocodingResult[] results = request.await();

Running this code gives the exception:

A 2020-05-14T17:42:52.557941036Z com.google.maps.errors.UnknownErrorException: Unexpected exception from com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager

A 2020-05-14T17:42:52.559374731Z at com.google.maps.internal.GaePendingResult.await(GaePendingResult.java:128)

A 2020-05-14T17:42:52.559425995Z at com.google.maps.PendingResultBase.await(PendingResultBase.java:58)

A 2020-05-14T17:42:52.559438799Z at de.bit.daimler.vehicletripanalyzer.geocoding.VTA_GeoCode.getCityName(VTA_GeoCode.java:42)

A 2020-05-14T17:42:52.559526039Z at de.bit.daimler.vehicletripanalyzer.analyzer.TripAnalyzer.buildResponse(TripAnalyzer.java:50)

A 2020-05-14T17:42:52.559550842Z at de.bit.daimler.vehicletripanalyzer.analyzer.TripAnalyzer.analyseTrip(TripAnalyzer.java:43)

A 2020-05-14T17:42:52.559557289Z at de.bit.daimler.vehicletripanalyzer.rest.VTA_RestController.analyzeTrip(VTA_RestController.java:32)

A 2020-05-14T17:42:52.561769118Z at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

A 2020-05-14T17:42:52.561810065Z at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

A 2020-05-14T17:42:52.561891356Z at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

A 2020-05-14T17:42:52.561902134Z at java.lang.reflect.Method.invoke(Method.java:498)

I updated all my recources (especially google-dependencies) to the latest available versions. I also use the latest image for the GCP app engine. But still the error persists.

I guess that this issue is related to #672, but there another language and API-call is used. Therefor I'm raising a new issue.

Help is urgently appreciated... Thanks a lot!

@frochi42 frochi42 added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels May 14, 2020
@johnb9682
Copy link

johnb9682 commented Sep 12, 2020

Think the root cause might be missing EnvironmentFactory stated in ApiProxy.java.
envFactory is null.

        ApiProxy.Environment threadLocalEnvironment = (ApiProxy.Environment)environmentThreadLocal.get();
        if (threadLocalEnvironment != null) {
            return threadLocalEnvironment;
        } else {
            ApiProxy.EnvironmentFactory envFactory = getEnvironmentFactory();
            if (envFactory != null) {
                ApiProxy.Environment environment = envFactory.newEnvironment();
                environmentThreadLocal.set(environment);
                return environment;
            } else {
                return null;
            }
        }

Or do not use Google App Engine client library.

GeoApiContext context = new GeoApiContext.Builder()
    .apiKey("AIza...")
    .build();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants