首页 > 解决方案 > 组 main 中的调度程序工作人员中的 Azure BlobClient.beginCopy(..) 错误失败并出现未捕获的异常

问题描述

以下是我的代码:

try (CSVReader reader = new CSVReader(new FileReader(csvFile.getAbsolutePath()))) {
            //List<String[]> r = reader.readAll();            
            String[] lineInArray;
            int count = 0;
            while ((lineInArray = reader.readNext()) != null) {
                String interId = lineInArray[0];
                String fileId = null;
                String mp3Name = null;
                List<Map<String, Object>> filesList = ccrDao.retrieveCallIdAndPaths(interId);
                
                for (Iterator iterator = filesList.iterator(); iterator.hasNext();) {
                    Map<String, Object> map = (Map<String, Object>) iterator.next();
                    
                    fileId = map.get("C_CALL_ID")!=null?map.get("C_CALL_ID").toString():"";
                    mp3Name = map.get("C_FILENAME")!=null?map.get("C_FILENAME").toString():"";
                    
                    if(!fileId.equals("") && !mp3Name.equals("")) {
                        String blobName = fileId+"/"+mp3Name;
                        context.getLogger().info("blobName: "+blobName);
                        BlobClient sourceBlobClient = srcContainer.getBlobClient(blobName);
                        context.getLogger().info("source blob client");
                        BlobClient destBlobClient = dstnContainer.getBlobClient(blobName);
                        context.getLogger().info("destination blob client");
                        
                        if(!destBlobClient.exists()) {
                            context.getLogger().info("blobName doesnt exist :"+blobName);
                            BlobServiceSasSignatureValues sas = new BlobServiceSasSignatureValues(OffsetDateTime.now().plusHours(1), BlobContainerSasPermission.parse("r"));
                            String sasToken = sourceBlobClient.generateSas(sas);
                            context.getLogger().info("generated sas token :"+sasToken);
                            destBlobClient.beginCopy(sourceBlobClient.getBlobUrl()+"?"+ sasToken,null);
                            //destBlobClient.copyFromUrl(sourceBlobClient.getBlobUrl());
                            context.getLogger().info(interId+"copied successfully");
                        }else {
                            context.getLogger().info("blob already exists");
                        }

                    }else {
                        context.getLogger().info("No file is present");
                        
                    }

                }
                count++;
                context.getLogger().fine("Recourd Count "+count);
            }
            
        } catch (Exception e ) { //IOException | CsvException
            context.getLogger().severe("Error occured while copying the data :"+e.getMessage());
            e.printStackTrace();
        }

在线获取以下错误

"destBlobClient.beginCopy(sourceBlobClient.getBlobUrl()+"?"+ sasToken,null);" 
正文 {font-family:Arial; 左边距:40px;}img { 边框:0 无;}#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; 字体粗细:正常;颜色:#000000;边距:34px 0px 0px 0px }#message p { 字体大小:13px; 颜色:#000000;边距:7px 0px 0px0px}#errorref { 字体大小:11px; 颜色:#737373;margin-top: 41px }服务不可用

我们的服务暂时不可用

我们正在努力尽快恢复所有服务。请稍后再回来查看。

0XjmzYAAAAAC2Ast2oBmIS47phNpxTuFBQk9NMDFFREdFMDIxOQA3ZGIwYWMxYy1iNzZkLTRiYTQtYTE3NS01NTgxNTUxMTEzZDU=主组中的调度程序工作程序错误失败,出现未捕获的异常。

标签: spring-bootazureazure-functionscloudazure-blob-storage

解决方案


正如怀疑的那样,这些问题与层或任何扩展问题无关。在执行我的函数时没有显示完整的日志,我的代码也无法捕获异常,所以我按照以下步骤操作。

  1. 通过 Kudu -Debug 控制台检查了“主机”日志。
  2. 能够在 beginCopy() 步骤找到实际错误,如下所述

2021-05-31T14:37:48.513 [信息] 2021-05-31 14:37:48.494 错误 5820 --- [parallel-1] reactor.core.scheduler.Schedulers:组 main 中的调度程序工作人员因未捕获的异常而失败2021-05-31T14:37:48.513 [信息] java.lang.NoSuchMethodError: okhttp3.RequestBody.create(Lokio/ByteString;Lokhttp3/MediaType;)Lokhttp3/RequestBody;

  1. 在对上述错误进行分析后,通过添加以下依赖项来覆盖我的 pom.xml 中的 okhttp 版本
<dependency>      
       <groupId>com.squareup.okhttp3</groupId>     
       <artifactId>okhttp</artifactId>     
       <version>4.9.1</version>      
</dependency>
  1. 清理软件包并将所有库替换为现有库。不要只替换函数应用程序中的一个库,因为它的依赖库(如 okio jar)也必须更新

推荐阅读