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

java.lang.IllegalAccessError: class com.google.iam.v1.TestIamPermissionsRequest tried to access method #8970

Open
rogerlzp opened this issue Jan 7, 2024 · 1 comment
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. samples Issues that are directly related to samples. type: question Request for information or clarification. Not an issue.

Comments

@rogerlzp
Copy link

rogerlzp commented Jan 7, 2024

  1. Jar files as following:

    com.google.cloud
    google-cloud-vertexai
    0.1.0

     <dependency>
         <artifactId>libraries-bom</artifactId>
         <groupId>com.google.cloud</groupId>
         <scope>import</scope>
         <type>pom</type>
         <version>26.29.0</version>
     </dependency>
    

Check the dependency:
com.google.cloud:google-cloud-vertexai:0.1.0:
com.google.api.grpc:proto-google-iam-v1:1.24.0

  1. Code segment:
    @RestController
    @RequestMapping("/api/gemini")
    @slf4j
    public class GeminiChatController {

    @value("${google.credentials}")
    private Resource gcpKeyFile;

    @GetMapping("/chat")
    public void test() {
    String projectId = "gptdemo-408313";
    String location = "us-west2";
    String modelName = "gemini-pro-vision";
    try {
    String output = this.simpleQuestion(projectId, location, modelName);
    log.info("output: {}", output);
    System.out.println(output);
    }catch (Exception e) {
    System.out.println(e);}
    }

    public String simpleQuestion(String projectId, String location, String modelName)
    throws Exception {
    // Initialize client that will be used to send requests.
    // This client only needs to be created once, and can be reused for multiple requests.
    GoogleCredentials credentials = GoogleCredentials.fromStream(gcpKeyFile.getInputStream());

     try (VertexAI vertexAI = new VertexAI(projectId, location, credentials)) {
         String output;
         GenerativeModel model = new GenerativeModel(modelName, vertexAI);
    
         GenerateContentResponse response = model.generateContent("Why is the sky blue?");
         output = ResponseHandler.getText(response);
         return output;
     } catch (Exception e) {
         throw new Exception("Failed to make request", e);
     }
    

    }
    }

  2. It failed with the error:
    java.lang.IllegalAccessError: class com.google.iam.v1.TestIamPermissionsRequest tried to access method 'com.google.protobuf.LazyStringArrayList com.google.protobuf.LazyStringArrayList.emptyList()' (com.google.iam.v1.TestIamPermissionsRequest and com.google.protobuf.LazyStringArrayList are in unnamed module of loader 'app')
    at com.google.iam.v1.TestIamPermissionsRequest.(TestIamPermissionsRequest.java:127) ~[proto-google-iam-v1-1.24.0.jar:1.24.0]
    at com.google.iam.v1.TestIamPermissionsRequest.(TestIamPermissionsRequest.java:918) ~[proto-google-iam-v1-1.24.0.jar:1.24.0]
    at com.google.cloud.vertexai.api.stub.GrpcPredictionServiceStub.(GrpcPredictionServiceStub.java:218) ~[google-cloud-vertexai-0.1.0.jar:0.1.0]
    at com.google.cloud.vertexai.api.stub.PredictionServiceStubSettings.createStub(PredictionServiceStubSettings.java:292) ~[google-cloud-vertexai-0.1.0.jar:0.1.0]
    at com.google.cloud.vertexai.api.PredictionServiceClient.(PredictionServiceClient.java:178) ~[google-cloud-vertexai-0.1.0.jar:0.1.0]
    at com.google.cloud.vertexai.api.PredictionServiceClient.create(PredictionServiceClient.java:160) ~[google-cloud-vertexai-0.1.0.jar:0.1.0]
    at com.google.cloud.vertexai.VertexAI.getPredictionServiceClient(VertexAI.java:151) ~[google-cloud-vertexai-0.1.0.jar:0.1.0]
    at com.google.cloud.vertexai.generativeai.preview.GenerativeModel.generateContentStream(GenerativeModel.java:698) ~[google-cloud-vertexai-0.1.0.jar:0.1.0]
    at com.google.cloud.vertexai.generativeai.preview.GenerativeModel.generateContent(GenerativeModel.java:396) ~[google-cloud-vertexai-0.1.0.jar:0.1.0]
    at com.google.cloud.vertexai.generativeai.preview.GenerativeModel.generateContent(GenerativeModel.java:320) ~[google-cloud-vertexai-0.1.0.jar:0.1.0]
    at com.google.cloud.vertexai.generativeai.preview.GenerativeModel.generateContent(GenerativeModel.java:269) ~[google-cloud-vertexai-0.1.0.jar:0.1.0]
    at com.md.gpt.controller.GeminiChatController.simpleQuestion(GeminiChatController.java:46) ~[classes/:na]
    at com.md.gpt.controller.GeminiChatController.test(GeminiChatController.java:29) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.31.jar:5.3.31]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.31.jar:5.3.31]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.31.jar:5.3.31]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.31.jar:5.3.31]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.31.jar:5.3.31]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.31.jar:5.3.31]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072) ~[spring-webmvc-5.3.31.jar:5.3.31]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965) ~[spring-webmvc-5.3.31.jar:5.3.31]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.31.jar:5.3.31]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.31.jar:5.3.31]

Could you please have a look, thanks?

@rogerlzp rogerlzp added priority: p3 Desirable enhancement or fix. May not be included in next release. triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jan 7, 2024
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 7, 2024
@kweinmeister kweinmeister assigned Sita04 and unassigned kweinmeister Jan 14, 2024
@minherz
Copy link
Contributor

minherz commented Jan 17, 2024

Hello @rogerlzp, thank you for reaching out. I apologies for the delayed response. We will need some additional information from you in order to review your report. Can you please provide the following information:

  • What is the path to the code sample that you have a problem with?
  • Did you modify any file of the code sample in your steps to reproduce the problem?
  • Given the reported exception is com.google.iam.v1.TestIamPermissionsRequest what are permissions of the identity you used to run the code sample?

I am temporary assigning this issue to you to reflect the status. Please, assign it to @minherz or @Sita04 once you provide this information.

Thank you

@minherz minherz assigned rogerlzp and unassigned Sita04 Jan 17, 2024
@minherz minherz added type: question Request for information or clarification. Not an issue. and removed type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. triage me I really want to be triaged. labels Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. samples Issues that are directly related to samples. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

6 participants
@rogerlzp @minherz @kweinmeister @Sita04 and others