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

Error with gcloud-java for datastore access from compute engine: “LookupRequest overrides final method getUnknownFields” #681

Closed
unitydynamics opened this issue Feb 28, 2016 · 6 comments
Assignees

Comments

@unitydynamics
Copy link

I started a brand new Java project (Java 8) and used maven to pull down my dependencies:

<dependency>
  <groupId>com.google.gcloud</groupId>
  <artifactId>gcloud-java</artifactId>
  <version>0.1.4</version>
</dependency>

I then wrote a very simple test call to write to the datastore... but there seems to be something structurally wrong with the library... here is the exception I ran into:

java.lang.VerifyError: class com.google.api.services.datastore.DatastoreV1$LookupRequest overrides final method getUnknownFields.

()Lcom/google/protob
uf/UnknownFieldSet;
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at com.google.gcloud.datastore.DatastoreOptions.normalize(DatastoreOptions.java:123)
        at com.google.gcloud.datastore.DatastoreOptions.access$400(DatastoreOptions.java:36)
        at com.google.gcloud.datastore.DatastoreOptions$Builder.build(DatastoreOptions.java:89)
        at com.google.gcloud.datastore.DatastoreOptions.defaultInstance(DatastoreOptions.java:175)

    ... my code here which called Datastore datastore = DatastoreOptions.defaultInstance().service();

I have plenty of jars but my environment is clean... I don't have any of the legacy google.appengine.* jars around. Just to make sure:

find . -name "*.jar" -exec grep -Hsli LookupRequest {} \;
returned only:

./google-api-services-datastore-protobuf-v1beta2-rev1-4.0.0.jar

Is the Google distribution broken? Is this a me thing? Any help appreciated.

@aozarov
Copy link
Contributor

aozarov commented Feb 28, 2016

Looks like you are pulling a version of com.google.protobuf:protofuf-java which is not compatible with the underlying datastore-protobuf dependency google-api-services-datastore-protobuf-v1beta2-rev1-4.0.0.

Try running mvn dependency:tree -Dverbose -Dincludes=com.google.protobuf:protobuf-java to see
where you are pulling it from and exclude it from there.

A similar reported issue discovered that it was pulled from j2html and disabled it this way:

  <dependency>
     <groupId>com.j2html</groupId>
     <artifactId>j2html</artifactId>
     <version>0.7</version>
     <exclusions>
       <exclusion>
         <groupId>com.google.guava</groupId>
         <artifactId>guava</artifactId>
       </exclusion>
       <exclusion>
         <groupId>com.google.protobuf</groupId>
         <artifactId>protobuf-java</artifactId>
       </exclusion>
     </exclusions>
   </dependency>

/cc @eddavisson

@unitydynamics
Copy link
Author

[WARNING] Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution
[INFO] .... my jar......
[INFO] \- com.google.gcloud:gcloud-java:jar:0.1.4:compile
[INFO]    \- com.google.gcloud:gcloud-java-datastore:jar:0.1.4:compile
[INFO]       \- com.google.apis:google-api-services-datastore-protobuf:jar:v1beta2-rev1-4.0.0:compile
[INFO]          +- com.google.protobuf:protobuf-java:jar:3.0.0-beta-1:compile
[INFO]          \- com.google.http-client:google-http-client-protobuf:jar:1.15.0-rc:compile
[INFO]             \- (com.google.protobuf:protobuf-java:jar:2.4.1:compile - omitted for conflict with 3.0.0-beta-1)

Thanks for pointing me in the right direction.... I should have noticed that old version of http-client-protobuf was there. I moved that to 1.21 and deleted protobuf-java-2.4.1.jar and I'm off to the races now. Thank you @aozarov

I immediately tested an now I'm getting "not authorized" type of error...

Feb 29, 2016 1:08:06 PM com.google.api.services.datastore.client.BaseDatastoreFactory makeClient
WARNING: Not using any credentials
Feb 29, 2016 1:08:07 PM com.google.api.services.datastore.client.BaseDatastoreFactory makeClient
WARNING: Not using any credentials
com.google.gcloud.datastore.DatastoreException
        at com.google.gcloud.spi.DefaultDatastoreRpc.translate(DefaultDatastoreRpc.java:110)
        at com.google.gcloud.spi.DefaultDatastoreRpc.lookup(DefaultDatastoreRpc.java:147)
        at com.google.gcloud.datastore.DatastoreOptions.normalize(DatastoreOptions.java:128)
        at com.google.gcloud.datastore.DatastoreOptions.access$400(DatastoreOptions.java:36)
        at com.google.gcloud.datastore.DatastoreOptions$Builder.build(DatastoreOptions.java:89)
        at com.google.gcloud.datastore.DatastoreOptions.defaultInstance(DatastoreOptions.java:175)
        at com.industryopenings.seeker.driver.SiteLogger.saveEntry(SiteLogger.java:122)
        at com.industryopenings.seeker.driver.SiteLogger.log(SiteLogger.java:235)
        at com.industryopenings.seeker.driver.SiteLogger.log(SiteLogger.java:188)
        at com.industryopenings.seeker.driver.SiteLogger.info(SiteLogger.java:273)
        at com.industryopenings.seeker.driver.Driver.main(Driver.java:61)
