gang_qi_xi_2 2020-07-16 14:52 采纳率: 75%
浏览 144
已采纳

在本地运行微信公众号的上传功能是可以实现,但放到was服务器上报错了?

本地运行微信公众号的上传功能可以实现,放到was服务器上报错,这该如何处理,报错日志见附件如下:

[20-7-16 12:59:11:585 CST] 00000040 SystemErr R java.lang.reflect.InvocationTargetException

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at java.lang.reflect.Method.invoke(Method.java:600)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.haitaiinc.Action.invoke(Action.java:67)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.haitaiinc.servlet.ServletAction.invoke(ServletAction.java:166)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.haitaiinc.servlet.Servlet.service(Servlet.java:132)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:183)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R Caused by: javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.g: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is:

java.security.cert.CertPathValidatorException: The certificate issued by CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US is not trusted; internal cause is: 
java.security.cert.CertPathValidatorException: Certificate chaining error

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.n.a(n.java:36)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.sc.a(sc.java:442)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.gb.a(gb.java:18)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.gb.a(gb.java:205)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.hb.a(hb.java:46)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.hb.a(hb.java:57)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.gb.n(gb.java:285)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.gb.a(gb.java:146)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.sc.a(sc.java:88)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.sc.g(sc.java:437)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.sc.a(sc.java:544)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.sc.startHandshake(sc.java:124)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.net.ssl.www2.protocol.https.c.afterConnect(c.java:48)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:39)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:899)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.net.ssl.www2.protocol.https.b.getOutputStream(b.java:47)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.haitaiinc.until.RequestUtils.f_upload(RequestUtils.java:100)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.haitaiinc.edc.wxmaterial.WxMaterialAction.uploadImage(WxMaterialAction.java:177)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R ... 29 more

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R Caused by: com.ibm.jsse2.util.g: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is:

java.security.cert.CertPathValidatorException: The certificate issued by CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US is not trusted; internal cause is: 
java.security.cert.CertPathValidatorException: Certificate chaining error

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.util.e.b(e.java:101)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.util.e.b(e.java:35)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.util.d.a(d.java:12)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.gc.a(gc.java:28)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.gc.checkServerTrusted(gc.java:16)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.ws.ssl.core.WSX509TrustManager.checkServerTrusted(WSX509TrustManager.java:358)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.hb.a(hb.java:6)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R ... 42 more

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R Caused by: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is:

java.security.cert.CertPathValidatorException: The certificate issued by CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US is not trusted; internal cause is: 

java.security.cert.CertPathValidatorException: Certificate chaining error

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.security.cert.PKIXCertPathBuilderImpl.engineBuild(PKIXCertPathBuilderImpl.java:411)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:258)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.jsse2.util.e.b(e.java:49)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R ... 48 more

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R Caused by: java.security.cert.CertPathValidatorException: The certificate issued by CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US is not trusted; internal cause is:

java.security.cert.CertPathValidatorException: Certificate chaining error

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.security.cert.BasicChecker.(BasicChecker.java:111)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.security.cert.PKIXCertPathValidatorImpl.engineValidate(PKIXCertPathValidatorImpl.java:176)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.security.cert.PKIXCertPathBuilderImpl.myValidator(PKIXCertPathBuilderImpl.java:732)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.security.cert.PKIXCertPathBuilderImpl.buildCertPath(PKIXCertPathBuilderImpl.java:649)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.security.cert.PKIXCertPathBuilderImpl.buildCertPath(PKIXCertPathBuilderImpl.java:595)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.security.cert.PKIXCertPathBuilderImpl.engineBuild(PKIXCertPathBuilderImpl.java:357)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R ... 50 more

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R Caused by: java.security.cert.CertPathValidatorException: Certificate chaining error

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.security.cert.CertPathUtil.findIssuer(CertPathUtil.java:298)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R at com.ibm.security.cert.BasicChecker.(BasicChecker.java:108)

[20-7-16 12:59:11:601 CST] 00000040 SystemErr R ... 55 more

部分代码如下:

public String uploadImage() throws Exception {

 Log.debug("进入uploadImage()方法�?...");
 /*String savePath = req.getSession().getServletContext().getRealPath("")+"/upload";
 System.out.println("savePath:"+savePath);*/
 String accsesstoken = getParameter("accsesstoken");
 String imgBase64 = getParameter("base64Code");
 String type = getParameter("type");
 String fileName = getParameter("fileName");
 WechatMedia media = new WechatMedia();
 DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
 String createtime = df2.format(new Date());
 media.setCreateTime(createtime);
 media.setMediaName(fileName);
 media.setMediaType(type);

    String filePath = "D:\\WxPic\\";
    File dirFile = new File(filePath);
    if (!dirFile.exists()) {
        dirFile.mkdirs();
    }
    imgBase64= imgBase64.substring(imgBase64.indexOf(",")+1);
   // System.out.println(imgBase64);
    BASE64Decoder decoder = new BASE64Decoder(); //Base64解码  
    byte[] b = decoder.decodeBuffer(imgBase64);  
    for(int i=0;i<b.length;++i)  
    {  
        if(b[i]<0)  
        {//调整异常数据  
            b[i]+=256;  
        }  
    }  
   //新生成的图片  
    OutputStream out = new FileOutputStream(filePath+fileName);      
    out.write(b);  
    out.flush();  
    out.close();  
 dirFile = new File(filePath);
 System.out.println("111111111");
    String url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token="+accsesstoken+"&type="+type;
    File item = new File(dirFile, fileName);
    String result = RequestUtils.f_upload(item, url, fileName);
    System.out.println(result);
    JSONObject jsonObject = ApplicationUtils.formatJSONObject(result);
    media.setMediaID(jsonObject.getString("media_id"));
    media.setMediaUrl(jsonObject.getString("url"));
 media.setMediaID(CommonUtil.getRandomReqNo());
    media
  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 已采纳回答 12月16日

      悬赏问题

      • ¥15 uniapp实现钉钉【发起审批实例】上传文件到钉盘,后端为C#.Net处理
      • ¥15 求深信服VDI基准测试工具Sangfor DTP
      • ¥20 使用python中pandas进行数据分析
      • ¥20 使用python中pandas进行数据分析
      • ¥15 导入数据,并且以utf-8为编码格式,但是以上代码报错,求解答
      • ¥15 关于#游戏程序#的问题:端 玩wy服务器10几分钟闪退一次没有任何提示,连启动器一起闪退 本人电脑5800h 3060 16运内 win11 求解答
      • ¥15 做一个手游私服需要什么条件?
      • ¥15 关于企业微信,调用官方 微盘api 时候access_token过期的问题?
      • ¥15 请问这个C语言代码的界面怎样修改
      • ¥15 QT for Android 开发的App后台切换后卡死,没有响应