Skip to content

Compile error found in "samples/snippets" #1043

@HailongWen

Description

@HailongWen

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

Metadata

Metadata

Labels

api: spannerIssues related to the googleapis/java-spanner API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.samplesIssues that are directly related to samples.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions