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

Compile error found in "samples/snippets" #1043

Closed
HailongWen opened this issue Apr 7, 2021 · 2 comments
Closed

Compile error found in "samples/snippets" #1043

HailongWen opened this issue Apr 7, 2021 · 2 comments
Assignees
Labels
api: spanner Issues related to the googleapis/java-spanner API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. samples Issues that are directly related to samples. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@HailongWen
Copy link
Contributor

I followed the Getting started with Cloud Spanner in Java and did the following:

$ git clone https://github.com/googleapis/java-spanner.git
$ cd java-spanner/samples/snippets
$ mvn package

However, the compilation failed. Note that I did the same thing a while ago and it did work. So I guess this is caused by recent releases that include incompatible changes?

FYI, the errors are:

[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING : 
[INFO] -------------------------------------------------------------
[WARNING] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/TracingSample.java: /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/TracingSample.java uses or overrides a deprecated API.
[WARNING] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/TracingSample.java: Recompile with -Xlint:deprecation for details.
[INFO] 2 warnings 
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithEncryptionKey.java:[30,43] package com.google.cloud.spanner.encryption does not exist
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[26,32] cannot find symbol
  symbol:   class Restore
  location: package com.google.cloud.spanner
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[30,43] package com.google.cloud.spanner.encryption does not exist
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[28,43] package com.google.cloud.spanner.encryption does not exist
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithEncryptionKey.java:[72,30] cannot find symbol
  symbol:   variable EncryptionConfigs
  location: class com.example.spanner.CreateBackupWithEncryptionKey
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[62,11] cannot find symbol
  symbol:   class Restore
  location: class com.example.spanner.RestoreBackupWithEncryptionKey
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[63,9] cannot find symbol
  symbol:   method newRestoreBuilder(com.google.cloud.spanner.BackupId,com.google.cloud.spanner.DatabaseId)
  location: variable adminClient of type com.google.cloud.spanner.DatabaseAdminClient
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[66,30] cannot find symbol
  symbol:   variable EncryptionConfigs
  location: class com.example.spanner.RestoreBackupWithEncryptionKey
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[92,17] cannot find symbol
  symbol:   method getEncryptionConfig()
  location: variable database of type com.google.cloud.spanner.Database
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[60,9] cannot find symbol
  symbol:   method newDatabaseBuilder(com.google.cloud.spanner.DatabaseId)
  location: variable adminClient of type com.google.cloud.spanner.DatabaseAdminClient
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[61,30] cannot find symbol
  symbol:   variable EncryptionConfigs
  location: class com.example.spanner.CreateDatabaseWithEncryptionKey
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[64,9] method createDatabase in interface com.google.cloud.spanner.DatabaseAdminClient cannot be applied to given types;
  required: java.lang.String,java.lang.String,java.lang.Iterable<java.lang.String>
  found:    com.google.cloud.spanner.Database,java.util.List<java.lang.String>
  reason: actual and formal argument lists differ in length
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[85,26] cannot find symbol
  symbol:   method getEncryptionConfig()
  location: variable createdDatabase of type com.google.cloud.spanner.Database
[INFO] 13 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.263 s
[INFO] Finished at: 2021-04-07T11:46:56-07:00
[INFO] Final Memory: 38M/224M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project spanner-snippets: Compilation failure: Compilation failure: 
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithEncryptionKey.java:[30,43] package com.google.cloud.spanner.encryption does not exist
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[26,32] cannot find symbol
[ERROR]   symbol:   class Restore
[ERROR]   location: package com.google.cloud.spanner
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[30,43] package com.google.cloud.spanner.encryption does not exist
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[28,43] package com.google.cloud.spanner.encryption does not exist
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithEncryptionKey.java:[72,30] cannot find symbol
[ERROR]   symbol:   variable EncryptionConfigs
[ERROR]   location: class com.example.spanner.CreateBackupWithEncryptionKey
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[62,11] cannot find symbol
[ERROR]   symbol:   class Restore
[ERROR]   location: class com.example.spanner.RestoreBackupWithEncryptionKey
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[63,9] cannot find symbol
[ERROR]   symbol:   method newRestoreBuilder(com.google.cloud.spanner.BackupId,com.google.cloud.spanner.DatabaseId)
[ERROR]   location: variable adminClient of type com.google.cloud.spanner.DatabaseAdminClient
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[66,30] cannot find symbol
[ERROR]   symbol:   variable EncryptionConfigs
[ERROR]   location: class com.example.spanner.RestoreBackupWithEncryptionKey
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java:[92,17] cannot find symbol
[ERROR]   symbol:   method getEncryptionConfig()
[ERROR]   location: variable database of type com.google.cloud.spanner.Database
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[60,9] cannot find symbol
[ERROR]   symbol:   method newDatabaseBuilder(com.google.cloud.spanner.DatabaseId)
[ERROR]   location: variable adminClient of type com.google.cloud.spanner.DatabaseAdminClient
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[61,30] cannot find symbol
[ERROR]   symbol:   variable EncryptionConfigs
[ERROR]   location: class com.example.spanner.CreateDatabaseWithEncryptionKey
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[64,9] method createDatabase in interface com.google.cloud.spanner.DatabaseAdminClient cannot be applied to given types;
[ERROR]   required: java.lang.String,java.lang.String,java.lang.Iterable<java.lang.String>
[ERROR]   found:    com.google.cloud.spanner.Database,java.util.List<java.lang.String>
[ERROR]   reason: actual and formal argument lists differ in length
[ERROR] /tmp/java-spanner/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java:[85,26] cannot find symbol
[ERROR]   symbol:   method getEncryptionConfig()
[ERROR]   location: variable createdDatabase of type com.google.cloud.spanner.Database
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
@product-auto-label product-auto-label bot added api: spanner Issues related to the googleapis/java-spanner API. samples Issues that are directly related to samples. labels Apr 7, 2021
@olavloite
Copy link
Collaborator

@skuruppu
The problem is that the samples/snippets project is using the Spanner client library version from the Google libraries bom. That is version 5.1.0. Encryption was added in version 6.x. As far as I can tell this was probably caused by the following:

  1. The samples for Database and Backup encryption was merged a little while ago.
  2. That PR probably used a manually set version locally during development, which meant that it wasn't noticed during development.
  3. The CI environment currently does not execute any (integration) tests on the samples as these take too long. Instead, there are (as far as I know) tests executed only on nightly builds. I would expect those nightly builds currently also to be broken. The PR was therefore also green on CI.

I think the best thing to do here is to:

  1. Revert samples: adds samples for CMEK #989 for now and add it back once Spanner client library 6.x is available in the BOM.
  2. Change the build script to at least do a compile of the samples (but perhaps we should also add a couple of unit tests to the samples just to add an extra level of certainty).

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Apr 8, 2021
@zoercai zoercai added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed triage me I really want to be triaged. labels Apr 13, 2021
@thiagotnunes
Copy link
Contributor

The samples dependencies have been updated and should compile now in the latest release: #1046

hengfengli pushed a commit to hengfengli/java-spanner that referenced this issue May 27, 2021
* Add Spanner BatchQuery sample.

* Update pom.xml to use latest client library.

* Update BatchSample.java
rajatbhatta pushed a commit to rajatbhatta/java-spanner that referenced this issue Nov 17, 2022
…s#1695) (googleapis#1043)

* chore(java): update gcp-releasetool and cryptography in java requirements file
Source-Link: https://togithub.com/googleapis/synthtool/commit/74d0956884c1bb9dc901b52de35ca2bca025a74e
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:142286d973c7b6d58186070f203b50058a20a7d7b42147996db24921a18da1b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. samples Issues that are directly related to samples. 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

5 participants