google-cloud-java icon indicating copy to clipboard operation
google-cloud-java copied to clipboard

Cloud Java APIs should work with a local Cloud SDK with GAE Standard.

Open ludoch opened this issue 9 years ago • 25 comments

With the following code in my Java Servlet:

   Storage storage = StorageOptions.getDefaultInstance().getService();
   
   
    String bucketName = "rdayalcloudtest"; // Change this to something unique
    Bucket bucket = storage.create(BucketInfo.of(bucketName));

    // Upload a blob to the newly created bucket
    BlobId blobId = BlobId.of(bucketName, "my_blob_name");
    Blob blob = bucket.create(
        "my_blob_name " + request.hashCode(), "a simple blob".getBytes(UTF_8), "text/plain");

I receive the following exception when attempting to test the code locally, using DevAppServer2:

Problem accessing /hello. Reason:

access denied ("java.io.FilePermission" "/Users/ludo/.config/gcloud/active_config" "read")

Caused by:

java.security.AccessControlException: access denied ("java.io.FilePermission" "/Users/ludo/.config/gcloud/active_config" "read") at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) at java.security.AccessController.checkPermission(AccessController.java:884) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at com.google.appengine.tools.development.devappserver2.DevAppServer2Factory$CustomSecurityManager.checkPermission(DevAppServer2Factory.java:232) at java.lang.SecurityManager.checkRead(SecurityManager.java:888) at java.io.FileInputStream.(FileInputStream.java:127) at com.google.common.io.Files$FileByteSource.openStream(Files.java:125) at com.google.common.io.Files$FileByteSource.openStream(Files.java:115) at com.google.common.io.ByteSource$AsCharSource.openStream(ByteSource.java:420) at com.google.common.io.CharSource.openBufferedStream(CharSource.java:91) at com.google.common.io.CharSource.readFirstLine(CharSource.java:168) at com.google.common.io.Files.readFirstLine(Files.java:513) at com.google.cloud.ServiceOptions.activeGoogleCloudConfig(ServiceOptions.java:354) at com.google.cloud.ServiceOptions.googleCloudProjectId(ServiceOptions.java:372) at com.google.cloud.ServiceOptions.getDefaultProject(ServiceOptions.java:348) at com.google.cloud.ServiceOptions.(ServiceOptions.java:281) at com.google.cloud.HttpServiceOptions.(HttpServiceOptions.java:179) at com.google.cloud.storage.StorageOptions.(StorageOptions.java:69) at com.google.cloud.storage.StorageOptions.(StorageOptions.java:27) at com.google.cloud.storage.StorageOptions$Builder.build(StorageOptions.java:64) at com.google.cloud.storage.StorageOptions.getDefaultInstance(StorageOptions.java:99) at com.example.HelloAppEngine.doGet(HelloAppEngine.java:40)

ludoch avatar Jan 05 '17 00:01 ludoch

@shinfan @ludoch That dependency is already added by default when using the Java GAE quickstart.

It does not solve this issue. #1731 Provides some more information on my specific case, if needed.

Orbyt avatar Mar 10 '17 23:03 Orbyt

Customer confirmed that the issue has been solved on his end. Closing this issue now.

shinfan avatar Mar 13 '17 18:03 shinfan

@shinfan how come we closed this? What's the actual fix?

rdayal avatar Mar 27 '17 19:03 rdayal

@rdayal There is nothing to fix from our side. The issue was caused by a missing dependency and the customer has confirmed things now working. See https://github.com/GoogleCloudPlatform/google-cloud-java/issues/1731

Confirm with @Orbyt

shinfan avatar Mar 27 '17 19:03 shinfan

Thanks, the reason this had been filed on this side is that I had run into this issue independently, and filed an internal bug about it. I wasn't following the other thread. I'll mark the other bug as closed.

rdayal avatar Mar 27 '17 20:03 rdayal