GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — AccessControlException (java.io.FilePermission) when trying to access Cloud Storage · Issue #1731 · googleapis/google-cloud-java

AccessControlException (java.io.FilePermission) when trying to access Cloud Storage #1731

New issue
Copy link
New issue
Copy link
Closed
Closed
AccessControlException (java.io.FilePermission) when trying to access Cloud Storage#1731
Copy link
Assignees
garrettjonesgoogle
Labels
api: storageIssues related to the Cloud Storage API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.running on app engine

Description

@Orbyt
Orbyt
opened on Mar 10, 2017
Issue body actions

@lesv

Continuing from the conversation here.

I have tried every method suggested here but routinely get a java.security.AccessControlException which differs depending on which authentication used.

If I don't use .setCredentials (and therefore it trys to authenticate automatically or use GOOGLE_APPLICATION_CREDENTIALS env variable) I get an AccessControlException for a file called active_config. If I instead do call .setCredentials and use a file downloaded by creating a service account key (as specified in option 1 here: https://developers.google.com/identity/protocols/application-default-credentials) then I get the same exception but for that specific file.

@lesv you made this comment in the other issue:

In your case, passing the credentials created by gcloud is incorrect - you need to pass credentials obtained from https://console.cloud.google.com -- why don't you create a new issue, and mention me in it and I'll help you out.

I assume you are referring to the same method I linked to above, correct? If so, as stated, i've tried that.

Activity

