0

''''Java Code where we re getting Error, I have tried with multiple secret manager version but getting same issue. Its is showing Bean related issue

@Configuration
public class AttachmentImpl implements Attachment {     
    @Value("${bucket.uploadbucket}")
    private String bucket;      
    @Value("${gcp.project.projectid}")
    private String projectid;       
    @Value("${key}")
    private String key;
    
    @Override
    public String getAttachmentURL(String projectId, String bucketName, String objectName) throws Exception{        
        
            Storage storage = StorageOptions.newBuilder().setCredentials(GoogleCredentials.getApplicationDefault()).build().getService();    
            // Define resource
            BlobInfo blobInfo = BlobInfo.newBuilder(BlobId.of(bucketName, objectName)).build();    
            URL url = storage.signUrl(blobInfo, 30, TimeUnit.MINUTES, Storage.SignUrlOption.withV4Signature());
            
            return url.toString();
    }
<project>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.8</version>
        <relativePath />
    </parent>

    <dependencies>
        <!-- ... -->

        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
            <version>2.0.0</version>
        </dependency>
        <!-- ... -->
    </dependencies>
</project>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AttachmentImpl': Injection of autowired dependencies failed; nested exception is com.google.api.gax.rpc.UnavailableException: io.grpc.StatusRuntimeException: UNAVAILABLE: Failed ALPN negotiation: Unable to find compatible protocol
Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0]

I have tried with solution given in below link but no success:

Problem with GCP Secret Manager and Spring Boot app

parmendrak74
  • 83
  • 1
  • 8

0 Answers0