Caused by: com.google.api.services.datastore.client.DatastoreException
        at com.google.api.services.datastore.client.RemoteRpc.makeException(RemoteRpc.java:115)
        at com.google.api.services.datastore.client.RemoteRpc.call(RemoteRpc.java:81)
        at com.google.api.services.datastore.client.BaseDatastoreFactory$RemoteRpc.call(BaseDatastoreFactory.java:41)
        at com.google.api.services.datastore.client.Datastore.lookup(Datastore.java:93)
        at com.google.gcloud.spi.DefaultDatastoreRpc.lookup(DefaultDatastoreRpc.java:145)
        ... 9 more
Caused by: com.google.api.client.http.HttpResponseException: 401 Unauthorized
        at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1061)
        at com.google.api.services.datastore.client.RemoteRpc.call(RemoteRpc.java:78)
        ... 12 more

If I can bug you just one more time... what's the magic I need to add to authenticate? Perhaps I read the docs too quickly... I thought it was handled automatically. My compute engine instances is in the same project... but inspection of the environment variables doesn't seem to yield anything that would tip off gcloud-java what my project ID is.

I'm almost there!

Oh and I built my custom image from the standard image: debian-8-jessie-v20160219
... and here is the permissions section on my instance. I haven't tried with "Allow All" option yet... maybe I'll test that.

image

@mziccard
Copy link
Contributor

@unitydynamics glad you solved your original issue.

For the 401 Unauthorized error try also adding the "User Info" scope (the first permission in your screenshot) when you create the instance.

@unitydynamics
Copy link
Author

You nailed it @mziccard . I've written my first entity to the datastore with gcloud-java! Thanks.

I noticed the required permissions are indeed documented...: https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/authentication/readme.md#authentication

but... I'm probably not the last wandering spirit to trip over this... gentle recommendation to clean up the scopes.

@unitydynamics
Copy link
Author

On more small comment... Stderr is getting littered with plenty of:
Feb 29, 2016 3:14:07 PM com.google.api.services.datastore.client.BaseDatastoreFactory makeClient
WARNING: Not using any credentials

@aozarov
Copy link
Contributor

aozarov commented Feb 29, 2016

@unitydynamics You can safely ignore this WARNING. It will be gone in the next version of the datastore
(v1beta3). Also, the need to use "User Info" scope is going to be removed by then.

github-actions bot pushed a commit that referenced this issue Jun 23, 2022
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 456641589

Source-Link: googleapis/googleapis@8a251f5

Source-Link: googleapis/googleapis-gen@4ca52a5
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9
github-actions bot pushed a commit to suztomo/google-cloud-java that referenced this issue Jun 29, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
github-actions bot pushed a commit to suztomo/google-cloud-java that referenced this issue Jun 29, 2022
)

* chore: update dependencies for regapic

* add more dependencies and trigger comment

* update goldens

* fix indentation

* remove duplicate gax-httpjson dependency

* remove duplicated dependencies
Source-Link: googleapis/synthtool@fa54eb2
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906
github-actions bot pushed a commit to suztomo/google-cloud-java that referenced this issue Jun 29, 2022
)

* chore: update dependencies for regapic

* add more dependencies and trigger comment

* update goldens

* fix indentation

* remove duplicate gax-httpjson dependency

* remove duplicated dependencies
Source-Link: googleapis/synthtool@fa54eb2
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906
github-actions bot pushed a commit to suztomo/google-cloud-java that referenced this issue Jul 1, 2022
🤖 I have created a release *beep* *boop*
---


## [2.4.0](googleapis/java-servicedirectory@v2.3.0...v2.4.0) (2022-07-01)


### Features