Next
  1. lesv commented on Mar 10, 2017

    @lesv
    lesv
    on Mar 10, 2017
    Contributor
    More actions

    First off, what environment are you developing for? GAE Std, Flex, GKE, GCP, something else?
    Is this local development?

    Take a look at the results of gcloud config list, is account set? project?

    Are you using Maven, Gradle, or something else?

    If Maven, which plugin are you using?

  2. Orbyt commented on Mar 10, 2017

    @Orbyt
    Orbyt
    on Mar 10, 2017
    Author
    More actions

    @lesv Java App Engine Standard Environment. I am trying to develop and test out the application locally.

    Output of gcloud config list is the following:

    Your active configuration is: [default]
    
    [core]
    account = [email protected]
    disable_usage_reporting = True
    project = myprojectname-123
    

    Using Maven. There are quite a few plugins listed in my pom.xml, which ones are you asking about?

  3. lesv commented on Mar 10, 2017

    @lesv
    lesv
    on Mar 10, 2017
    Contributor
    More actions

    If you are using the old Maven Plugin, you'll be having the problem that they were discussing in #1500 - we can't access the file system, so none of the access mechanisms work. You might wish to try to the new plugin, but beware, it's BETA, and has trouble doing async IO requests - this should be fixed early next Q.

    Some of the older client libraries (not from this REPO) continue to work with App Engine. (This is probably a better solution than using the new plugin for now). Apologies for the confusion -- I'll look into why we have samples that don't work locally.

  4. Orbyt commented on Mar 10, 2017

    @Orbyt
    Orbyt
    on Mar 10, 2017
    Author
    More actions

    @lesv I assume this conversation I had earlier is relevant: GoogleCloudPlatform/app-maven-plugin#151

    The appengine-maven-plugin I have defined in my pom.xml is as follows:

    <plugin>
        <groupId>com.google.cloud.tools</groupId>
        <artifactId>appengine-maven-plugin</artifactId>
        <version>${appengine-maven-plugin-version}</version>
    </plugin>
    

    I assume this is the "new" plugin. This issue persists.

  5. Orbyt commented on Mar 10, 2017

    @Orbyt
    Orbyt
    on Mar 10, 2017
    Author
    More actions

    Also, note that their seems to be a issue when using the following method:

    Storage storage = StorageOptions.newBuilder()
                .setCredentials(ServiceAccountCredentials.
                    fromStream(getServletContext().getResourceAsStream("credentials.json")))
                .build()
                .getService();
    

    throws an NPE:

    java.lang.NullPointerException
    [INFO] GCLOUD: 	at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213)
    [INFO] GCLOUD: 	at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:127)
    [INFO] GCLOUD: 	at com.google.auth.oauth2.ServiceAccountCredentials.fromStream(ServiceAccountCredentials.java:252)
    [INFO] GCLOUD: 	at com.google.auth.oauth2.ServiceAccountCredentials.fromStream(ServiceAccountCredentials.java:237)
    

    I can read the file normally using GSON, so the file definitely exists. The issue seems to be internal.

  6. shinfan commented on Mar 11, 2017

    @shinfan
    shinfan
    on Mar 11, 2017
    Contributor
    More actions

    @Orbyt Can you provide me the full stacktrace of the AccessControlException?

  7. Orbyt commented on Mar 11, 2017

    @Orbyt
    Orbyt
    on Mar 11, 2017
    Author
    More actions

    @shinfan

    Code:

    public class DemoServlet extends HttpServlet {
      @Override
      public void doGet(HttpServletRequest req, HttpServletResponse resp)
          throws IOException {
    
        Storage storage = StorageOptions.getDefaultInstance().getService();
      }
    } 

    Stacktrace:

    [INFO] GCLOUD: java.security.AccessControlException: access denied ("java.io.FilePermission" "/Users/example/.config/gcloud/active_config" "read")
    [INFO] GCLOUD: 	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
    [INFO] GCLOUD: 	at java.security.AccessController.checkPermission(AccessController.java:884)
    [INFO] GCLOUD: 	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    [INFO] GCLOUD: 	at com.google.appengine.tools.development.devappserver2.DevAppServer2Factory$CustomSecurityManager.checkPermission(DevAppServer2Factory.java:232)
    [INFO] GCLOUD: 	at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
    [INFO] GCLOUD: 	at java.io.FileInputStream.<init>(FileInputStream.java:127)
    [INFO] GCLOUD: 	at com.google.common.io.Files$FileByteSource.openStream(Files.java:126)
    [INFO] GCLOUD: 	at com.google.common.io.Files$FileByteSource.openStream(Files.java:116)
    [INFO] GCLOUD: 	at com.google.common.io.ByteSource$AsCharSource.openStream(ByteSource.java:448)
    [INFO] GCLOUD: 	at com.google.common.io.CharSource.openBufferedStream(CharSource.java:92)
    [INFO] GCLOUD: 	at com.google.common.io.CharSource.readFirstLine(CharSource.java:234)
    [INFO] GCLOUD: 	at com.google.common.io.Files.readFirstLine(Files.java:523)
    [INFO] GCLOUD: 	at com.google.cloud.ServiceOptions.getActiveGoogleCloudConfig(ServiceOptions.java:374)
    [INFO] GCLOUD: 	at com.google.cloud.ServiceOptions.getGoogleCloudProjectId(ServiceOptions.java:391)
    [INFO] GCLOUD: 	at com.google.cloud.ServiceOptions.getDefaultProjectId(ServiceOptions.java:363)
    [INFO] GCLOUD: 	at com.google.cloud.ServiceOptions.getDefaultProject(ServiceOptions.java:336)
    [INFO] GCLOUD: 	at com.google.cloud.ServiceOptions.<init>(ServiceOptions.java:284)
    [INFO] GCLOUD: 	at com.google.cloud.HttpServiceOptions.<init>(HttpServiceOptions.java:179)
    [INFO] GCLOUD: 	at com.google.cloud.storage.StorageOptions.<init>(StorageOptions.java:69)
    [INFO] GCLOUD: 	at com.google.cloud.storage.StorageOptions.<init>(StorageOptions.java:27)
    [INFO] GCLOUD: 	at com.google.cloud.storage.StorageOptions$Builder.build(StorageOptions.java:64)
    [INFO] GCLOUD: 	at com.google.cloud.storage.StorageOptions.getDefaultInstance(StorageOptions.java:99)
    [INFO] GCLOUD: 	at myapp.DemoServlet.doGet(DemoServlet.java:19)
    
    
  8. shinfan commented on Mar 11, 2017

    @shinfan
    shinfan
    on Mar 11, 2017
    Contributor
    More actions

    Thanks, this looks the same issue as #1500. The cause of this issue is:

    [INFO] GCLOUD: 	at com.google.cloud.ServiceOptions.getGoogleCloudProjectId(ServiceOptions.java:391)
    

    where getGoogleCloudProjectId is called due to the runtime failure in com.google.cloud.ServiceOptions.getAppEngineProjectId

    The failure is caused by the reflection method here where the GAE API classes are not loaded in the classpath.

    To confirm, can you try to package your application via maven: mvn clean package and make sure appengine-api-1.0-sdk-1.9.50.jar is in your jar/war package?

  9. Orbyt commented on Mar 11, 2017

    @Orbyt
    Orbyt
    on Mar 11, 2017
    Author
    More actions

    @shinfan Is this why using

    .setCredentials(ServiceAccountCredentials.fromStream(
        getServletContext().getResourceAsStream("credentials.json"))
    )
    

    Also fails, except with an NPE, as shown above?

    I executed mvn clean package. A target/ directory was generated, with the following items:

    • A /generated-sources directory
    • A /maven-archiver directory
    • A /maven-statusdirectory
    • A /snapshot-app-engine directory
    • A /snapshot-app-engine-1.0 directory
    • A snapshot-app-engine-1.0.war

    Inside /snapshot-app-engine-1.0/WEB-INF/lib/ I see a appengine-api-1.0-sdk-1.9.50.jar.

  10. shinfan commented on Mar 11, 2017

    @shinfan
    shinfan
    on Mar 11, 2017
    Contributor
    More actions

    The NPE issue of .setCredentialsshould be a separate issue. Normally you don't need to use that method.

    @lesv Is it okay to ask the customer to send a copy of their sample application so I can try to reproduce the issue here? I could not repro with my own app (my own app works fine after adding the appengine sdk dependency)

  11. Orbyt commented on Mar 11, 2017

    @Orbyt
    Orbyt
    on Mar 11, 2017
    Author
    More actions

    @shinfan @lesv I would have no issue posting a repo to github as the project is empty and only contains a single DemoServlet class. However, because of that i'm not sure how useful posting it would be.

    @shinfan You mentioned you are no longer able to reproduce this issue. Are you saying your are able to call StorageOptions.getDefaultInstance().getService(); without any issues? If so, could this be an issue within the gcloud SDK and it's setup on my machine? Perhaps some type of authentication issue?

  12. shinfan commented on Mar 11, 2017

    @shinfan
    shinfan
    on Mar 11, 2017
    Contributor
    More actions

    Yes, my sample application was able to call StorageOptions.getDefaultInstance().getService(); without any issues. Maybe there are some issues of your local environment but I am not 100% sure, that is why I think it would be helpful for me to debug with your app. If your app runs fine on my local machine, we can probably confirm it is an environment setup issue.

  13. Orbyt commented on Mar 11, 2017

    @Orbyt
    Orbyt
    on Mar 11, 2017
    Author
    More actions

    @shinfan Give me a few minutes and I will upload a repository.

  14. garrettjonesgoogle
    added
    api: storageIssues related to the Cloud Storage API.
    running on app engine
    on Mar 11, 2017
  15. 13 remaining items

  16. garrettjonesgoogle
    closed this as completedon Jul 18, 2017
  17. JustinBeckwith
    assigned
    garrettjonesgoogle
    on Feb 1, 2021
  18. meltsufin
    added a commit that references this issue on Dec 22, 2025

    chore: mark the unmanaged dependency check required (#1731)

    13bc357
  19. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore(main): release 2.26.1 (#1731)

    8b54994
  20. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore: mark the unmanaged dependency check required (googleapis#1731)

    cb8393a
  21. suztomo
    added a commit that references this issue on Mar 23, 2026

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

    4f77781
  22. suztomo
    added a commit that references this issue on Mar 30, 2026

    chore(main): release 0.128.11 (#1731)

    8a3335c
  23. lqiu96
    added a commit that references this issue on Apr 1, 2026

    chore(main): release 0.128.11 (#1731)

    467fa6c
  24. meltsufin
    added 6 commits that reference this issue on Apr 29, 2026

    deps: update dependency org.graalvm.buildtools:native-maven-plugin to…

    403b7e7

    chore(main): release 1.125.2 (#1732)

    629ed33

    chore(main): release 1.133.0 (#2206)

    a3b6539

    deps: update dependency org.graalvm.buildtools:native-maven-plugin to…

    a4adf5a

    chore(main): release 1.125.2 (#1732)

    3d67774

    chore(main): release 1.133.0 (#2206)

    1180af9
  25. benjaminp
    added a commit that references this issue on Jul 13, 2026

    feat: send feature flag when flow control is enabled (googleapis#1731)

    7bccb58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @garrettjonesgoogle
    garrettjonesgoogle

Labels

api: storageIssues related to the Cloud Storage API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.running on app engine

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.