* Enable REST transport for most of Java and Go clients ([googleapis#681](googleapis/java-servicedirectory#681)) ([7917b3f](googleapis/java-servicedirectory@7917b3f))


### Dependencies

* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([googleapis#680](googleapis/java-servicedirectory#680)) ([21e1422](googleapis/java-servicedirectory@21e1422))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
github-actions bot pushed a commit that referenced this issue Jul 14, 2022
Source-Link: googleapis/synthtool@18d4e9b
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:f8374176dc59291f05dd3fec927a9da2cda687a9ef4de32e77f699a2be12ab45
github-actions bot pushed a commit that referenced this issue Jul 14, 2022
…681)

* chore(deps): update dependency com.google.cloud:libraries-bom to v26

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
github-actions bot pushed a commit that referenced this issue Aug 9, 2022
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
github-actions bot pushed a commit that referenced this issue Aug 18, 2022
…1.0 (#681)

[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:libraries-bom](https://cloud.google.com/java/docs/bom) ([source](https://togithub.com/googleapis/java-cloud-bom)) | `26.0.0` -> `26.1.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.0/compatibility-slim/26.0.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.0/confidence-slim/26.0.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-redis).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNTguMCIsInVwZGF0ZWRJblZlciI6IjMyLjE1OC4wIn0=-->
suztomo pushed a commit that referenced this issue Feb 1, 2023
…onfig to v1.4.0 (#681)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:google-cloud-shared-config](https://togithub.com/googleapis/java-shared-config) | `1.3.3` -> `1.4.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.4.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.4.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.4.0/compatibility-slim/1.3.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.4.0/confidence-slim/1.3.3)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/java-shared-config</summary>

### [`v1.4.0`](https://togithub.com/googleapis/java-shared-config/blob/HEAD/CHANGELOG.md#&#8203;140-httpsgithubcomgoogleapisjava-shared-configcomparev133v140-2022-04-28)

[Compare Source](https://togithub.com/googleapis/java-shared-config/compare/v1.3.3...v1.4.0)

##### Features

-   **java:** remove native image module ([#&#8203;471](https://togithub.com/googleapis/java-shared-config/issues/471)) ([7fcba01](https://togithub.com/googleapis/java-shared-config/commit/7fcba016b3138d7beaa4e962853f9bc80f59438c))

##### [1.3.3](https://togithub.com/googleapis/java-shared-config/compare/v1.3.2...v1.3.3) (2022-04-19)

##### Bug Fixes

-   **java:** remove protobuf feature from native profile ([#&#8203;461](https://togithub.com/googleapis/java-shared-config/issues/461)) ([ffd07cb](https://togithub.com/googleapis/java-shared-config/commit/ffd07cb18ee7d45d4daee1d9ea6f6d321fdca874))

##### Dependencies

-   update dependency com.google.cloud:native-image-support to v0.12.11 ([#&#8203;459](https://togithub.com/googleapis/java-shared-config/issues/459)) ([d20008d](https://togithub.com/googleapis/java-shared-config/commit/d20008df15209708fdf9d06828b567778190f4d0))
-   update dependency com.google.cloud:native-image-support to v0.13.1 ([#&#8203;465](https://togithub.com/googleapis/java-shared-config/issues/465)) ([b202064](https://togithub.com/googleapis/java-shared-config/commit/b2020648816feb4740ad70acedfed470d7da5bcf))

##### [1.3.2](https://togithub.com/googleapis/java-shared-config/compare/v1.3.1...v1.3.2) (2022-03-28)

##### Dependencies

-   revert google-java-format to 1.7 ([#&#8203;453](https://togithub.com/googleapis/java-shared-config/issues/453)) ([cbc777f](https://togithub.com/googleapis/java-shared-config/commit/cbc777f3e9ab75edb6fa2e0268a7446ae4111725))

##### [1.3.1](https://togithub.com/googleapis/java-shared-config/compare/v1.3.0...v1.3.1) (2022-03-25)

##### Dependencies

-   update dependency com.google.cloud:native-image-support to v0.12.10 ([#&#8203;443](https://togithub.com/googleapis/java-shared-config/issues/443)) ([5b39d5e](https://togithub.com/googleapis/java-shared-config/commit/5b39d5ee15121f052226ff873b6ab101e9c71de5))
-   update dependency com.google.googlejavaformat:google-java-format to v1.15.0 ([#&#8203;426](https://togithub.com/googleapis/java-shared-config/issues/426)) ([4c3c4b6](https://togithub.com/googleapis/java-shared-config/commit/4c3c4b66129632181e6bc363a0ecccf4f5aac914))
-   update dependency org.graalvm.buildtools:junit-platform-native to v0.9.11 ([#&#8203;448](https://togithub.com/googleapis/java-shared-config/issues/448)) ([f7f518e](https://togithub.com/googleapis/java-shared-config/commit/f7f518e87d1d9feb9ac54d7c099f97d8751ee3da))
-   update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.11 ([#&#8203;449](https://togithub.com/googleapis/java-shared-config/issues/449)) ([3e1c0b5](https://togithub.com/googleapis/java-shared-config/commit/3e1c0b5a1d2f4a0db88c06a0d683ed90cbc745e2))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-shared-dependencies).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants